/* =========================================================
   SAHIL SOLUTIONS — Design System
   Navy + brass palette, Inter type, card-free data tables
   that fold into labeled rows on small screens.
   ========================================================= */

:root {
  --navy-950: #0d1526;
  --navy-900: #121b30;
  --navy-800: #1a2745;
  --navy-700: #223258;
  --navy-100: #e7eaf3;

  --brass-500: #b9862f;
  --brass-600: #9c6f26;
  --brass-100: #f6ecd9;

  --bg: #f2f4f8;
  --surface: #ffffff;
  --border: #e2e6ee;

  --ink-900: #16213a;
  --ink-600: #4b5568;
  --ink-400: #8791a3;

  --green-600: #227a53;
  --green-100: #e2f4ec;
  --red-600: #b3392c;
  --red-100: #fbe9e6;
  --amber-600: #9a6a13;
  --amber-100: #fbf0da;

  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-1: 0 1px 2px rgba(13, 21, 38, 0.06), 0 1px 1px rgba(13, 21, 38, 0.04);
  --shadow-2: 0 8px 24px rgba(13, 21, 38, 0.10);

  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink-900);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; color: var(--ink-900); }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; color: var(--ink-600); }

:focus-visible {
  outline: 2px solid var(--brass-500);
  outline-offset: 2px;
}

/* ---------- App shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform 0.22s ease;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brass-500), var(--brass-600));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--navy-950); font-size: 15px; flex-shrink: 0;
}
.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 15px; font-weight: 650; color: #fff; }
.brand-text span { display: block; font-size: 11.5px; color: rgba(255,255,255,0.5); }

.nav-group { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-label { padding: 8px 10px 4px; font-size: 11px; color: rgba(255,255,255,0.35); }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,0.75); font-size: 14px; font-weight: 500; margin-bottom: 2px;
}
.nav-item svg { flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: rgba(185, 134, 47, 0.16);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brass-500);
}

.sidebar-footer { padding: 14px 16px 18px; border-top: 1px solid rgba(255,255,255,0.08); }
.admin-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.admin-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy-700); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 650; flex-shrink: 0;
}
.admin-meta { line-height: 1.25; overflow: hidden; }
.admin-meta strong { display: block; font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-meta span { font-size: 11.5px; color: rgba(255,255,255,0.45); }

.logout-link {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; padding: 9px 10px; border-radius: 8px;
  font-size: 13.5px; color: rgba(255,255,255,0.65);
}
.logout-link:hover { background: rgba(255,255,255,0.06); color: #fff; }

/* ---------- Main column ---------- */

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(242, 244, 248, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
}
.hamburger {
  display: none; width: 38px; height: 38px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  align-items: center; justify-content: center; flex-shrink: 0;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 18px; margin: 0; }
.topbar-title p { margin: 0; font-size: 12.5px; }

