/**
 * app.css — NAOC-DOMS design tokens and shell styles.
 * Every colour used anywhere in the app is one of the --tokens defined on
 * :root below. Re-theming the whole application is a one-file edit here.
 */

:root {
  /* Brand palette — deep ordnance green + brass/gold, an institutional,
     restrained "mature/professional" identity rather than a flashy one. */
  --primary: #16342a;
  --primary-dark: #0c1f19;
  --primary-light: #1f4a3a;
  --accent: #c9a227;          /* brass/gold — used sparingly: active nav, key actions, card accents */
  --accent-dark: #a9851c;
  --navy: #1b2a4a;

  /* Surfaces & text */
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-alt: #fafaf8;
  --border: #e3e5e0;
  --text: #1d231f;
  --text-muted: #6b7369;
  --text-inverse: #f5f6f3;

  /* Status colours */
  --status-serviceable: #1f7a45;
  --status-unserviceable: #b3261e;
  --status-maintenance: #b8860b;
  --status-awaiting: #2f5fa8;
  --status-conditional: #7a5cc9;
  --status-retired: #6b7369;
  --status-disposed: #3b3f3c;
  --status-missing: #8a1c1c;

  /* Chrome */
  --sidebar-width: 264px;
  --topbar-height: 64px;
  --radius: 0.6rem;
  --radius-lg: 0.9rem;
  --shadow-sm: 0 1px 2px rgba(17, 24, 20, 0.06), 0 1px 1px rgba(17, 24, 20, 0.04);
  --shadow-md: 0 6px 16px rgba(17, 24, 20, 0.08), 0 2px 4px rgba(17, 24, 20, 0.05);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* This is a deliberately single-theme institutional dashboard (the palette
     above IS the brand), so form controls, scrollbars etc. stay light even
     when the OS/browser prefers dark — that avoids Bootstrap's own
     component defaults (labels, muted text) silently going low-contrast
     against a dark surface they don't know about. */
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--accent-dark); }

.brand-mark {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

/* ===================== Shell layout ===================== */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--primary-dark);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.25s ease;
}

.sidebar .sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-inverse);
}
.sidebar .sidebar-brand .bi { color: var(--accent); font-size: 1.3rem; flex-shrink: 0; }
.sidebar .sidebar-brand .brand-logo { height: 28px; width: auto; max-width: 64px; object-fit: contain; flex-shrink: 0; }
.sidebar .sidebar-brand .brand-mark { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0.6rem; }
.sidebar-nav .nav-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(245, 246, 243, 0.45);
  padding: 0.9rem 0.7rem 0.3rem;
}
.sidebar-nav .nav-link {
  color: rgba(245, 246, 243, 0.82);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.88rem;
}
.sidebar-nav .nav-link .bi { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: 0.9; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-inverse); }
.sidebar-nav .nav-link.active {
  background: rgba(201, 162, 39, 0.16);
  color: #fff;
  border-left: 3px solid var(--accent);
  padding-left: calc(0.75rem - 3px);
  font-weight: 600;
}
.sidebar-nav .nav-link.disabled { opacity: 0.4; pointer-events: none; }

.sidebar-user-link { display: block; color: inherit; }
.sidebar-user-link:hover { color: inherit; background: rgba(255, 255, 255, 0.05); }
.sidebar-user {
  padding: 0.85rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 84px; height: 84px; font-size: 1.9rem; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.75rem; }

