/* ============================================================
   MedLumen — Unified Medical Image Diagnostics with Explainable AI
   Custom theme layered on Bootstrap 5.3 (data-bs-theme aware)
   ============================================================ */

:root {
  /* Brand */
  --brand:        #2563EB;
  --brand-600:    #1D4ED8;
  --brand-700:    #1E40AF;
  --brand-soft:   #EFF4FF;
  --accent:       #06B6D4;   /* explainability cyan */
  --accent-soft:  #ECFEFF;

  /* Neutrals (light) */
  --bg:           #F6F8FB;
  --surface:      #FFFFFF;
  --surface-2:    #F8FAFC;
  --line:         #E6EAF0;
  --ink:          #0F172A;
  --muted:        #64748B;
  --faint:        #94A3B8;

  /* Status */
  --ok:    #16A34A;  --ok-soft:   #E9F8EF;
  --warn:  #F59E0B;  --warn-soft: #FEF6E7;
  --bad:   #DC2626;  --bad-soft:  #FDECEC;

  /* Shape & motion */
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow:    0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 18px 40px -12px rgba(15,23,42,.18);
  --ease: cubic-bezier(.4,0,.2,1);

  /* Bootstrap overrides */
  --bs-primary: var(--brand);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-body-font-family: 'Inter', system-ui, sans-serif;
  --bs-border-color: var(--line);
}

[data-bs-theme="dark"] {
  --bg:        #0B1120;
  --surface:   #111827;
  --surface-2: #0E1525;
  --line:      #1F2A3C;
  --ink:       #F1F5F9;
  --muted:     #94A3B8;
  --faint:     #64748B;
  --brand-soft:#162544;
  --accent-soft:#0C2230;
  --ok-soft:   #0E2A1B; --warn-soft: #2A2210; --bad-soft: #2C1717;
  --shadow-lg: 0 18px 40px -12px rgba(0,0,0,.6);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
}

/* ---------- Base ---------- */
* { -webkit-font-smoothing: antialiased; }
body { background: var(--bg); color: var(--ink); font-family: var(--bs-body-font-family);
  letter-spacing: -.005em; }
h1,h2,h3,h4,h5,.display-font { font-family: 'Space Grotesk', 'Inter', sans-serif; letter-spacing: -.02em; font-weight: 600; }
.text-muted-2 { color: var(--muted) !important; }
.text-faint { color: var(--faint) !important; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-700); }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* gradient text + the signature heatmap gradient */
.grad-text { background: linear-gradient(100deg, var(--brand), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.jet-bar { height: 6px; border-radius: 999px;
  background: linear-gradient(90deg,#1d4ed8,#06b6d4,#22c55e,#eab308,#ef4444); }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--r-sm); font-weight: 500; padding: .55rem 1rem; transition: all .15s var(--ease); }
.btn-lg { padding: .8rem 1.4rem; border-radius: var(--r); }
.btn-sm { padding: .36rem .7rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); box-shadow: 0 1px 2px rgba(37,99,235,.3); }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); transform: translateY(-1px); }
.btn-soft { background: var(--brand-soft); color: var(--brand-700); border: 1px solid transparent; }
.btn-soft:hover { background: #e2ebff; color: var(--brand-700); }
.btn-light { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.btn-light:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-outline-light { border-color: var(--line); color: var(--ink); }

/* ---------- Cards & surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.5rem; }
.soft-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.divider { height: 1px; background: var(--line); border: 0; }

/* ---------- Badges / chips ---------- */
.chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 500;
  padding: .3rem .7rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted); }
.badge-soft { font-weight: 600; padding: .35em .7em; border-radius: 999px; font-size: .74rem; }
.badge-ok   { background: var(--ok-soft);   color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad  { background: var(--bad-soft);  color: var(--bad); }
.badge-info { background: var(--brand-soft); color: var(--brand-700); }

/* ---------- Forms ---------- */
.form-control, .form-select { border-radius: var(--r-sm); border-color: var(--line);
  background: var(--surface); color: var(--ink); padding: .6rem .85rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: .35rem; color: var(--ink); }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--faint); }
.input-icon .form-control { padding-left: 2.4rem; }

/* ============================================================
   Marketing
   ============================================================ */
.site-nav { background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1030; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; box-shadow: var(--shadow-sm); }
.brand-name { font-family: 'Space Grotesk'; font-weight: 600; letter-spacing: -.02em; font-size: 1.08rem; color: var(--ink); }

