/* Inside Imaging - dark mint theme with enhanced visuals */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #050505;
  --panel: #0d0d0d;
  --panel-2: #141414;
  --text: #f2f6f4;
  --muted: #8a8f95;
  --border: #1c1c1c;
  --mint: #3ee6b0;
  --mint-soft: rgba(62, 230, 176, 0.14);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
  --nav-glow: 0 20px 40px rgba(0, 0, 0, 0.5);

  /* layout and background pads */
  --wrap-top: 12px;
  --bgpad-top: 2vh;
  --bgpad-sides: 22vw;
  --bgpad-bottom: 18vh;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font: 16px/1.55 'Montserrat', system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: transparent;
  /* gradients move to ::before */
  position: relative;
}

/* Oversized “background box” that tracks the user */
body::before {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  top: calc(-1 * var(--bgpad-top));
  right: calc(-1 * var(--bgpad-sides));
  bottom: calc(-1 * var(--bgpad-bottom));
  left: calc(-1 * var(--bgpad-sides));
  background: var(--bg);
}

.wrap {
  max-width: 980px;
  margin: var(--wrap-top) auto 40px;
  padding: 24px;
  animation: fadeIn 1s ease-out;
}

h1 {
  margin: 0 0 12px 0;
  font-weight: 700;
  letter-spacing: .2px;
}

h2 {
  margin: 28px 0 8px 0;
  font-size: 1.05rem;
  color: var(--muted);
  font-weight: 600;
}

textarea,
input,
button,
pre {
  font: inherit;
}

textarea {
  width: 100%;
  min-height: 160px;
  padding: 14px 16px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  caret-color: var(--mint);
  transition: border .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--mint) 35%, transparent);
}

