/* GeniOCR — shared modern theme tokens (light / dark) + product font */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@600;700;800&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap");

:root,
html[data-theme="light"] {
  color-scheme: light;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-brand: "Outfit", "Inter", sans-serif;
  --font-doc: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  /* Modern Indigo & Amber accents */
  --brand-purple: #4f46e5;
  --brand-purple-deep: #4338ca;
  --brand-orange: #f97316;
  --brand-orange-hot: #fb923c;
  /* Clean modern canvas & surfaces */
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --text-muted: #64748b;
  --faint: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.08);
  --cta: #f97316;
  --cta-hover: #ea580c;
  --cta-soft: rgba(249, 115, 22, 0.12);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.1);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.1);
  --error: #ef4444;
  --error-soft: rgba(239, 68, 68, 0.1);
  --print: #0284c7;
  --print-soft: rgba(2, 132, 199, 0.12);
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --hover: rgba(15, 23, 42, 0.04);
  --active-soft: rgba(79, 70, 229, 0.1);
  --table-head: #f1f5f9;
  --table-head-text: #334155;
  --table-stripe: rgba(241, 245, 249, 0.5);
  --table-hover: rgba(79, 70, 229, 0.04);
  --paper: #f1f5f9;
  --paper-page: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --theme-toggle-bg: #e2e8f0;
  --theme-toggle-knob: #ffffff;
  --workspace: #f8fafc;
  --workspace-muted: #f1f5f9;
  /* UI spacing */
  --space-page: 16px;
  --space-panel: 14px;
  --gap-layout: 14px;
  --gap-stack: 8px;
  --header-page-mb: 10px;
  --title-page: 1.25rem;
  --control-h: 36px;
  --control-h-touch: 42px;
  --sidebar-width: 256px;
  --sidebar-width-collapsed: 64px;
  --nav-link-py: 7px;
  --table-cell-py: 6px;
  --table-cell-px: 8px;
  --chrome-offset-data: 185px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --font-brand: "Outfit", "Inter", sans-serif;
  --font-doc: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --brand-purple: #818cf8;
  --brand-purple-deep: #6366f1;
  --brand-orange: #fb923c;
  --brand-orange-hot: #fdba74;
  --bg: #0b0f17;
  --bg-elevated: #111827;
  --surface: #111827;
  --surface-2: #1e293b;
  --surface-3: #334155;
  --panel: #111827;
  --panel-2: #182234;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --text-muted: #94a3b8;
  --faint: #64748b;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.15);
  --cta: #fb923c;
  --cta-hover: #f97316;
  --cta-soft: rgba(251, 146, 60, 0.16);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.14);
  --print: #38bdf8;
  --print-soft: rgba(56, 189, 248, 0.16);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --input-bg: #0f172a;
  --input-border: #1e293b;
  --hover: rgba(255, 255, 255, 0.05);
  --active-soft: rgba(129, 140, 248, 0.2);
  --table-head: #1e293b;
  --table-head-text: #f1f5f9;
  --table-stripe: rgba(255, 255, 255, 0.02);
  --table-hover: rgba(129, 140, 248, 0.08);
  --paper: #111827;
  --paper-page: #0f172a;
  --radius: 12px;
  --radius-sm: 8px;
  --theme-toggle-bg: #1e293b;
  --theme-toggle-knob: #f8fafc;
  --workspace: #0b0f17;
  --workspace-muted: #111827;
}

