/* Material Design 3 & Liquid Glass Design System */

:root {
  /* Material Design 3 Color Tokens - Clean Modern Palette */
  --md-sys-color-primary: #005CBB;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #D7E2FF;
  --md-sys-color-on-primary-container: #001A40;
  
  --md-sys-color-secondary: #565E71;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #DAE2F9;
  --md-sys-color-on-secondary-container: #131C2C;
  
  --md-sys-color-surface: rgba(255, 255, 255, 0.6);
  --md-sys-color-on-surface: #1B1B1F;
  --md-sys-color-surface-variant: rgba(225, 226, 236, 0.4);
  --md-sys-color-on-surface-variant: #44474F;
  
  --md-sys-color-outline: #74777F;
  --md-sys-color-outline-variant: #C4C6D0;
  
  --md-sys-color-error: #BA1A1A;
  --md-sys-color-on-error: #FFFFFF;
  
  /* Legacy/Support Variables */
  --bg-color: #f8f9ff;
  --primary-color: var(--md-sys-color-primary);
  --primary-hover: #004e9e;
  --border-radius-lg: 28px;
  --border-radius-md: 16px;
  --border-radius-sm: 12px;
  
  /* Liquid Glass Shadow */
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --glass-border: 1px solid rgba(255, 255, 255, 0.5);
  --glass-blur: blur(20px);
}

