/* ===== SnWebTech CRM — Admin Panel CSS ===== */
:root {
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --purple: #7c3aed;
  --teal: #0f766e;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(37,99,235,0.2);
  --sidebar-active-text: #60a5fa;
  --body-bg: #f1f5f9;
  --card-bg: #fff;
  --card-border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --topbar-bg: #fff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--body-bg); color: var(--text-main); font-size: 14px; line-height: 1.6; }
a { text-decoration: none; color: inherit; }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-height);
  background: var(--topbar-bg); border-bottom: 1px solid var(--card-border);
  display: flex; align-items: center; padding: 0 20px; z-index: 1000;
  box-shadow: var(--shadow-sm); gap: 12px;
}
.sidebar-toggle { background: none; border: none; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--text-muted); }
.sidebar-toggle:hover { background: var(--body-bg); }
.brand-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-main); }
.brand-icon { width: 32px; height: 32px; background: var(--primary); color: #fff; border-radius: 8px; display:flex; align-items:center; justify-content:center; font-size:16px; }
.brand-name { font-size: 15px; }
.brand-tag { font-size: 10px; background: var(--primary); color: #fff; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.btn-topbar { background: none; border: none; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--text-muted); position:relative; }
.btn-topbar:hover { background: var(--body-bg); color: var(--text-main); }
.notif-badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 10px; min-width: 16px; text-align: center; }
.topbar-time { font-size: 13px; color: var(--text-muted); }
.user-avatar-sm { width: 30px; height: 30px; background: var(--primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.user-menu { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.notif-dropdown { width: 320px; padding: 0; }
.notif-list { max-height: 280px; overflow-y: auto; }
.notif-item { padding: 10px 16px; border-bottom: 1px solid var(--card-border); cursor: pointer; }
.notif-item:hover { background: var(--body-bg); }
.notif-item.unread { background: #eff6ff; }
.notif-item .notif-title { font-size: 13px; font-weight: 600; }
.notif-item .notif-time { font-size: 11px; color: var(--text-muted); }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: var(--topbar-height); left: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--sidebar-bg);
  overflow-y: auto; overflow-x: hidden; z-index: 900;
  transition: transform 0.3s ease; padding-bottom: 20px;
  scrollbar-width: thin; scrollbar-color: #1e293b transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #1e293b; }
.sidebar-brand { padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.06); color: #fff; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sidebar-menu { padding: 8px 0; }
.menu-label { padding: 12px 20px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: #475569; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  transition: all 0.15s ease; position: relative; cursor: pointer;
  border-left: 3px solid transparent;
}
.menu-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.menu-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); border-left-color: var(--primary); }
.menu-item i { font-size: 16px; min-width: 20px; text-align: center; }
.menu-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }

/* ===== LAYOUT ===== */
.layout-wrapper { display: flex; min-height: 100vh; }
.main-content {
  margin-left: var(--sidebar-width); margin-top: var(--topbar-height);
  padding: 24px; flex: 1; min-width: 0; transition: margin-left 0.3s ease;
}
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text-main); margin: 0; }
.page-sub { font-size: 13px; color: var(--text-muted); margin: 2px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== CARDS ===== */
.card-panel {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-title { font-size: 14px; font-weight: 600; color: var(--text-main); margin: 0; }
.panel-link { font-size: 12px; color: var(--primary); }
.panel-link:hover { text-decoration: underline; }

/* ===== STAT CARDS ===== */
.stat-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--card-border); box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1; color: var(--text-main); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-blue .stat-icon  { background: #eff6ff; color: var(--primary); }
.stat-green .stat-icon { background: #f0fdf4; color: var(--success); }
.stat-orange .stat-icon{ background: #fffbeb; color: var(--warning); }
.stat-red .stat-icon   { background: #fef2f2; color: var(--danger); }
.stat-purple .stat-icon{ background: #f5f3ff; color: var(--purple); }
.stat-teal .stat-icon  { background: #f0fdfa; color: var(--teal); }
.stat-warning .stat-icon{ background: #fffbeb; color: var(--warning); }
.stat-dark .stat-icon  { background: #f8fafc; color: #334155; }

/* ===== TABLES ===== */
.table { font-size: 13.5px; }
.table thead th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--card-border); padding: 10px 12px; white-space: nowrap; }
.table tbody td { padding: 12px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table-hover tbody tr:hover { background: #f8fafc; }
.data-table tbody tr { cursor: default; }
.crm-table { margin: 0; }

/* ===== STATUS BADGES ===== */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.status-active, .status-paid, .status-approved, .status-closed, .status-success { background: #dcfce7; color: #15803d; }
.status-inactive, .status-cancelled, .status-rejected { background: #fee2e2; color: #b91c1c; }
.status-pending, .status-open, .status-draft, .status-not_started { background: #fef3c7; color: #92400e; }
.status-partial, .status-in_progress, .status-sent, .status-viewed { background: #dbeafe; color: #1e40af; }
.status-overdue, .status-expired, .status-critical { background: #fee2e2; color: #b91c1c; }
.status-resolved, .status-completed { background: #dcfce7; color: #15803d; }
.status-on_hold { background: #f3f4f6; color: #374151; }

/* ===== BUTTONS ===== */
.btn { font-size: 13px; font-weight: 500; border-radius: var(--radius-sm); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== FORMS ===== */
.form-control, .form-select { font-size: 13.5px; border-radius: var(--radius-sm); border-color: #d1d5db; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-main); margin-bottom: 4px; }

/* ===== AVATAR ===== */
.avatar-xl { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.avatar-text { background: var(--primary); color: #fff; font-weight: 700; font-size: 22px; }
.avatar-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; }
.bg-primary-soft { background: #eff6ff; }
.bg-info-soft { background: #ecfeff; }
.bg-success-soft { background: #f0fdf4; }
.bg-warning-soft { background: #fffbeb; }

/* ===== LIST ROWS ===== */
.list-scroll { max-height: 320px; overflow-y: auto; }
.list-row-compact { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.list-row-compact:last-child { border-bottom: none; }
.list-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.list-icon-globe { background: #eff6ff; color: var(--primary); }
.list-icon-blue  { background: #eff6ff; color: var(--primary); }
.list-icon-red   { background: #fef2f2; color: var(--danger); }
.list-icon-green { background: #f0fdf4; color: var(--success); }
.smaller { font-size: 11px; }

/* ===== INFO GRID ===== */
.info-grid { border: 1px solid var(--card-border); border-radius: var(--radius-sm); overflow: hidden; }
.info-row { display: flex; border-bottom: 1px solid var(--card-border); }
.info-row:last-child { border-bottom: none; }
.info-label { flex: 0 0 45%; padding: 8px 12px; background: #f8fafc; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; }
.info-value { flex: 1; padding: 8px 12px; font-size: 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }

/* ===== TOTALS BOX ===== */
.totals-box { background: #f8fafc; border-radius: var(--radius-sm); padding: 16px; }
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 13px; }
.total-grand { font-size: 16px; font-weight: 700; padding-top: 8px; }

/* ===== INVOICE BUILDER ===== */
.invoice-items-table { border: 1px solid var(--card-border); border-radius: var(--radius-sm); overflow: hidden; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; color: var(--text-muted); }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: #fff; max-width: 320px; box-shadow: var(--shadow-md); animation: slideIn 0.3s ease; display: flex; align-items: center; gap: 8px; }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--info); }
.toast-warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== MODAL ===== */
.modal-content { border-radius: var(--radius); border: none; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { border-bottom: 1px solid var(--card-border); padding: 16px 20px; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-footer { border-top: 1px solid var(--card-border); }

/* ===== PROGRESS BARS ===== */
.progress { height: 6px; border-radius: 10px; background: #e2e8f0; }
.progress-bar { border-radius: 10px; transition: width 0.6s ease; }

/* ===== ALERTS ===== */
.alert { font-size: 13.5px; border-radius: var(--radius-sm); }
.alert-sm { font-size: 12px; padding: 8px 12px; }

/* ===== PAGINATION ===== */
.pagination .page-link { font-size: 12px; padding: 4px 10px; color: var(--text-muted); border-color: var(--card-border); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .stat-value { font-size: 18px; }
  .topbar { padding: 0 12px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 576px) {
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }
  .card-panel { padding: 14px; }
}

/* ===== UTILITIES ===== */
.cursor-pointer { cursor: pointer; }
.font-monospace { font-family: 'Courier New', monospace !important; }
.bg-purple { background: var(--purple) !important; }
.text-purple { color: var(--purple) !important; }
.sticky-top { position: sticky; }