html {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

@media (max-width: 960px) {
  html {
    font-size: 16px;
  }
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: var(--font);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Full-app shell follows theme */
#appShell,
.app-shell,
.app-main,
.view,
.app {
  background: var(--bg) !important;
  color: var(--text);
  min-height: 100%;
}

#appShell.app-shell,
.app-shell {
  min-height: 100dvh;
  width: 100%;
}

/* ── Theme switch control ── */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 3px;
  border-radius: 999px;
  background: var(--theme-toggle-bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.theme-switch-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  width: 34px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.theme-switch-btn:hover {
  color: var(--text);
}

.theme-switch-btn.active {
  background: var(--theme-toggle-knob);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.theme-switch-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-fab {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10050;
}

.theme-switch.compact .theme-switch-btn {
  width: 30px;
  height: 26px;
  font-size: 12px;
}

.sidebar.collapsed .theme-switch-label {
  display: none;
}

.sidebar-theme {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
}

.sidebar-theme-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.sidebar.collapsed .sidebar-theme-row {
  justify-content: center;
}

.sidebar.collapsed .sidebar-theme-label {
  display: none;
}

/* Login: branded atmosphere (independent of app light/dark lists) */
html[data-theme="light"] .login-screen,
html[data-theme="dark"] .login-screen {
  background: #12081c;
}

/* Elevated chrome only — list pages stay flush with workspace */
.sidebar,
.bottom-nav,
.project-bar,
.project-bar-wrap,
.mobile-scan-tabs,
.card,
.panel-card,
.modal-panel,
.modal-header,
.modal-footer,
.modal-body,
.toolbar,
.excel-toolbar,
.data-toolbar,
.admin-card,
.admin-section,
.cs-menu,
.cs-trigger,
.settings-controls {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.app-header,
.top-right-user-bar,
.top-user-card {
  background-color: transparent;
  color: var(--text);
  border-color: var(--border);
}

/* List / history / admin / help: no floating white panels */
.data-filters,
.bia-history-filters,
.bia-history-list,
.bia-history-shell,
.bia-history-group,
.data-result-shell,
.admin-table-shell,
.view-help .help-toc,
.view-help .help-section {
  background-color: transparent !important;
  box-shadow: none !important;
}

.sidebar {
  background-color: var(--panel-2) !important;
}

html[data-theme="light"] body,
html[data-theme="light"] #appShell,
html[data-theme="light"] .app-shell,
html[data-theme="light"] .app-main {
  background: var(--bg) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] body,
html[data-theme="dark"] #appShell,
html[data-theme="dark"] .app-shell,
html[data-theme="dark"] .app-main,
html[data-theme="dark"] .view,
html[data-theme="dark"] .app {
  background: var(--bg) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .bottom-nav {
  background: var(--panel) !important;
  border-color: var(--border) !important;
}

/* Keep printable paper white in both themes */
.page,
.xl-page,
.excel-sheet.layout-print,
.nhan-page {
  background: var(--paper-page) !important;
  color: #000 !important;
}
/* === APP TOAST (top-right) === */
.app-toast-container {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 28px));
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border, #cbd5e1);
  background: var(--surface, #ffffff);
  color: var(--text, #0f172a);
  box-shadow: 0 10px 28px -8px rgba(15, 23, 42, 0.28), 0 4px 10px -4px rgba(15, 23, 42, 0.12);
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.app-toast-show {
  opacity: 1;
  transform: translateX(0);
}

.app-toast.app-toast-hide {
  opacity: 0;
  transform: translateX(16px);
}

.app-toast-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  margin-top: 1px;
}

.app-toast-message {
  flex: 1 1 auto;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  padding-top: 1px;
}

.app-toast-close {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--muted, #64748b);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  margin: -2px 0 0;
}

.app-toast-close:hover {
  color: var(--text, #0f172a);
}

.app-toast-success {
  border-color: #86efac;
  background: #f0fdf4;
}

.app-toast-success .app-toast-icon {
  background: #16a34a;
  color: #fff;
}

.app-toast-info {
  border-color: #93c5fd;
  background: #eff6ff;
}

.app-toast-info .app-toast-icon {
  background: #2563eb;
  color: #fff;
}

.app-toast-warning {
  border-color: #fcd34d;
  background: #fffbeb;
}

.app-toast-warning .app-toast-icon {
  background: #d97706;
  color: #fff;
}

.app-toast-error {
  border-color: #fca5a5;
  background: #fef2f2;
}

.app-toast-error .app-toast-icon {
  background: #dc2626;
  color: #fff;
}

[data-theme="dark"] .app-toast,
html.theme-dark .app-toast {
  background: var(--surface, #1e293b);
  color: var(--text, #f1f5f9);
  border-color: var(--border, #334155);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .app-toast-success,
html.theme-dark .app-toast-success {
  background: #052e16;
  border-color: #166534;
}

[data-theme="dark"] .app-toast-info,
html.theme-dark .app-toast-info {
  background: #0c1a33;
  border-color: #1e40af;
}

[data-theme="dark"] .app-toast-warning,
html.theme-dark .app-toast-warning {
  background: #2a1a05;
  border-color: #92400e;
}

[data-theme="dark"] .app-toast-error,
html.theme-dark .app-toast-error {
  background: #2a0b0b;
  border-color: #991b1b;
}

[data-theme="dark"] .app-toast-close:hover,
html.theme-dark .app-toast-close:hover {
  color: var(--text, #f8fafc);
}