.hero { padding: clamp(3rem, 7vw, 6rem) 0 clamp(2rem,4vw,3.5rem); }
.eyebrow { display:inline-flex; align-items:center; gap:.5rem; font-size:.8rem; font-weight:600;
  letter-spacing:.02em; color: var(--brand-700); background: var(--brand-soft);
  padding:.4rem .8rem; border-radius:999px; }
.hero h1 { font-size: clamp(2.3rem, 5vw, 3.6rem); line-height: 1.05; }
.hero .lead { color: var(--muted); font-size: 1.12rem; max-width: 33ch; }

.scan-demo { border-radius: var(--r-xl); border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow-lg); overflow: hidden; }
.scan-demo .bar { display:flex; gap:6px; padding:12px 14px; border-bottom:1px solid var(--line); }
.scan-demo .bar i { width:10px; height:10px; border-radius:50%; background: var(--line); }
.scan-canvas-wrap { position: relative; aspect-ratio: 1/1; background:#0b1120; }
.scan-canvas-wrap canvas { position:absolute; inset:0; width:100%; height:100%; }

.section { padding: clamp(3rem, 6vw, 5rem) 0; }
.feature-ico { width: 44px; height: 44px; border-radius: 12px; display:grid; place-items:center;
  background: var(--brand-soft); color: var(--brand); font-size: 1.25rem; }
.feature-card { height:100%; transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.price-card.popular { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.price-amt { font-family:'Space Grotesk'; font-size: 2.4rem; font-weight: 600; }

.cta-band { background: linear-gradient(120deg, var(--brand-700), var(--brand) 55%, var(--accent));
  border-radius: var(--r-xl); color:#fff; padding: clamp(2rem,5vw,3.5rem); }

.site-foot { border-top:1px solid var(--line); background: var(--surface); }
.site-foot a { color: var(--muted); } .site-foot a:hover { color: var(--ink); }

/* ============================================================
   Auth
   ============================================================ */
.auth-split { min-height: 100vh; }
.auth-aside { background:
  radial-gradient(1200px 500px at -10% -10%, rgba(6,182,212,.20), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(37,99,235,.28), transparent 55%),
  linear-gradient(160deg, #0b1120, #111c34);
  color:#fff; position: relative; overflow: hidden; }
.auth-aside .quote { font-family:'Space Grotesk'; font-size:1.5rem; line-height:1.4; font-weight:500; }
.auth-card { max-width: 420px; width:100%; }

/* ============================================================
   App shell
   ============================================================ */
.app-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; display:flex; flex-direction:column; }
.sidebar-head { padding: 1.1rem 1.2rem; }
.side-nav { padding: .4rem .7rem; overflow-y:auto; flex:1; }
.side-label { font-size:.7rem; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
  color: var(--faint); padding: 1rem .8rem .35rem; }
.side-link { display:flex; align-items:center; gap:.75rem; padding:.6rem .75rem; border-radius:var(--r-sm);
  color: var(--muted); font-weight:500; font-size:.92rem; margin-bottom:2px; transition: all .12s var(--ease); }
.side-link i { font-size: 1.1rem; width: 1.25rem; text-align:center; }
.side-link:hover { background: var(--surface-2); color: var(--ink); }
.side-link.active { background: var(--brand-soft); color: var(--brand-700); font-weight:600; }
.side-foot { padding:.8rem; border-top:1px solid var(--line); }
.userchip { display:flex; align-items:center; gap:.6rem; padding:.5rem; border-radius:var(--r-sm); cursor:pointer; }
.userchip:hover { background: var(--surface-2); }
.avatar { width:36px; height:36px; border-radius:50%; display:grid; place-items:center; flex:none;
  background: linear-gradient(135deg, var(--brand), var(--accent)); color:#fff; font-weight:600; font-size:.85rem; }

.topbar { height:64px; display:flex; align-items:center; gap:1rem; padding:0 1.5rem;
  border-bottom:1px solid var(--line); background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(150%) blur(8px); position: sticky; top:0; z-index: 20; }
.topbar .search { flex:1; max-width: 440px; }
.content { padding: 1.6rem; max-width: 1320px; margin: 0 auto; width:100%; }
.page-title { font-size: 1.6rem; }
.icon-btn { width:40px; height:40px; border-radius:var(--r-sm); border:1px solid var(--line);
  background: var(--surface); color: var(--muted); display:grid; place-items:center; cursor:pointer;
  transition: all .12s var(--ease); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* Stat cards */
.stat { padding: 1.25rem; }
.stat .ico { width:40px; height:40px; border-radius:10px; display:grid; place-items:center;
  background: var(--brand-soft); color: var(--brand); font-size:1.2rem; }
.stat .val { font-family:'Space Grotesk'; font-size: 1.9rem; font-weight:600; line-height:1; }
.stat .lbl { color: var(--muted); font-size:.86rem; }
.trend-up { color: var(--ok); font-weight:600; font-size:.8rem; }

/* Tables */
.table-clean { --bs-table-bg: transparent; margin:0; }
.table-clean thead th { font-size:.72rem; text-transform:uppercase; letter-spacing:.05em;
  color: var(--faint); font-weight:600; border-bottom:1px solid var(--line); padding:.7rem 1rem; }
.table-clean td { padding: .85rem 1rem; border-bottom:1px solid var(--line); vertical-align: middle; color: var(--ink); }
.table-clean tbody tr:last-child td { border-bottom:0; }
.table-clean tbody tr { transition: background .12s var(--ease); }
.table-clean tbody tr:hover { background: var(--surface-2); }

/* Meter / progress */
.meter { height:8px; border-radius:999px; background: var(--surface-2); overflow:hidden; }
.meter > span { display:block; height:100%; border-radius:999px;
  background: linear-gradient(90deg, var(--brand), var(--accent)); }

/* Dropzone */
.dropzone { border:2px dashed var(--line); border-radius: var(--r-lg); padding: 2.4rem 1.5rem;
  text-align:center; cursor:pointer; transition: all .15s var(--ease); background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .dz-ico { width:54px; height:54px; border-radius:14px; margin:0 auto .8rem; display:grid;
  place-items:center; background: var(--surface); border:1px solid var(--line); color: var(--brand); font-size:1.5rem; }

/* Explainability viewer (signature) */
.viewer { position: relative; border-radius: var(--r-lg); overflow:hidden; background:#0b1120; aspect-ratio: 1/1; }
.viewer img, .viewer canvas { position:absolute; inset:0; width:100%; height:100%; object-fit: contain; }
.viewer .heat { mix-blend-mode: screen; transition: opacity .12s linear; }
.viewer-empty { position:absolute; inset:0; display:grid; place-items:center; color: var(--faint);
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 12px, var(--surface) 12px, var(--surface) 24px); }
.legend-jet { display:flex; align-items:center; gap:.5rem; font-size:.72rem; color: var(--muted); }
.legend-jet .bar { flex:1; height:6px; border-radius:999px;
  background: linear-gradient(90deg,#1d4ed8,#06b6d4,#22c55e,#eab308,#ef4444); }

/* Empty states */
.empty { text-align:center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .e-ico { width:56px; height:56px; border-radius:16px; margin:0 auto 1rem; display:grid;
  place-items:center; background: var(--surface-2); color: var(--faint); font-size:1.5rem; }

/* Loading overlay for analysis */
.analyzing { display:flex; flex-direction:column; align-items:center; gap:1rem; padding:2rem; }
.scan-line { position:relative; width:100%; height:4px; background: var(--surface-2); border-radius:999px; overflow:hidden; }
.scan-line::after { content:''; position:absolute; left:-40%; top:0; height:100%; width:40%;
  background: linear-gradient(90deg, transparent, var(--brand), var(--accent), transparent); animation: scan 1.1s var(--ease) infinite; }
@keyframes scan { to { left:110%; } }
.spin-ring { width:46px; height:46px; border-radius:50%; border:3px solid var(--brand-soft);
  border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast-host { position: fixed; right: 1rem; bottom: 1rem; z-index: 2000; display:flex; flex-direction:column; gap:.6rem; }
.toast-item { background: var(--surface); border:1px solid var(--line); border-left:4px solid var(--brand);
  border-radius: var(--r-sm); padding: .8rem 1rem; box-shadow: var(--shadow-lg); min-width: 260px;
  animation: toastin .25s var(--ease); }
.toast-item.ok { border-left-color: var(--ok); } .toast-item.bad { border-left-color: var(--bad); }
@keyframes toastin { from { opacity:0; transform: translateY(8px); } }

/* Mobile */
.menu-btn { display:none; }
.scrim { position: fixed; inset:0; background: rgba(15,23,42,.45); z-index: 49; opacity:0; pointer-events:none; transition: opacity .2s; }
@media (max-width: 992px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left:0; top:0; width:264px; z-index:50; transform: translateX(-100%); transition: transform .22s var(--ease); }
  .app-shell.nav-open .sidebar { transform: none; }
  .app-shell.nav-open .scrim { opacity:1; pointer-events:auto; }
  .menu-btn { display:grid; }
}
@media (max-width: 575px) { .content { padding: 1rem; } .topbar .search { display:none; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
