/* ═══════════════════════════════════════════════════════════════════
   FutureTech v18 — Theme Override
   ───────────────────────────────────────────────────────────────────
   • Dark theme refined with logo brand colors (mint + navy)
   • New Light theme
   • Background image with theme-aware overlay
   • Smooth toggle without page reload
   ═══════════════════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════════════════════════════
   1) BACKGROUND IMAGE (applies to both themes)
   ═══════════════════════════════════════════════════════════════════ */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: url('/bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* overlay color set per theme below */
}


/* ═══════════════════════════════════════════════════════════════════
   2) DARK THEME (default — refined with brand mint #6FFFE8 + navy)
   ═══════════════════════════════════════════════════════════════════ */

:root,
html[data-theme="dark"],
body[data-theme="dark"] {
  /* Brand accent — mint from logo */
  --accent: #6FFFE8 !important;
  --accent-2: #4ee0c8 !important;
  --accent-3: #2bb8a0 !important;
  --accent-dim: rgba(111, 255, 232, 0.12) !important;
  --accent-glow: rgba(111, 255, 232, 0.22) !important;
  --accent-glow2: rgba(111, 255, 232, 0.06) !important;

  /* Backgrounds — slightly bluer navy tint to harmonize with logo */
  --bg: #070b14 !important;
  --bg-2: #0a1220 !important;
  --surface: #0d1626 !important;
  --surface-2: #121d30 !important;
  --surface-3: #18253c !important;
  --surface-4: #1f2e48 !important;
  --surface-hover: #243553 !important;

  /* Text — keep readable */
  --text: #eaf0fa !important;
  --text-2: #95a8c2 !important;
  --text-3: #546478 !important;
  --muted: #3e5468 !important;

  /* Borders — slightly brighter to maintain contrast on darker bg */
  --border: rgba(255, 255, 255, 0.07) !important;
  --border-2: rgba(111, 255, 232, 0.20) !important;
  --border-3: rgba(255, 255, 255, 0.13) !important;

  /* Shadows tinted with mint */
  --shadow-accent: 0 0 40px rgba(111, 255, 232, 0.14) !important;
}

/* Dark overlay on background image (heavy — bg barely visible) */
html[data-theme="dark"] body::after,
html:not([data-theme]) body::after,
body[data-theme="dark"]::after,
body:not([data-theme])::after {
  background:
    linear-gradient(135deg,
      rgba(7, 11, 20, 0.94) 0%,
      rgba(10, 18, 32, 0.96) 50%,
      rgba(7, 11, 20, 0.97) 100%);
}


/* ═══════════════════════════════════════════════════════════════════
   3) LIGHT THEME — new, derived from logo navy + bg.jpg office tones
   ═══════════════════════════════════════════════════════════════════ */

html[data-theme="light"],
html[data-theme="light"] body,
body[data-theme="light"] {
  /* Backgrounds — soft white/grey from office bg */
  --bg: #f5f7fa !important;
  --bg-2: #eef2f7 !important;
  --surface: #ffffff !important;
  --surface-2: #f8fafc !important;
  --surface-3: #f1f5f9 !important;
  --surface-4: #e8eef5 !important;
  --surface-hover: #e2e8f0 !important;

  /* Brand accent — navy primary, mint secondary */
  --accent: #3B506D !important;
  --accent-2: #2C3C4F !important;
  --accent-3: #1f2c3d !important;
  --accent-dim: rgba(59, 80, 109, 0.10) !important;
  --accent-glow: rgba(59, 80, 109, 0.18) !important;
  --accent-glow2: rgba(59, 80, 109, 0.05) !important;

  /* Text — dark for readability */
  --text: #1a2332 !important;
  --text-2: #4a5a70 !important;
  --text-3: #7a8a9e !important;
  --muted: #9aa8bc !important;

  /* Borders — visible on light bg */
  --border: rgba(59, 80, 109, 0.12) !important;
  --border-2: rgba(59, 80, 109, 0.22) !important;
  --border-3: rgba(59, 80, 109, 0.18) !important;

  /* Status colors — slightly darker for light bg contrast */
  --green: #10b981 !important;
  --green-dim: rgba(16, 185, 129, 0.12) !important;
  --red: #e11d48 !important;
  --red-dim: rgba(225, 29, 72, 0.10) !important;
  --yellow: #d97706 !important;
  --yellow-dim: rgba(217, 119, 6, 0.12) !important;
  --blue: #0284c7 !important;
  --blue-dim: rgba(2, 132, 199, 0.10) !important;
  --purple: #7c3aed !important;
  --purple-dim: rgba(124, 58, 237, 0.10) !important;

  /* Shadows — softer on light */
  --shadow: 0 8px 32px rgba(59, 80, 109, 0.10) !important;
  --shadow-sm: 0 2px 12px rgba(59, 80, 109, 0.08) !important;
  --shadow-accent: 0 0 32px rgba(59, 80, 109, 0.10) !important;
  --shadow-card: 0 2px 12px rgba(59, 80, 109, 0.06), 0 1px 0 rgba(0, 0, 0, 0.02) inset !important;
}

/* Light overlay — softer, lets bg show more */
html[data-theme="light"] body::after,
body[data-theme="light"]::after {
  background:
    linear-gradient(135deg,
      rgba(245, 247, 250, 0.88) 0%,
      rgba(238, 242, 247, 0.92) 50%,
      rgba(245, 247, 250, 0.94) 100%);
}


