/* High-Density Swiss & Curated SaaS Themes */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;1,6..72,400&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-serif: 'Newsreader', serif;

  /* Theme 0: Swiss Minimal (Default Light) */
  --bg-app: #fcfcfd;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --border-subtle: #e4e4e7;
  --border-muted: #f4f4f5;
  --text-main: #09090b;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  --brand-accent: #0f172a;
}

/* Dark Mode Default Tokens */
html.dark {
  --bg-app: #090a0f;
  --bg-card: #12131a;
  --bg-subtle: #181924;
  --border-subtle: #27272a;
  --border-muted: #1e1f2b;
  --text-main: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --brand-accent: #38bdf8;
}

/* Theme 1: Savanna Emerald */
html[data-theme="emerald"] {
  --bg-app: #f2f9f5;
  --bg-card: #ffffff;
  --bg-subtle: #e6f4ed;
  --border-subtle: #cfe8dc;
  --text-main: #064e3b;
  --brand-accent: #059669;
}
html.dark[data-theme="emerald"] {
  --bg-app: #04100c;
  --bg-card: #081a14;
  --bg-subtle: #0d261e;
  --border-subtle: #133a2e;
  --text-main: #ecfdf5;
  --brand-accent: #10b981;
}

/* Theme 2: Warm Editorial Ivory */
html[data-theme="ivory"] {
  --bg-app: #faf6ef;
  --bg-card: #ffffff;
  --bg-subtle: #f2ebe0;
  --border-subtle: #e3d7c5;
  --text-main: #292524;
  --brand-accent: #c2410c;
}
html.dark[data-theme="ivory"] {
  --bg-app: #171412;
  --bg-card: #1f1b17;
  --bg-subtle: #29241f;
  --border-subtle: #3d352e;
  --text-main: #f5f5f4;
  --brand-accent: #ea580c;
}

/* Theme 3: Obsidian Cyber */
html[data-theme="obsidian"] {
  --bg-app: #f5f3ff;
  --bg-card: #ffffff;
  --bg-subtle: #ede9fe;
  --border-subtle: #ddd6fe;
  --text-main: #1e1b4b;
  --brand-accent: #7c3aed;
}
html.dark[data-theme="obsidian"] {
  --bg-app: #090714;
  --bg-card: #110d24;
  --bg-subtle: #191436;
  --border-subtle: #2b2254;
  --text-main: #f5f3ff;
  --brand-accent: #a855f7;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Responsive Theme & Dark Mode Surface Adaptors */
body.bg-slate-50,
.bg-slate-50 {
  background-color: var(--bg-app) !important;
}

.bg-white {
  background-color: var(--bg-card) !important;
  color: var(--text-main);
}

.bg-slate-100 {
  background-color: var(--bg-subtle) !important;
}

.border-slate-200, 
.border-slate-200\/80,
.border-slate-200\/90,
.border-slate-100 {
  border-color: var(--border-subtle) !important;
}

#sidebar,
header {
  background-color: var(--bg-card) !important;
  border-color: var(--border-subtle) !important;
}

html.dark .text-slate-800,
html.dark .text-slate-900 {
  color: #f4f4f5 !important;
}

html.dark .text-slate-600,
html.dark .text-slate-700 {
  color: #d4d4d8 !important;
}

html.dark .text-slate-500 {
  color: #a1a1aa !important;
}

html.dark .text-slate-400 {
  color: #71717a !important;
}

html.dark table thead {
  background-color: var(--bg-subtle) !important;
  color: #a1a1aa !important;
}

html.dark table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.04) !important;
}

html.dark input, 
html.dark select, 
html.dark textarea {
  background-color: var(--bg-card) !important;
  border-color: var(--border-subtle) !important;
  color: #f4f4f5 !important;
}

/* Tactile Button Press */
button:active:not(:disabled) {
  transform: scale(0.98);
}

/* Custom Minimal Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #71717a;
  border-radius: 4px;
}

/* Active Nav Link */
#sidebar {
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.sidebar-header {
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-card);
}

.nav-link {
  color: var(--text-secondary);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s ease;
}

.nav-link:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.nav-link.active {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  font-weight: 600;
}

.nav-link i, .nav-link svg {
  color: var(--text-muted);
}
.nav-link.active i, .nav-link.active svg {
  color: var(--brand-accent);
}

.nav-section-title {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 12px 12px 4px 12px;
}

/* Unified Flat KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background-color: var(--bg-card);
  overflow: hidden;
}

.kpi-cell {
  padding: 18px 20px;
  border-right: 1px solid var(--border-subtle);
}

.kpi-cell:last-child {
  border-right: none;
}

@media (max-width: 1024px) {
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi-cell:nth-child(2) {
    border-right: none;
  }
  .kpi-cell:nth-child(-n+2) {
    border-bottom: 1px solid var(--border-subtle);
  }
}

@media (max-width: 640px) {
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi-cell {
    padding: 12px 14px;
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
  }
  .kpi-cell:nth-child(2n) {
    border-right: none;
  }
  .kpi-cell:nth-child(3),
  .kpi-cell:nth-child(4) {
    border-bottom: none;
  }
}

/* Mobile Navigation & Bottom Sheet Styles */
.mobile-tab-btn {
  position: relative;
  transition: all 0.15s ease;
  min-height: 44px;
}

.mobile-tab-btn.active {
  color: var(--brand-accent) !important;
}

.mobile-tab-btn.active i,
.mobile-tab-btn.active svg {
  color: var(--brand-accent) !important;
  transform: translateY(-1px);
}

.mobile-tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 2px;
  background-color: transparent;
  border-radius: 2px;
  transition: background-color 0.2s ease;
}

.mobile-tab-btn.active::after {
  background-color: var(--brand-accent);
}

/* Prevent iOS Safari 16px Auto-Zoom on form input focus */
@media (max-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  }
  
  #toast-container {
    bottom: 74px !important;
    left: 16px;
    right: 16px;
  }
  
  .toast {
    width: 100%;
  }
}

/* Native-Like Touch Scrolling */
.touch-scroll {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Responsive Bottom Sheets for Modals on Mobile */
@media (max-width: 640px) {
  [id^="modal-"] {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  
  [id^="modal-"] > div {
    max-width: 100% !important;
    width: 100% !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 20px !important;
    border-top-right-radius: 20px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    padding: 20px 16px !important;
    padding-bottom: max(env(safe-area-inset-bottom), 24px) !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25) !important;
    animation: sheetSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
}

@keyframes sheetSlideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Hide scrollbars for clean mobile tab/chips */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Print Styles */
@media print {
  body * {
    visibility: hidden;
  }
  #printable-area, #printable-area * {
    visibility: visible;
  }
  #printable-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 24px;
    background: white;
    color: black;
  }
  .no-print {
    display: none !important;
  }
}