/* Light/Dark dynamic could be added but user asked for "Clean / White Background" */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--md-sys-color-on-surface);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout Container */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Material 3 Sidebar */
.sidebar {
  width: 280px;
  background: var(--md-sys-color-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: var(--glass-border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  position: fixed;
  /* Anchored top-to-bottom instead of height:100vh so the drawer still
     fills the screen exactly once the UI scale (see bottom of file) applies. */
  top: 0;
  bottom: 0;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo {
  padding: 5px 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.sidebar-logo img,
img.sidebar-logo {
  height: 150px;
  width: auto;
  object-fit: contain;
}

.sidebar-header {
  padding: 16px 16px 24px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.nav-links {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-links li,
.nav-links > a {
  margin-bottom: 4px;
}

.nav-links a {
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 100px; /* M3 Navigation Drawer style */
  transition: all 0.2s ease;
  font-weight: 500;
  text-decoration: none;
}

.nav-links a:hover {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface);
}

.nav-links a.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.main-content {
  flex: 1;
  padding: 32px;
  margin-left: 280px;
  width: calc(100% - 280px);
}

/* Sticky top banner (ID Cards, etc.) — keeps header + filters visible while scrolling */
.sticky-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-color);
  margin: -32px -32px 16px;
  padding: 32px 32px 4px;
  box-shadow: 0 6px 12px -8px rgba(0, 0, 0, 0.25);
}
@media (max-width: 768px) {
  .sticky-banner {
    margin: -24px -16px 12px;
    padding: 24px 16px 4px;
  }
}
@media print {
  .sticky-banner {
    position: static;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }
}

/* Liquid Glass Cards (OS26 Style) */
.card {
  background: var(--md-sys-color-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  margin-bottom: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card h3 {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--md-sys-color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* Pending count badges */
.pending-badge,
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #e53935;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.nav-badge {
  margin-left: 6px;
  min-width: 18px;
  height: 18px;
  font-size: 0.65rem;
}

/* M3 Typography Hierarchy */
h1 {
  font-size: 2.25rem;
  font-weight: 400;
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}

h2 {
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 16px;
}

.text-muted {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
}

.text-value {
  font-size: 2.5rem;
  font-weight: 300;
  color: var(--md-sys-color-primary);
}

/* Material 3 Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  height: 40px;
}

.btn-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(0, 92, 187, 0.25);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.btn-danger {
  background-color: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
}

/* M3 Form Fields */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  font-weight: 500;
  margin-left: 4px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  color: var(--md-sys-color-on-surface);
  font-size: 1rem;
  transition: all 0.2s;
  outline: none;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: rgba(255, 255, 255, 0.05);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
  background: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] input:focus {
  background: rgba(255, 255, 255, 0.1);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.menu-toggle {
  display: none; /* Hidden on desktop */
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.active {
    transform: translateX(0);
    width: 280px;
  }

  .sidebar-logo img {
    height: 75px; /* Reduced by 50% for mobile as requested */
    margin-bottom: 0;
  }

  /* Hide specific titles on mobile */
  .mobile-hide-title, 
  header h1 {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 24px 16px;
  }
  
  .menu-toggle {
    display: block;
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface);
    font-size: 24px;
    cursor: pointer;
    margin-right: 16px;
  }
}

/* Overlay for mobile */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 900;
  backdrop-filter: blur(4px);
}

.overlay.active {
  display: block;
}



/* Liquid Glass Cards & Modals */
.glass-card {
  background: var(--md-sys-color-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--border-radius-lg);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  padding: 2rem;
}

.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
}

.modal-content {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  margin: 5% auto;
  padding: 2.5rem;
  border: var(--glass-border);
  width: 100%;
  max-width: 500px;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  color: var(--md-sys-color-on-surface);
}

.modal-content h2 {
  color: var(--md-sys-color-primary);
  font-weight: 500;
  letter-spacing: -0.5px;
}

.form-group label {
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500 !important;
  font-size: 0.9rem !important;
  margin-bottom: 8px !important;
  display: block;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: rgba(255, 255, 255, 0.6) !important;
  border: 1px solid var(--md-sys-color-outline-variant) !important;
  border-radius: var(--border-radius-sm) !important;
  color: var(--md-sys-color-on-surface) !important;
  padding: 12px 16px !important;
  font-size: 1rem !important;
  transition: all 0.2s !important;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus {
  background: #fff !important;
  border-color: var(--md-sys-color-primary) !important;
  box-shadow: 0 0 0 4px var(--md-sys-color-primary-container) !important;
  outline: none !important;
}

/* ============================================================
   DARK MODE — Material Design 3 Dark Theme Tokens
   Activated via: document.documentElement.setAttribute('data-theme','dark')
   ============================================================ */
[data-theme="dark"] {
  --md-sys-color-primary: #ADC6FF;
  --md-sys-color-on-primary: #00315D;
  --md-sys-color-primary-container: #004785;
  --md-sys-color-on-primary-container: #D7E2FF;

  --md-sys-color-secondary: #BBC3D8;
  --md-sys-color-on-secondary: #252D40;
  --md-sys-color-secondary-container: #3B4457;
  --md-sys-color-on-secondary-container: #DAE2F9;

  --md-sys-color-surface: rgba(28, 28, 32, 0.9);
  --md-sys-color-on-surface: #E3E2E6;
  --md-sys-color-surface-variant: rgba(68, 71, 79, 0.6);
  --md-sys-color-on-surface-variant: #C4C6D0;

  --md-sys-color-outline: #8E9099;
  --md-sys-color-outline-variant: #44474F;

  --bg-color: #111114;
  --primary-color: #ADC6FF;
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] body {
  background-color: #111114;
}

[data-theme="dark"] .sidebar {
  background: rgba(20, 20, 25, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .card {
  background: rgba(28, 28, 32, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .modal-content {
  background: rgba(22, 22, 28, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #E3E2E6;
}

[data-theme="dark"] .modal-content h2 {
  color: #ADC6FF;
}

[data-theme="dark"] thead {
  background-color: rgba(173, 198, 255, 0.08);
}

[data-theme="dark"] table {
  color: #E3E2E6;
}

[data-theme="dark"] td {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] th {
  border-bottom-color: rgba(255, 255, 255, 0.07);
  color: #ADC6FF;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: #44474F !important;
  color: #E3E2E6 !important;
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: #ADC6FF !important;
  box-shadow: 0 0 0 4px rgba(173, 198, 255, 0.15) !important;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: rgba(255, 255, 255, 0.06);
  border-color: #44474F;
  color: #E3E2E6;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: #ADC6FF;
}

/* ============================================================
   LIGHT MODE — explicit defaults (already in :root but aliased)
   ============================================================ */
[data-theme="light"] {
  --md-sys-color-primary: #005CBB;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #D7E2FF;
  --md-sys-color-on-primary-container: #001A40;
  --md-sys-color-surface: rgba(255, 255, 255, 0.6);
  --md-sys-color-on-surface: #1B1B1F;
  --md-sys-color-surface-variant: rgba(225, 226, 236, 0.4);
  --md-sys-color-on-surface-variant: #44474F;
  --md-sys-color-outline-variant: #C4C6D0;
  --bg-color: #f8f9ff;
  --glass-border: 1px solid rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* Smooth theme transition on all elements */
*, *::before, *::after {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.15s ease;
}

/* ============================================================
   COMPACT UI SCALE
   The app was designed at 1:1 but reads better a notch smaller on a
   desktop screen — the same density you get by setting the browser to
   90%. This bakes that in so nobody has to change a browser setting:
   sidebar, content, tables, modals and dialogs all shrink together.

   Change --ui-scale to adjust the whole app (0.9 = 90%, 0.85 = tighter,
   1 = back to the original size). --ui-scale-inverse is its reciprocal and
   must be updated with it: 1/0.9 = 1.111111, 1/0.85 = 1.176471, 1/1 = 1.

   Deliberately limited to:
     - screen (print stays 1:1, so CR80 ID cards keep their exact size)
     - >= 769px (phones and small tablets keep full-size touch targets)
   ============================================================ */
:root {
  --ui-scale: 1;
  --ui-scale-inverse: 1;
}

@media screen and (min-width: 769px) {
  :root {
    --ui-scale: 0.9;
    --ui-scale-inverse: 1.111111;
  }

  html {
    zoom: var(--ui-scale);
  }

  /* Escape hatch for anything that must stay physically exact — the ID card
     preview is captured by html2canvas at CR-80 size, so it cancels the scale
     back out instead of exporting a 90% card. Apply to the capture target
     only; its children inherit the restored 1:1 scale. */
  .ui-scale-exempt {
    zoom: var(--ui-scale-inverse);
  }
}
