/* ── Variables ─────────────────────────────────────────────────── */
/* Design tokens per design-spec.md — Indigo brand on a neutral Slate
   scale. Keeping these as CSS custom properties (plus the matching
   literal hex values hardcoded in templates as Tailwind arbitrary
   values, e.g. text-[#4f46e5]) is what lets the sidebar/topbar chrome,
   every module's cards/tables/forms, and the dashboard read as one
   system — see design-spec.md §§1-3. */
:root {
  --primary:        #4f46e5;  /* indigo-600 */
  --primary-dark:   #4338ca;  /* indigo-700 — hover state */
  --primary-light:  #eef2ff;  /* indigo-50 — tint backgrounds */
  --primary-border: #e0e7ff;  /* indigo-100 — tint borders */
  --bg:             #f8fafc;  /* slate-50 — app canvas */
  --sidebar-bg:     #FFFFFF;
  --card-bg:        #FFFFFF;
  --text:           #0f172a;  /* slate-900 — headings, KPI numbers */
  --text-secondary: #334155;  /* slate-700 — body/labels */
  --text-muted:     #64748b;  /* slate-500 — captions, meta text */
  --text-faint:     #94a3b8;  /* slate-400 — placeholders, faint labels */
  --success:        #059669;  /* emerald-600 */
  --warning:        #d97706;  /* amber-600 */
  --danger:         #dc2626;  /* red-600 */
  --border:         #e2e8f0;  /* slate-200 — default borders */
  --border-subtle:  #f1f5f9;  /* slate-100 — row dividers, internal separators */
  --sidebar-border: #e2e8f0;
  --sidebar-w:      256px;
  --radius:         8px;      /* buttons, inputs, badges */
  --radius-lg:      12px;     /* cards, panels */
  --shadow:         none;     /* cards rest on a border, not a shadow — §12 */
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 20;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: 64px;
  border-bottom: 1px solid var(--border-subtle);
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-text { line-height: 1.2; }
.brand-name { font-size: 16px; font-weight: 700; color: var(--text); }
.brand-tagline { font-size: 9px; font-weight: 600; letter-spacing: .12em; color: var(--text-faint); margin-top: -2px; }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 400;
  font-size: 14px;
  transition: background .15s ease-out, color .15s ease-out;
  width: calc(100% - 16px);
}
.nav-item:hover { background: var(--border-subtle); color: var(--text-muted); text-decoration: none; }
.nav-item.active { color: var(--primary); background: var(--primary-light); font-weight: 600; }
.nav-icon { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }

.nav-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 6px;
}
.nav-sub:hover { color: var(--primary); background: var(--primary-light); text-decoration: none; }
.nav-sub.active { color: var(--primary); font-weight: 600; }

