/* SnWebTech CRM — Custom Stylesheet */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar-bg: #1e2a3a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #3b82f6;
  --sidebar-hover: rgba(59,130,246,.12);
  --topbar-height: 60px;
  --sidebar-width: 240px;
  --body-bg: #f4f6fb;
  --card-radius: 12px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { font-family: var(--font-main); background: var(--body-bg); color: #1e293b; font-size: 14px; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-width);
  background: var(--sidebar-bg); z-index: 1040; overflow-y: auto;
  overflow-x: hidden; transition: width .25s ease; display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }
.sidebar-logo { padding: 18px 20px 14px; border-bottom: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.sidebar-logo .logo-text { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; white-space: nowrap; }
.sidebar-logo .logo-sub { color: var(--sidebar-text); font-size: 11px; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-section { padding: 10px 18px 4px; font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: #475569; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 18px; color: var(--sidebar-text);
  text-decoration: none; font-size: 13.5px; border-radius: 0; transition: all .18s; white-space: nowrap;
}
.sidebar-nav a i { width: 18px; text-align: center; opacity: .85; flex-shrink: 0; font-size: 14px; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-nav a.active { background: rgba(59,130,246,.18); color: #fff; border-left: 3px solid var(--sidebar-active); }
.sidebar-nav a.active i { opacity: 1; }
.sidebar-footer { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.sidebar-footer a { color: var(--sidebar-text); font-size: 13px; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.sidebar-footer a:hover { color: #fff; }
.sidebar-badge { margin-left: auto; background: #ef4444; color: #fff; border-radius: 10px; font-size: 10px; font-weight: 700; padding: 1px 6px; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-width); min-height: 100vh; transition: margin-left .25s ease; }
@media (max-width: 991.98px) { .main-content { margin-left: 0; } .sidebar { transform: translateX(-100%); } .sidebar.show { transform: translateX(0); } }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar { height: var(--topbar-height); background: #fff; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; padding: 0 24px; position: sticky; top: 0; z-index: 1030; gap: 14px; }
.topbar-title { font-weight: 600; font-size: 15px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.notif-bell { position: relative; cursor: pointer; padding: 6px; border-radius: 8px; transition: background .15s; }
.notif-bell:hover { background: #f1f5f9; }
.notif-badge { position: absolute; top: 2px; right: 2px; background: #ef4444; color: #fff; border-radius: 50%; width: 16px; height: 16px; font-size: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; background: var(--primary); flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; background: var(--primary); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card { border-radius: var(--card-radius) !important; border: 1px solid #e9edf3 !important; }
.card.shadow-sm { box-shadow: 0 1px 6px rgba(0,0,0,.07) !important; }
.card-header { font-size: 14px; font-weight: 600; padding: 14px 18px 4px !important; background: transparent !important; border-bottom: 0 !important; }
.card-body { padding: 16px 18px !important; }
.card-footer { padding: 10px 18px !important; }

/* ── Stat Cards ───────────────────────────────────────────────────────────── */
.stat-card { border-radius: var(--card-radius); padding: 20px 18px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.07); position: relative; overflow: hidden; }
.stat-card .stat-icon { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 36px; opacity: .10; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; color: #64748b; margin-top: 4px; }
.stat-card .stat-change { font-size: 11px; margin-top: 8px; }
.stat-card.primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; }
.stat-card.success { background: linear-gradient(135deg, #16a34a, #15803d); color: #fff; }
.stat-card.warning { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.stat-card.danger  { background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff; }
.stat-card.info    { background: linear-gradient(135deg, #0891b2, #0e7490); color: #fff; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table > :not(caption) > * > * { padding: .6rem 1rem; }
.table thead th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: #64748b; border-bottom-width: 1px; white-space: nowrap; }
.table tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table th, .table td { vertical-align: middle; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { font-weight: 500; letter-spacing: .3px; }
.badge.bg-active, .badge.bg-success { background-color: #16a34a !important; }
.badge.bg-pending  { background-color: #d97706 !important; }
.badge.bg-inactive { background-color: #64748b !important; }
.badge.bg-overdue  { background-color: #dc2626 !important; }
.badge.bg-partial  { background-color: #0891b2 !important; }
.badge.bg-open     { background-color: #2563eb !important; }
.badge.bg-resolved { background-color: #16a34a !important; }
.badge.bg-closed   { background-color: #64748b !important; }
.badge.bg-in_progress  { background-color: #7c3aed !important; }
.badge.bg-waiting_client { background-color: #0891b2 !important; }
.badge.bg-urgent   { background-color: #dc2626 !important; }
.badge.bg-high     { background-color: #ea580c !important; }
.badge.bg-medium   { background-color: #d97706 !important; }
.badge.bg-low      { background-color: #64748b !important; }
.badge.text-xs { font-size: 10px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-control, .form-select { border-color: #d1d5db; border-radius: 8px; font-size: 13.5px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-label { font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 5px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { border-radius: 8px; font-size: 13.5px; font-weight: 500; }
.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background-color: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { font-size: 12px; padding: .3rem .65rem; }
.btn-xs { font-size: 11px; padding: .2rem .45rem; border-radius: 5px; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination-wrap { padding: 12px 16px; border-top: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.pagination .page-link { border-radius: 7px; font-size: 13px; padding: .3rem .65rem; color: var(--primary); border-color: #e5e7eb; }
.pagination .page-item.active .page-link { background-color: var(--primary); border-color: var(--primary); }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-content { border-radius: 14px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.modal-header { border-bottom: 1px solid #f1f5f9; padding: 18px 20px 14px; }
.modal-footer { border-top: 1px solid #f1f5f9; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#crm-toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.crm-toast { min-width: 280px; max-width: 360px; background: #fff; border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,.16); padding: 12px 16px; display: flex; align-items: flex-start; gap: 10px; pointer-events: auto; animation: slideInRight .25s ease; }
.crm-toast.removing { animation: slideOutRight .25s ease forwards; }
.crm-toast-icon { flex-shrink: 0; font-size: 16px; margin-top: 1px; }
.crm-toast.success .crm-toast-icon { color: #16a34a; }
.crm-toast.danger  .crm-toast-icon { color: #dc2626; }
.crm-toast.warning .crm-toast-icon { color: #d97706; }
.crm-toast.info    .crm-toast-icon { color: #2563eb; }
.crm-toast-msg { flex: 1; font-size: 13.5px; color: #1e293b; line-height: 1.4; }
.crm-toast-close { cursor: pointer; color: #94a3b8; font-size: 15px; line-height: 1; padding: 0 2px; }
.crm-toast-close:hover { color: #475569; }
@keyframes slideInRight  { from { opacity:0; transform: translateX(30px); } to { opacity:1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity:1; transform: translateX(0); } to { opacity:0; transform: translateX(30px); } }

/* ── Auth Pages ───────────────────────────────────────────────────────────── */
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e2a3a 0%, #2563eb 100%); padding: 24px; }
.auth-card { background: #fff; border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 420px; box-shadow: 0 24px 80px rgba(0,0,0,.22); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo img, .auth-logo .logo-icon { height: 48px; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.text-sm { font-size: 13px !important; }
.text-xs { font-size: 11px !important; }
.font-monospace { font-family: 'SFMono-Regular', Consolas, monospace; }
.bg-primary-soft { background-color: rgba(37,99,235,.1); }
.bg-success-soft { background-color: rgba(22,163,74,.1); }
.bg-warning-soft { background-color: rgba(217,119,6,.1); }
.bg-danger-soft  { background-color: rgba(220,38,38,.1); }
.bg-info-soft    { background-color: rgba(8,145,178,.1); }
.page-loader { position: fixed; inset: 0; background: rgba(255,255,255,.7); z-index: 9998; display: flex; align-items: center; justify-content: center; }
hr { border-color: #f1f5f9; }
.alert { border-radius: 10px; font-size: 13px; }

/* ── Notification list ────────────────────────────────────────────────────── */
.notification-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }

/* ── Invoice PDF preview ──────────────────────────────────────────────────── */
.invoice-preview { background: #fff; padding: 40px; max-width: 800px; margin: 0 auto; font-size: 13px; }
.invoice-preview .inv-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; }
.invoice-preview .inv-table th { background: #f8fafc; }
.invoice-preview .inv-total { font-size: 15px; font-weight: 700; }

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress { border-radius: 10px; background: #e9ecef; }
.progress-bar { border-radius: 10px; }

/* ── Responsive tweaks ────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .table-responsive-sm .table { min-width: 600px; }
  .stat-card .stat-value { font-size: 20px; }
  .card-body { padding: 14px !important; }
  h4.fw-bold { font-size: 16px; }
}
@media print {
  .sidebar, .topbar, .btn, .pagination-wrap { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { border: none !important; box-shadow: none !important; }
}