.topbar-user-btn {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border: 1px solid transparent;
  background: none;
}
.topbar-user-btn:hover { background: var(--surface-alt); border-color: var(--border); }
.topbar-user-btn::after { margin-left: 0.15rem; }
.topbar-user-name { font-size: 0.85rem; font-weight: 600; color: var(--text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user .dropdown-menu { min-width: 220px; padding: 0.4rem 0; }
.topbar-user .dropdown-item { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; padding: 0.5rem 1rem; }
.topbar-user .dropdown-item .bi { width: 1.1rem; text-align: center; opacity: 0.75; }
.topbar-user .dropdown-menu form { margin: 0; }
.topbar-user .dropdown-header { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.sidebar-user .user-meta { line-height: 1.2; overflow: hidden; }
.sidebar-user .user-meta .name { font-size: 0.85rem; font-weight: 600; color: #fff; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.sidebar-user .user-meta .role { font-size: 0.72rem; color: rgba(245, 246, 243, 0.6); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1035;
}

.main-wrap {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* .app-shell is a plain block, so this is width:auto by normal block
     layout (fills everything right of the margin) — width/min-width below
     are just a defensive pin in case a future wrapper re-introduces flex. */
  width: auto;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  gap: 1rem;
}
.topbar .page-title { font-weight: 700; font-size: 1.05rem; }
.topbar .sidebar-toggle { display: none; border: none; background: none; font-size: 1.4rem; color: var(--text); }

.topbar-search { flex: 1; max-width: 360px; }
.topbar-search input {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.content-area { flex: 1; padding: 1.5rem; }

/* ===================== Cards & stats ===================== */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header { background: var(--surface-alt); border-bottom: 1px solid var(--border); font-weight: 600; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  height: 100%;
}
.stat-card .stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); line-height: 1.2; margin-top: 0.2rem; }
.stat-card .stat-icon {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
}
.stat-card.variant-accent .stat-icon { background: var(--accent); color: var(--primary-dark); }
.stat-card .stat-trend { font-size: 0.78rem; margin-top: 0.35rem; }
.stat-card .stat-trend.up { color: var(--status-serviceable); }
.stat-card .stat-trend.down { color: var(--status-unserviceable); }

/* ===================== Status badges ===================== */
.badge-status { font-weight: 600; font-size: 0.72rem; padding: 0.35em 0.6em; border-radius: 999px; }
.badge-serviceable { background: rgba(31,122,69,0.12); color: var(--status-serviceable); }
.badge-unserviceable { background: rgba(179,38,30,0.12); color: var(--status-unserviceable); }
.badge-under_maintenance { background: rgba(184,134,11,0.14); color: var(--status-maintenance); }
.badge-awaiting_inspection { background: rgba(47,95,168,0.12); color: var(--status-awaiting); }
.badge-conditionally_serviceable { background: rgba(122,92,201,0.12); color: var(--status-conditional); }
.badge-retired { background: rgba(107,115,105,0.14); color: var(--status-retired); }
.badge-disposed { background: rgba(59,63,60,0.14); color: var(--status-disposed); }
.badge-missing { background: rgba(138,28,28,0.14); color: var(--status-missing); }
.badge-active { background: rgba(31,122,69,0.12); color: var(--status-serviceable); }
.badge-inactive { background: rgba(107,115,105,0.14); color: var(--status-retired); }

.demo-badge {
  background: var(--accent);
  color: var(--primary-dark);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.25em 0.55em;
  border-radius: 4px;
  text-transform: uppercase;
}

/* ===================== Tables ===================== */
.table-toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.table-toolbar .flex-spacer { flex: 1; }
.table-responsive-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
table.table { margin-bottom: 0; }
table.table thead th {
  background: var(--surface-alt);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  padding: 0.9rem 1.1rem;
}
table.table td {
  vertical-align: middle;
  padding: 0.95rem 1.1rem;
  border-bottom-color: var(--border);
}
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: var(--surface-alt); }
table.table-sm td, table.table-sm th { padding: 0.6rem 0.85rem; }

/* Small thumbnail shown as the leading column on Assets/Inventory lists —
   a bit of visual variety plus a quick photo cue, without hunting a detail page. */
.list-thumb {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); background: var(--surface-alt); flex-shrink: 0;
}
.list-thumb-placeholder {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  background: var(--surface-alt); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1.1rem;
}

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .bi { font-size: 2.4rem; color: var(--border); display: block; margin-bottom: 0.75rem; }

/* ===================== Misc ===================== */
.section-divider { border-top: 1px solid var(--border); margin: 1.5rem 0; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--primary-dark); }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.text-accent { color: var(--accent-dark); }
.bg-brand { background: var(--primary); }

.chart-card canvas { max-height: 280px; }

.notification-item { border-bottom: 1px solid var(--border); padding: 0.75rem 1rem; }
.notification-item:last-child { border-bottom: none; }
.notification-item.unread { background: rgba(201,162,39,0.06); }

/* ===================== Password visibility toggle ===================== */
.password-group .password-toggle {
  background: var(--surface-alt);
  border-color: var(--border, #ced4da);
  color: var(--text-muted);
}
.password-group .password-toggle:hover { color: var(--text); background: var(--border); }
.password-group .password-toggle:focus { box-shadow: none; }

/* ===================== Upload dropzone ===================== */
.upload-dropzone {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  margin: 0;
}
.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.06);
}
.upload-dropzone-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.upload-dropzone-icon {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.upload-dropzone-body { min-width: 0; }
.upload-dropzone-text { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.upload-dropzone-hint { font-size: 0.74rem; color: var(--text-muted); display: block; }
.upload-dropzone-filename {
  font-size: 0.78rem; color: var(--primary-light); font-weight: 600;
  display: block; margin-top: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upload-preview {
  width: 64px; height: 64px; border-radius: var(--radius); object-fit: cover;
  border: 1px solid var(--border); flex-shrink: 0;
}

/* ===================== Responsive ===================== */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-wrap { margin-left: 0; }
  .topbar .sidebar-toggle { display: inline-flex; align-items: center; }
  .content-area { padding: 1rem; }
  .topbar-search { max-width: 200px; }
}

@media (max-width: 575.98px) {
  .topbar-search { display: none; }
  .content-area { padding: 0.75rem; }
}

/* ===================== Print ===================== */
@media print {
  .sidebar, .topbar, .sidebar-overlay, .table-toolbar, .btn, .no-print { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  body { background: #fff; }
  .card, .table-responsive-wrap { box-shadow: none !important; border: 1px solid #ccc !important; }
}
