/* ==========================================================================
   Global UI Styles — Light/Dark, Responsive, Professional Palette
   Author: ChatGPT UI Refresh Pack (2025-08-17)
   How to use:
   - Link this file as /assets/css/style.css
   - Header adds/removes .dark on <html> (persisted via localStorage)
   -------------------------------------------------------------------------- */

/* 1) CSS Variables (Light/Dark) */
:root{
  --bg: #0b1020;            /* used behind translucent cards for dark */
  --surface: #ffffff;
  --surface-2:#f4f6fb;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;

  --primary:#2563eb;
  --primary-600:#1e51c4;
  --primary-700:#173e9c;

  --good:#10b981;
  --warn:#f59e0b;
  --bad:#ef4444;
  --info:#06b6d4;

  --radius:14px;
  --shadow:0 10px 28px rgba(2,6,23,.10);
}

html.dark{
  --surface:#0b1220;
  --surface-2:#0e1628;
  --text:#e5eaf5;
  --muted:#93a0b8;
  --border:#1e293b;
  --shadow:0 10px 28px rgba(0,0,0,.4);
}

/* Respect OS preference on first load */
@media (prefers-color-scheme: dark){
  :root{
    color-scheme: dark;
  }
}

/* 2) Base / Reset */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:linear-gradient(180deg, var(--surface-2), var(--surface));
  line-height:1.5;
}
a{color:var(--primary); text-decoration:none}
a:hover{text-decoration:underline}
img{max-width:100%; display:block}
hr{border:none; border-top:1px solid var(--border); margin:24px 0}

/* 3) Layout helpers */
.container{
  width:100%;
  max-width:1200px;
  margin-inline:auto;
  padding: 16px;
}
.wrap{padding: 16px}
.grid{
  display:grid;
  gap:16px;
}
@media (min-width:768px){
  .grid-2{grid-template-columns:1fr 1fr}
  .grid-3{grid-template-columns:repeat(3,1fr)}
  .grid-4{grid-template-columns:repeat(4,1fr)}
}

/* 4) Topbar / Header */
.topbar{
  position:sticky; top:0; z-index:50;
  background: var(--surface);
  border-bottom:1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: saturate(180%) blur(6px);
}
.topbar-inner{
  display:flex; align-items:center; gap:12px;
  padding:10px 16px;
}
.brand{
  display:flex; align-items:center; gap:10px; font-weight:700;
  font-size:1.1rem;
}
.brand .logo{
  /*width:32px; height:32px; */
  border-radius:10px;
  background:linear-gradient(135deg, var(--primary), var(--info));
  display:inline-block;
}
.topnav{
  margin-left:auto;
  display:flex; align-items:center; gap:6px;
}
.navlink{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius:10px; color:var(--text);
}
.navlink:hover{background:var(--surface-2); text-decoration:none}
.theme-toggle{
  display:inline-flex; align-items:center; justify-content:center;
  width:38px; height:38px; border-radius:10px;
  border:1px solid var(--border); background:transparent; cursor:pointer;
}
.theme-toggle:hover{background:var(--surface-2)}

/* 5) Footer */
.footer{
  margin-top: 32px;
  border-top:1px solid var(--border);
  background: var(--surface);
}
.footer-inner{
  padding:18px 16px;
  display:flex; gap:12px; flex-wrap:wrap; align-items:center;
  color:var(--muted); font-size:.9rem;
}

/* 6) Cards */
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header{padding:14px 16px; border-bottom:1px solid var(--border); font-weight:600}
.card-content{padding:16px}