.content { padding: 22px 24px 90px; max-width: 1180px; width: 100%; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(13, 21, 38, 0.45); z-index: 35; }
.sidebar-overlay.show { display: block; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 550; border: 1px solid transparent;
  cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { background: var(--navy-800); }
.btn-brass { background: var(--brass-500); color: #fff; }
.btn-brass:hover { background: var(--brass-600); }
.btn-outline { background: var(--surface); color: var(--ink-900); border-color: var(--border); }
.btn-outline:hover { background: var(--navy-100); }
.btn-ghost { background: transparent; color: var(--ink-600); }
.btn-ghost:hover { background: var(--navy-100); color: var(--ink-900); }
.btn-danger { background: var(--red-100); color: var(--red-600); }
.btn-danger:hover { background: #f6d6d1; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Cards ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-1); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-body { padding: 20px; }

/* ---------- Stat cards ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-grid.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px 20px; box-shadow: var(--shadow-1); position: relative; overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brass-500); }
.stat-label { font-size: 12.5px; color: var(--ink-400); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--navy-900); letter-spacing: -0.02em; }
.stat-sub { font-size: 12.5px; color: var(--ink-400); margin-top: 4px; }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--ink-900); }
label .req { color: var(--red-600); }

input[type="text"], input[type="date"], input[type="number"], input[type="email"],
input[type="password"], input[type="search"], input[type="tel"], textarea, select {
  width: 100%; padding: 11px 13px; font-size: 15px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-900); font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brass-500); box-shadow: 0 0 0 3px rgba(185, 134, 47, 0.15);
}
.field-hint { font-size: 12px; color: var(--ink-400); }
.field-error { font-size: 12.5px; color: var(--red-600); }
input.invalid, textarea.invalid, select.invalid { border-color: var(--red-600); }

.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------- Toggle switch (permissions) ---------- */

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px dashed var(--border);
  gap: 12px;
}
.switch-row:last-child { border-bottom: none; }
.switch-label { font-size: 13.5px; font-weight: 550; color: var(--ink-900); }
.switch-desc { font-size: 12px; color: var(--ink-400); margin-top: 1px; }
.switch {
  position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; cursor: pointer; inset: 0;
  background: #d7dce6; border-radius: 999px; transition: 0.15s ease;
}
.switch-track::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.15s ease; box-shadow: var(--shadow-1);
}
.switch input:checked + .switch-track { background: var(--brass-500); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

/* ---------- Alerts ---------- */

.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: var(--green-100); color: var(--green-600); border-color: #c3e8d5; }
.alert-error   { background: var(--red-100); color: var(--red-600); border-color: #f3c9c2; }
.alert-info    { background: var(--navy-100); color: var(--navy-800); border-color: #d7deef; }
.alert-warning { background: var(--amber-100); color: var(--amber-600); border-color: #f0dead; }

/* ---------- Auth pages ---------- */

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 15%, #1a2745 0%, #0d1526 55%, #0a0f1d 100%);
  padding: 20px;
}
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2); padding: 32px 30px 28px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; text-align: center; }
.auth-brand .brand-mark { width: 46px; height: 46px; font-size: 19px; margin-bottom: 12px; }
.auth-brand strong { font-size: 18px; font-weight: 700; color: var(--navy-900); }
.auth-brand span { font-size: 12.5px; color: var(--ink-400); margin-top: 2px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 12px; color: var(--ink-400); }

/* ---------- Toolbar / search ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input { padding-left: 38px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-400); }

.filter-panel { display: none; gap: 14px 16px; grid-template-columns: repeat(4, 1fr); padding: 16px 20px; margin-bottom: 16px; }
.filter-panel.show { display: grid; }
.filter-panel .form-actions { grid-column: 1 / -1; margin: 4px 0 0; padding: 0; border: none; }

/* ---------- Data table ---------- */

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th { text-align: left; padding: 12px 16px; font-size: 11.5px; color: var(--ink-400); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--ink-900); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfd; }
.cell-muted { color: var(--ink-400); }
.cell-strong { font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-600);
}
.icon-btn:hover { background: var(--navy-100); color: var(--navy-900); }
.icon-btn.danger:hover { background: var(--red-100); color: var(--red-600); border-color: #f3c9c2; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--brass-100); color: var(--brass-600); }
.badge-role-admin { background: var(--navy-100); color: var(--navy-800); }
.badge-status-active { background: var(--green-100); color: var(--green-600); }
.badge-status-inactive { background: var(--red-100); color: var(--red-600); }

.empty-state { text-align: center; padding: 54px 20px; }
.empty-state svg { color: var(--ink-400); margin-bottom: 14px; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { margin-bottom: 18px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--ink-400); }
.pagination .pages { display: flex; gap: 6px; }
.pagination a.page-link, .pagination span.page-link {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--border); font-size: 12.5px; color: var(--ink-600);
}
.pagination a.page-link:hover { background: var(--navy-100); }
.pagination .page-link.active { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }

/* ---------- Detail view ---------- */

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 24px; }
.detail-item { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.detail-item.full { grid-column: 1 / -1; }
.detail-item .d-label { font-size: 12px; color: var(--ink-400); margin-bottom: 4px; }
.detail-item .d-value { font-size: 15.5px; color: var(--ink-900); font-weight: 550; }

/* ---------- Confirm modal ---------- */

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(13, 21, 38, 0.5); z-index: 60; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal-box { background: var(--surface); border-radius: 12px; width: 100%; max-width: 380px; padding: 24px; box-shadow: var(--shadow-2); }
.modal-box h3 { margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ---------- Tabs (profile page) ---------- */

.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 16px; font-size: 13.5px; font-weight: 550; color: var(--ink-400); border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--navy-900); border-bottom-color: var(--brass-500); }

/* ---------- Utility ---------- */

.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 980px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-2); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .content { padding: 16px 14px 90px; }
  .topbar { padding: 12px 14px; }
  .stat-grid { grid-template-columns: 1fr; }
  .filter-panel { grid-template-columns: 1fr; }
  .card-pad, .card-body { padding: 16px; }

  table.data-table thead { display: none; }
  table.data-table, table.data-table tbody, table.data-table tr, table.data-table td { display: block; width: 100%; }
  table.data-table tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; padding: 6px 4px; background: var(--surface); }
  table.data-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 12px; border-bottom: 1px dashed var(--border); text-align: right; }
  table.data-table td:last-child { border-bottom: none; }
  table.data-table td::before { content: attr(data-label); font-size: 11.5px; color: var(--ink-400); font-weight: 600; text-align: left; }
  table.data-table td.row-actions { justify-content: flex-end; }
  table.data-table td.row-actions::before { content: ''; }

  .auth-card { padding: 26px 20px; }
}