.nav-divider { height: 1px; background: var(--border); margin: 8px 0; }

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
}
.footer-user-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--text);
}
.footer-user-link:hover { background: var(--border-subtle); text-decoration: none; }
.footer-avatar { font-size: 22px; color: var(--text-faint); flex-shrink: 0; display: flex; align-items: center; }
.footer-user {
  min-width: 0;
  display: flex;
  align-items: baseline;
  white-space: nowrap;
  overflow: hidden;
}
.user-name { font-weight: 600; font-size: 13px; color: inherit; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-faint); text-transform: capitalize; flex-shrink: 0; }
.user-role::before { content: '\00b7'; margin: 0 5px; color: var(--border); }
.footer-logout-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); color: var(--text-faint); font-size: 14px;
}
.footer-logout-btn:hover { background: #fef2f2; color: var(--danger); text-decoration: none; }

/* ── Main Content ──────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--sidebar-border);
  height: 64px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.page-subtitle { font-size: 14px; font-weight: 400; color: var(--text-muted); }

.content-area { padding: 24px; flex: 1; }

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.alert-success { background: #ecfdf5; color: var(--success); }
.alert-danger   { background: #fef2f2; color: var(--danger); }
.alert-error    { background: #fef2f2; color: var(--danger); }
.alert-warning  { background: #fffbeb; color: var(--warning); }
.alert-info     { background: #dbeafe; color: #1e40af; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

/* ── Stats ─────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }

/* ── Tables ────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border-subtle); font-size: 13px;
}
.table th {
  font-weight: 700; color: var(--text-muted); background: #fafafa;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }

.table-th {
  padding: 10px 14px; text-align: left;
  font-weight: 700; color: var(--text-muted); background: #fafafa;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border-subtle);
}
.table-td {
  padding: 10px 14px; text-align: left;
  font-size: 13px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Buttons ───────────────────────────────────────────────────── */
/* Radius 8px, height ~36-40px on all variants per design-spec §9 (not pills). */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  transition: background .15s ease-out, color .15s ease-out; text-decoration: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  box-shadow: 0 1px 2px 0 rgba(79,70,229,.25);
  transition: background .15s ease-out; text-decoration: none;
  line-height: 1.4;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--text-secondary);
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border);
  transition: background .15s ease-out; text-decoration: none;
  line-height: 1.4;
}
.btn-secondary:hover { background: var(--bg); color: var(--text-secondary); text-decoration: none; }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--danger); color: #fff;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  transition: background .15s ease-out; text-decoration: none;
  line-height: 1.4;
}
.btn-danger:hover { background: #b91c1c; color: #fff; text-decoration: none; }

.btn-sm { padding: 5px 12px !important; font-size: 12px !important; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .4px;
}
.form-control, .form-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px; font-family: inherit;
  color: var(--text-secondary); background: #fff;
  transition: border-color .15s ease-out, box-shadow .15s ease-out;
}
.form-control:focus, .form-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99,102,241,.3);
}
select.form-control, select.form-input { cursor: pointer; }

/* ── Login ─────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--primary); margin-top: 8px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn-primary { margin-top: 8px; }

/* ── Badges ────────────────────────────────────────────────────── */
/* Full (pill) radius per design-spec §11 "pills/avatars: full". */
.badge-available { display: inline-flex; align-items: center; gap: 4px; background: #ecfdf5; color: var(--success); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-allocated { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-light); color: var(--primary); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-repair    { display: inline-flex; align-items: center; gap: 4px; background: #fffbeb; color: var(--warning); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-disposed  { display: inline-flex; align-items: center; gap: 4px; background: #fef2f2; color: var(--danger); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-active    { display: inline-flex; align-items: center; gap: 4px; background: #ecfdf5; color: var(--success); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-inactive  { display: inline-flex; align-items: center; gap: 4px; background: #f1f5f9; color: var(--text-muted); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-returned  { display: inline-flex; align-items: center; gap: 4px; background: #f1f5f9; color: var(--text-secondary); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-success   { background: #ecfdf5; color: var(--success); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-warning   { background: #fffbeb; color: var(--warning); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-danger    { background: #fef2f2; color: var(--danger); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-info      { background: var(--primary-light); color: var(--primary); padding: 2px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; display: inline-block; }

/* ── Filter chips & tabs (design-spec §10) ────────────────────────
   Available for any page that needs a chip filter row or a segmented
   view toggle (Week/Month/List-style); not every list view uses these
   yet, but new ones should reach for these classes first. */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: background .15s ease-out, color .15s ease-out, border-color .15s ease-out;
}
.chip:hover { background: var(--bg); text-decoration: none; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.view-toggle {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--border-subtle); border-radius: var(--radius);
  padding: 3px;
}
.view-toggle-item {
  padding: 6px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: background .15s ease-out, color .15s ease-out;
}
.view-toggle-item.active { background: #fff; color: var(--primary); box-shadow: 0 1px 2px 0 rgba(16,24,40,.06); }

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  background: #fff; cursor: pointer; text-decoration: none;
  transition: background .12s ease-out, border-color .12s ease-out, color .12s ease-out;
}
.page-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: .4; cursor: default; pointer-events: none; }

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 24px; text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .3; }

/* ── Grids ─────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Print styles ───────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .print\:hidden { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
  .layout { display: block !important; }
  .content-area { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  a { color: inherit !important; text-decoration: none !important; }
  body { background: #fff !important; }
}