button {
  width: 100%;
  margin: 10px 0 0 0;
  padding: 12px 16px;
  border: 1px solid color-mix(in oklab, var(--mint) 28%, var(--border));
  border-radius: 14px;
  background: var(--mint);
  color: #051e14;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}

button:hover {
  background: color-mix(in oklab, var(--mint) 85%, #ffffff);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

/* Light mode button fix */
.light button {
  background: var(--mint);
  color: #000000;
  font-weight: 700;
  border: 1px solid color-mix(in oklab, var(--mint) 50%, #000000);
}

.light button:hover {
  background: color-mix(in oklab, var(--mint) 75%, #000000);
  box-shadow: 0 14px 34px rgba(34, 197, 94, 0.4);
}

input[type="file"] {
  display: block;
  width: 100%;
  padding: 14px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 8px 0;
}

pre {
  width: 100%;
  padding: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
  min-height: 120px;
}

details {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

details[open] {
  background: var(--panel-2);
}

summary {
  cursor: pointer;
  padding: 10px 14px;
  color: var(--muted);
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

::selection {
  background: color-mix(in oklab, var(--mint) 35%, #ffffff10);
}

a {
  color: var(--mint);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Patient header box */
.patient-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--mint);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 10px 0 20px 0;
  box-shadow: var(--shadow);
}

.patient-card .lbl {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 2px;
}

/* Status line */
.status {
  min-height: 20px;
  margin: 4px 0 10px 0;
  color: var(--mint);
  font-weight: 600;
}

/* Report sections */
.report section {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 10px 0;
}

.report h3 {
  margin: 0 0 6px 0;
  font-size: 1rem;
  color: var(--mint);
}

.report p {
  margin: 0;
  white-space: pre-wrap;
}

/* Ensure consistent text color across all summary sections */
.report p.simple-output,
.report div.simple-output {
  color: var(--text);
}

.report section.warn {
  border-color: #ffbe33;
}

/* Highlight important findings section */
.important-findings {
  border-left: 4px solid var(--mint);
  background: var(--panel-2);
}

/* Emphasize text within report using <strong> */
.report p strong {
  color: var(--mint);
  font-weight: 700;
}

/* Distinguish positive and negative findings */
.report p strong.negative {
  color: #ff6b6b;
}

.report p strong.positive {
  color: #4cc96c;
}

/* Container for interactive diagram */
.diagram-container {
  width: 100%;
  height: 300px;
  background: var(--panel-2);
  margin: 20px 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* Loading spinner overlay */
.spinner-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  border: 4px solid var(--panel-2);
  border-top: 4px solid var(--mint);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* fade in the main container */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header with logo and navigation */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.logo-wrapper {
  display: flex;
  align-items: center;
}

.logo {
  height: 68px;
  width: auto;
  border-radius: 8px;
}

.navbar-brand .logo {
  height: 68px;
  width: auto;
}

.navbar-brand img {
  height: 68px;
  width: auto;
}

/* Fix logo visibility in light mode */
.light .logo,
.light .navbar-brand .logo,
.light .navbar-brand img {
  filter: invert(1);
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.nav a {
  color: var(--mint);
  margin-left: 16px;
  text-decoration: none;
  font-weight: 600;
}

.nav a:hover {
  text-decoration: underline;
}

/* Layout with sidebar and main content */
.layout {
  display: flex;
  gap: 24px;
}

.sidebar {
  flex: 0 0 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.sidebar h3 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--mint);
}

.stats {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stats li {
  margin: 6px 0;
  color: var(--text);
}

.main-content {
  flex: 1;
}

.language-label {
  display: block;
  margin-top: 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: .85rem;
}

.visually-hidden {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Language indicator on result page */
.lang {
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.lang-warning {
  background: color-mix(in oklab, var(--mint) 20%, transparent);
  padding: 8px 12px;
  border-left: 4px solid var(--mint);
  border-radius: 8px;
  margin-bottom: 12px;
  color: var(--text);
}

/* Responsive adjustments */
@media (max-width:800px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    flex: none;
    margin-bottom: 20px;
  }
}

/* Flash messages */
.flash {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}

.flash li {
  background: var(--panel-2);
  padding: 8px 12px;
  border-left: 4px solid #ffbe33;
  border-radius: 8px;
  margin-bottom: 6px;
  color: var(--text);
}


/* Light theme variables */
:root.light,
[data-theme='light'] {
  --bg: #f8f9fa;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --text: #1f2937;
  --muted: #4b5563;
  --border: #d7dde5;
  --mint: #0fb989;
  --shadow: 0 4px 10px rgba(0, 0, 0, .08);
}

/* Light theme background override */
html.light body::before,
[data-theme='light'] body::before {
  background-color: var(--bg);
}

/* Light theme selection contrast */
html.light ::selection,
[data-theme='light'] ::selection {
  background: color-mix(in oklab, var(--mint) 25%, #00000010);
}

/* Keep login/signup from stretching with the taller slider */
.navbar .nav-auth {
  display: flex;
  align-items: center;
  /* key fix */
  gap: .75rem;
}

.navbar .nav-auth>* {
  flex: 0 0 auto;
  /* prevent flex-grow */
}

.user-menu {
  position: relative;
}

.user-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.user-menu-toggle:hover,
.user-menu-toggle:focus-visible {
  border-color: var(--mint);
  background: color-mix(in oklab, var(--panel-2) 70%, var(--mint) 18%);
  outline: none;
}

.user-menu-toggle:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--mint) 45%, transparent);
}

.user-caret {
  font-size: 0.75rem;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: 0.45rem 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.35);
  z-index: 1000;
}

.user-menu-dropdown[hidden] {
  display: none !important;
}

.user-menu-dropdown a {
  padding: 0.55rem 0.95rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.user-menu-dropdown a:hover {
  background: color-mix(in oklab, var(--mint) 18%, var(--panel));
}

/* Compact auth buttons */
.navbar .login-button,
.navbar .signup-button {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  padding: .45rem .8rem;
}

/* ---- Theme slider with label below (FINAL) ---- */
.theme-switch {
  display: inline-flex;
  flex-direction: column;
  /* label below */
  align-items: center;
  gap: .25rem;
  margin-right: .5rem;

  /* sizes and fine nudges */
  --track-w: 46px;
  --track-h: 26px;
  --pad: 1px;
  --knob: 22px;
  --travel: calc(var(--track-w) - var(--knob) - (var(--pad) * 2));
  --x-nudge-checked: -2px;
  /* 1px left in light mode */
  --y-nudge-checked: 0px;
  /* 1px up in light mode */
}

.theme-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.theme-icon {
  font-size: 1rem;
  line-height: 1;
}

.theme-switch-text {
  font-size: .9rem;
  line-height: 1;
  color: var(--muted);
}

.theme-switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.theme-switch-track {
  position: relative;
  box-sizing: border-box;
  width: var(--track-w);
  height: var(--track-h);
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  transition: background .22s ease, border-color .22s ease;
}

.theme-switch-track::after {
  content: "";
  position: absolute;
  width: var(--knob);
  height: var(--knob);
  border-radius: 50%;
  left: var(--pad);
  top: 50%;
  transform: translate(var(--x, 0), -50%);
  /* centered vertically */
  background: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), background-color .22s ease, box-shadow .22s ease;
}

.theme-switch-input:checked+.theme-switch-track {
  --x: calc(var(--travel) + var(--x-nudge-checked));
  background: color-mix(in oklab, var(--mint) 35%, var(--panel-2));
  border-color: var(--mint);
}

.theme-switch-input:checked+.theme-switch-track::after {
  transform: translate(calc(var(--travel) + var(--x-nudge-checked)), calc(-50% + var(--y-nudge-checked)));
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {

  .theme-switch-track,
  .theme-switch-track::after {
    transition: none;
  }
}

/* ---- Simple-output lists and highlight colors sitewide ---- */
.simple-output ul {
  margin: .25rem 0 0;
  padding-left: 1.1rem;
}

.simple-output li {
  margin: .2rem 0;
}

.simple-output strong.negative {
  color: #ff6b6b;
}

.simple-output strong.positive {
  color: #4cc96c;
}

/* ---- Clickable organ terms ---- */
.organ-link {
  text-decoration: underline dotted;
  cursor: pointer;
}

/* Lock navbar layout across pages: [logo] [centered nav] [auth/theme] */
.navbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.5rem 2rem;
  background-color: rgba(8, 8, 8, 0.9);
  border-bottom: 1px solid var(--border);
}

.navbar-brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.nav-links {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  white-space: nowrap;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--nav-glow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.nav-links:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
}

@supports (backdrop-filter: blur(0.1px)) {
  .nav-links {
    background: rgba(20, 20, 20, 0.55);
    backdrop-filter: blur(18px);
  }
}

.nav-auth {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.navbar * {
  min-width: 0;
}

.nav-links a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  color: color-mix(in oklab, var(--text) 55%, var(--muted));
  transition: transform 0.2s ease, color 0.2s ease, background 0.25s ease;
}

.nav-links a::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  transition: background 0.25s ease, box-shadow 0.25s ease;
  z-index: -1;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text);
  transform: translateY(-3px);
}

.nav-links a:hover::before,
.nav-links a:focus-visible::before {
  background: var(--mint-soft);
  box-shadow: inset 0 0 0 1px rgba(62, 230, 176, 0.35);
}

html.light .navbar {
  background-color: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid color-mix(in oklab, var(--border) 65%, rgba(15, 23, 42, 0.12));
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.08);
}

html.light .nav-links {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 20px 35px rgba(15, 23, 42, 0.08);
}

@supports (backdrop-filter: blur(0.1px)) {
  html.light .nav-links {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px);
  }
}

html.light .nav-links a {
  color: color-mix(in oklab, #0f172a 75%, rgba(15, 23, 42, 0.35));
}

html.light .nav-links a:hover,
html.light .nav-links a:focus-visible {
  color: #0f172a;
}

html.light .nav-links a::before {
  background: transparent;
}

html.light .nav-links a:hover::before,
html.light .nav-links a:focus-visible::before {
  background: rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.1);
}

html.light .nav-links a.active {
  color: var(--mint);
}

html.light .nav-links a.active::before {
  background: color-mix(in oklab, var(--mint) 25%, rgba(15, 23, 42, 0.08));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--mint) 45%, rgba(15, 23, 42, 0.1));
}

html.light .username-badge,
html.light .nav-auth a,
html.light .nav-auth span {
  color: #0f172a;
}

.nav-links a:focus-visible {
  outline: none;
}

.nav-links a.active {
  color: var(--mint);
}

.nav-links a.active::before {
  background: rgba(62, 230, 176, 0.2);
  box-shadow: inset 0 0 0 1px rgba(62, 230, 176, 0.45);
}

@media (max-width: 900px) {
  .navbar {
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
  }

  .nav-links {
    position: static;
    transform: none;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    row-gap: 0.5rem;
    padding: 0.35rem 0.75rem;
  }

  .nav-links:hover {
    transform: none;
    box-shadow: var(--nav-glow);
  }

  .nav-auth {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* === Theme slider EXACT override === */
.theme-switch {
  --track-w: 44px;
  --track-h: 24px;
  --pad: 3px;
  --knob: 18px;
  --travel: calc(var(--track-w) - var(--knob) - (var(--pad) * 2));
  --x-nudge-checked: 0px;
  --y-nudge-checked: 0px;
}

/* Unchecked (dark mode label) */
.theme-switch-track {
  background: #e5e7eb;
  /* light gray track */
  border: 1px solid #d1d5db;
  /* subtle border */
}

.theme-switch-track::after {
  background: #111827;
  /* dark knob */
}

/* Checked = LIGHT mode */
.theme-switch-input:checked+.theme-switch-track {
  background: #1f7a69;
  /* mint track */
  border-color: #1f7a69;
}

.theme-switch-input:checked+.theme-switch-track::after {
  background: #f3f4f6;
  /* white knob */
}