/* ═══════════════════════════════════════════════════════════════════
   4) LIGHT THEME — element-specific fixes
   (because the original CSS was hardcoded for dark in some places)
   ═══════════════════════════════════════════════════════════════════ */

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

/* Sidebar in light */
html[data-theme="light"] .sidebar,
body[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
  border-left: 1px solid var(--border) !important;
  color: var(--text) !important;
}
html[data-theme="light"] .sidebar a,
html[data-theme="light"] .sidebar .nav-item,
body[data-theme="light"] .sidebar a,
body[data-theme="light"] .sidebar .nav-item {
  color: var(--text-2) !important;
}
html[data-theme="light"] .sidebar a:hover,
html[data-theme="light"] .sidebar a.active,
html[data-theme="light"] .sidebar .nav-item:hover,
html[data-theme="light"] .sidebar .nav-item.active,
body[data-theme="light"] .sidebar a:hover,
body[data-theme="light"] .sidebar a.active {
  background: var(--accent-dim) !important;
  color: var(--accent) !important;
}

/* Topbar in light */
html[data-theme="light"] .topbar,
body[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text) !important;
}

/* Cards/surfaces */
html[data-theme="light"] .card,
html[data-theme="light"] .panel,
html[data-theme="light"] .modal-box,
body[data-theme="light"] .card,
body[data-theme="light"] .panel,
body[data-theme="light"] .modal-box {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-card) !important;
}

/* Tables */
html[data-theme="light"] table,
body[data-theme="light"] table {
  color: var(--text) !important;
}
html[data-theme="light"] thead,
html[data-theme="light"] th,
body[data-theme="light"] thead,
body[data-theme="light"] th {
  background: var(--surface-3) !important;
  color: var(--text-2) !important;
  border-bottom: 1px solid var(--border) !important;
}
html[data-theme="light"] td,
body[data-theme="light"] td {
  border-bottom: 1px solid var(--border) !important;
}
html[data-theme="light"] tbody tr:hover,
body[data-theme="light"] tbody tr:hover {
  background: var(--surface-2) !important;
}

/* Inputs */
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea,
body[data-theme="light"] input,
body[data-theme="light"] select,
body[data-theme="light"] textarea {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-3) !important;
}
html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus,
body[data-theme="light"] input:focus,
body[data-theme="light"] select:focus,
body[data-theme="light"] textarea:focus {
  border-color: var(--accent) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px var(--accent-dim) !important;
}
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder,
body[data-theme="light"] input::placeholder,
body[data-theme="light"] textarea::placeholder {
  color: var(--text-3) !important;
}

/* Buttons */
html[data-theme="light"] button,
body[data-theme="light"] button {
  color: inherit;
}
html[data-theme="light"] .btn-primary,
body[data-theme="light"] .btn-primary {
  background: var(--accent) !important;
  color: #ffffff !important;
  border: 1px solid var(--accent) !important;
}
html[data-theme="light"] .btn-primary:hover,
body[data-theme="light"] .btn-primary:hover {
  background: var(--accent-2) !important;
  border-color: var(--accent-2) !important;
}

/* Mobile hamburger button (defined inline in HTML) */
html[data-theme="light"] .mob-menu-btn,
body[data-theme="light"] .mob-menu-btn {
  background: rgba(59, 80, 109, 0.05) !important;
  border-color: rgba(59, 80, 109, 0.15) !important;
  color: var(--accent) !important;
}

/* Sidebar overlay (mobile) — keep dark in both themes for contrast */
.sidebar-overlay {
  background: rgba(0, 0, 0, 0.5) !important;
}

/* Skeleton loaders in light */
html[data-theme="light"] .skeleton-row,
body[data-theme="light"] .skeleton-row {
  background: linear-gradient(90deg,
    rgba(59, 80, 109, 0.04) 25%,
    rgba(59, 80, 109, 0.08) 50%,
    rgba(59, 80, 109, 0.04) 75%) !important;
  background-size: 200% 100% !important;
}

/* Scrollbar in light */
html[data-theme="light"] ::-webkit-scrollbar,
body[data-theme="light"] ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html[data-theme="light"] ::-webkit-scrollbar-track,
body[data-theme="light"] ::-webkit-scrollbar-track {
  background: var(--surface-2);
}
html[data-theme="light"] ::-webkit-scrollbar-thumb,
body[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 5px;
}
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover,
body[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}


/* ═══════════════════════════════════════════════════════════════════
   5) THEME TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════════════ */

.theme-toggle-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-3);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin: 0 4px;
}

.theme-toggle-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.theme-toggle-btn:active {
  transform: translateY(0);
}


/* ═══════════════════════════════════════════════════════════════════
   6) SMOOTH TRANSITIONS BETWEEN THEMES
   ═══════════════════════════════════════════════════════════════════ */

html, body, .sidebar, .topbar, .card, .panel, .modal-box,
input, select, textarea, button, table, th, td {
  transition:
    background-color 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease;
}

body::after {
  transition: background 0.4s ease;
}


/* ═══════════════════════════════════════════════════════════════════
   7) PRESERVE COMPATIBILITY WITH EXISTING THEME CLASSES
   (theme-blue/purple/red/amber/green still work — they just override accent)
   ═══════════════════════════════════════════════════════════════════ */

/* These existing classes only set --accent, so they work on top of dark/light */


/* ═══════════════════════════════════════════════════════════════════
   8) PRINT STYLES (don't show bg image when printing invoices)
   ═══════════════════════════════════════════════════════════════════ */

@media print {
  body::before, body::after {
    display: none !important;
  }
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
  }
}