/* 7) Buttons */
.btn{
  display:inline-flex; align-items:center; gap:8px;
  border-radius:12px; border:1px solid transparent;
  padding:10px 14px; font-weight:600; cursor:pointer;
  transition:.2s ease;
}
.btn:disabled{opacity:.6; cursor:not-allowed}
.btn-primary{background:var(--primary); color:#fff}
.btn-primary:hover{background:var(--primary-600)}
.btn-outline{background:transparent; border-color:var(--border); color:var(--text)}
.btn-outline:hover{background:var(--surface-2)}

/* 8) Forms */
.input, select, textarea{
  width:100%; padding:10px 12px; border-radius:10px;
  border:1px solid var(--border); background:var(--surface);
  color:var(--text);
}
.input:focus, select:focus, textarea:focus{outline:2px solid var(--primary); outline-offset:2px}
.form-row{display:grid; gap:12px}
@media (min-width:768px){ .form-row-2{grid-template-columns:1fr 1fr}}

/* 9) Tables (scrollable on mobile) */
.table-wrap{width:100%; overflow:auto; border:1px solid var(--border); border-radius:12px}
.table{
  width:100%; border-collapse:separate; border-spacing:0; min-width:760px;
}
.table thead th{
  text-align:left; font-size:.9rem; color:var(--muted);
  background:var(--surface-2); position:sticky; top:0; z-index:1;
}
.table th, .table td{padding:12px 14px; border-bottom:1px solid var(--border)}
.table tbody tr:hover{background:rgba(2,6,23,.03)}
.badge{display:inline-block; padding:4px 8px; border-radius:999px; font-size:.8rem}
.badge.good{background: color-mix(in oklab, var(--good) 20%, transparent); color:var(--good); border:1px solid var(--good)}
.badge.warn{background: color-mix(in oklab, var(--warn) 20%, transparent); color:var(--warn); border:1px solid var(--warn)}
.badge.bad{background: color-mix(in oklab, var(--bad) 20%, transparent); color:var(--bad); border:1px solid var(--bad)}

/* 10) Utilities */
.hidden{display:none !important}
.center{display:flex; align-items:center; justify-content:center}
.right{margin-left:auto}
.mt-2{margin-top:8px} .mt-3{margin-top:12px} .mt-4{margin-top:16px} .mt-6{margin-top:24px}
.mb-2{margin-bottom:8px} .mb-3{margin-bottom:12px} .mb-4{margin-bottom:16px} .mb-6{margin-bottom:24px}
.p-2{padding:8px} .p-3{padding:12px} .p-4{padding:16px} .p-6{padding:24px}

/* 11) Alerts */
.alert{border:1px solid var(--border); border-radius:12px; padding:12px 14px; background:var(--surface)}
.alert.info{border-color: color-mix(in oklab, var(--info) 40%, var(--border));}
.alert.warn{border-color: color-mix(in oklab, var(--warn) 40%, var(--border));}
.alert.bad{border-color: color-mix(in oklab, var(--bad) 40%, var(--border));}

/* 12) Responsive tweaks */
@media (max-width: 480px){
  .topbar-inner{padding:8px 12px}
  .navlabel{display:none}
  .brand{font-size:1rem}
  .card-content{padding:12px}
}

/* 13) Print-friendly */
@media print{
  .topbar, .footer{display:none !important}
  body{background:#fff}
  .card{box-shadow:none}
}

/* === Header add-ons (for your custom elements) ============================ */
.topbar { display: block; }
.topbar-inner { display:flex; align-items:center; gap:12px; padding:10px 16px; }

.back-btn{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius:10px;
  border:1px solid var(--border); background:transparent; color:var(--text);
  cursor:pointer;
}
.back-btn:hover{ background: var(--surface-2); }
.back-label{ display:inline; }
@media (max-width: 520px){ .back-label{ display:none; } }

.topbar .brand{ margin-left:8px; display:flex; align-items:center; }
.topbar .topnav{ margin-left:auto; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }

.topbar nav a.navlink,
.topbar nav a{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius:10px; color:var(--text); text-decoration:none;
}
.topbar nav a.navlink:hover,
.topbar nav a:hover{ background: var(--surface-2); text-decoration:none; }

.user-pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 10px; border-radius:999px; font-size:.9rem;
  color: var(--text);
  border:1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
}

/* Dropdown (uses your markup) */
.mode-dropdown{ position:relative; display:inline-block; }
.mode-dropdown-btn{
  background:transparent; border:1px solid var(--border);
  color:var(--text); font-size: .9rem; cursor:pointer;
  padding:8px 12px; border-radius:10px; display:flex; align-items:center; gap:6px;
}
.mode-dropdown-btn:hover{ background: var(--surface-2); }

.mode-dropdown-content{
  display:none; position:absolute; right:0; top:calc(100% + 8px);
  background: var(--surface); border:1px solid var(--border);
  border-radius:10px; min-width: 220px; z-index: 60; box-shadow: var(--shadow);
  overflow:hidden;
}
.mode-dropdown-content a{
  display:flex; align-items:center; gap:8px;
  color:var(--text); padding:10px 12px; text-decoration:none; font-size:.92rem;
}
.mode-dropdown-content a:hover{ background: var(--surface-2); }
.mode-dropdown-content .current-mode{
  font-weight:700; color: var(--primary);
}

/* Mobile nav wrapping */
@media (max-width: 768px){
  .topbar-inner{ gap:8px; flex-wrap: wrap; }
  .topbar .topnav{ gap:4px; flex-wrap: nowrap !important;}
  .mode-dropdown-content{ position:fixed; right:16px; left:16px; top:auto; bottom:16px; }
}

/* Optional: subtle background animation container (if you use it) */
.background-animation{ position:fixed; inset:0; pointer-events:none; opacity:.06; }

/* === Palette refinement for better contrast in both modes ================= */

/* Light mode fine-tune */
:root{
  --surface: #ffffff;
  --surface-2:#f3f5fb;
  --text:#0e172a;
  --muted:#5f6b86;
  --border:#dfe6f0;
  --primary:#2563eb;    /* Primary accent (Indigo/Blue) */
  --info:#0ea5e9;
}

/* Dark mode fine-tune */
html.dark{
  --surface:#0c1323;
  --surface-2:#0f1830;
  --text:#e6ecfb;
  --muted:#9aacc6;
  --border:#1e2a44;
  --primary:#60a5fa;    /* Brighter blue in dark mode for legibility */
  --info:#38bdf8;
}


/* ===== Footer (keeps your content, improves layout + responsiveness) ===== */
.footer{
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer .footer-content{
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer .footer-left{
  color: var(--muted);
  font-size: .95rem;
}

.footer .footer-right{
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer .it-logo{
  height: 36px;
  width: auto;
  object-fit: contain;
  display: block;
  filter: none; /* keep original colors; remove/adjust if you want grayscale in light mode */
}

/* Dark-mode logo hint (optional): lighten GIF slightly if needed) */
/* html.dark .footer .it-logo { filter: brightness(1.05) contrast(1.05); } */

/* Mobile stacking */
@media (max-width: 640px){
  .footer .footer-content{
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
  .footer .it-logo{
    height: 30px;
    margin-top: 4px;
  }
}

/* Subtle top separator glow (looks nice on modern screens) */
.footer::before{
  content:"";
  display:block;
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    color-mix(in oklab, var(--border) 70%, transparent) 15%,
    color-mix(in oklab, var(--border) 70%, transparent) 85%,
    transparent 100%);
}
/* Ensure header wraps neatly on small screens */
.topbar-inner{ display:flex; align-items:center; gap:12px; padding:10px 16px; }
.topbar .topnav{ margin-left:auto; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
@media (max-width: 768px){
  .topbar-inner{ gap:8px; flex-wrap: wrap; }
  .topbar .topnav{ gap:4px; }
  .navlabel{ display:none; } /* hide text labels beside icons on narrow screens */
}

/* Logo sizing (remove inline width on the <img>) */
.logo{ height: 40px; width: auto; object-fit: contain; }

/* Theme toggle (reuses your .theme-toggle style if present) */
.theme-toggle{
  display:inline-flex; align-items:center; justify-content:center;
  width:38px; height:38px; border-radius:10px;
  border:1px solid var(--border); background:transparent; cursor:pointer;
}
.theme-toggle:hover{ background: var(--surface-2); }


    /* Dashboard Styles */
.dashboard-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 8px;
  background: rgba(79, 70, 229, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1.25rem;
  flex-shrink: 0;
}

.stat-icon i {
  font-size: 1.5rem;
  color: var(--pri);
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--muted);
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 0.5rem;
}

/* Chart Section */
.chart-section {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.period-selector {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  color: var(--text);
  font-size: 0.875rem;
}

.chart-container {
  height: 300px;
  position: relative;
}

/* Quick Links Section */
.quick-links-section {
  margin-bottom: 2rem;
}

.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

.quick-link {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text);
  aspect-ratio: 1/1;
  border: 1px solid;
}

.quick-link:hover {
  background: rgba(79, 70, 229, 0.1);
  border-color: var(--pri);
  transform: translateY(-3px);
  background: #b1cefa;
}

.quick-link-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  background: rgba(79, 70, 229, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.quick-link-icon i {
  font-size: 5rem;
  color: var(--pri);
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
  .quick-links-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (max-width: 768px) {
  .dashboard-container {
    padding: 1.5rem;
  }
  
  .stats-row {
    grid-template-columns: 1fr;
  }
  
  .quick-links-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  
  .chart-container {
    height: 250px;
  }
}

@media (max-width: 480px) {
  .quick-links-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-card {
    padding: 1.25rem;
  }
  
  .quick-link {
    padding: 1.25rem;
  }
}