/* ==========================================================================
   VISANA Complexity Demo — Clean Light Stylesheet
   Simple white UI · matches the markup in index.html
   ========================================================================== */

:root {
  --bg-page:        #f4f6f9;
  --bg-card:        #ffffff;
  --bg-subtle:      #f8fafc;
  --bg-input:       #ffffff;

  --accent:         #2563eb;
  --accent-dark:    #1d4ed8;
  --accent-soft:    rgba(37, 99, 235, 0.08);

  --low:            #6b7280;
  --medium:         #2563eb;
  --high:           #ea580c;
  --very-high:      #dc2626;

  --ok:             #16a34a;
  --warn:           #d97706;
  --err:            #dc2626;

  --text:           #1a1f2e;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  --border:         #e5e7eb;
  --border-strong:  #cbd5e1;

  --radius:         12px;
  --radius-sm:      8px;
  --radius-pill:    9999px;

  --shadow:         0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-hover:   0 4px 14px rgba(15, 23, 42, 0.10);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-page);
  min-height: 100vh;
}

ul, ol { list-style: none; }
img, svg { max-width: 100%; display: block; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }


/* --------------------------------------------------------------------------
   Layout shell
   -------------------------------------------------------------------------- */
.app-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}


/* --------------------------------------------------------------------------
   Header bar
   -------------------------------------------------------------------------- */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.header-left { display: flex; flex-direction: column; }

.logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.logo-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.scan-counter {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--accent-soft);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
}

.scan-counter-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.scan-counter-label { font-size: 0.8rem; color: var(--text-secondary); }


/* --------------------------------------------------------------------------
   Cards & grid
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

.dashboard-section,
.bottom-section { display: flex; flex-direction: column; gap: 24px; }

.section-header { margin-bottom: 4px; }
.section-title { font-size: 1.1rem; font-weight: 700; }
.section-subtitle { font-size: 0.85rem; color: var(--text-muted); }


/* --------------------------------------------------------------------------
   Form controls (left panel)
   -------------------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 36px 10px 12px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-select:hover { border-color: var(--border-strong); }
.form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }

.form-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  outline: none;
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.form-range::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
}

.range-value {
  display: inline-block;
  min-width: 2.4rem;
  text-align: center;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--text-muted);
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.divider-text { padding: 0 12px; font-size: 0.75rem; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toggle-row .form-label { margin-bottom: 0; }

.toggle-switch { position: relative; display: inline-flex; cursor: pointer; }
.toggle-switch input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider {
  width: 42px; height: 24px;
  background: #cbd5e1;
  border-radius: var(--radius-pill);
  transition: background 0.2s;
  position: relative;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }


/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn.disabled { opacity: 0.5; pointer-events: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-subtle); }

.btn-danger { background: #fff; color: var(--err); border-color: #f3c0c0; }
.btn-danger:hover { background: #fdf0f0; }

.btn-row-full { margin-top: 8px; }
.btn-row-full .btn { width: 100%; }

.btn-row-half {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}


/* --------------------------------------------------------------------------
   DICOM drop zone
   -------------------------------------------------------------------------- */
.dicom-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 22px 16px;
  margin-bottom: 16px;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.dicom-dropzone:hover, .dicom-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.dicom-dropzone .dz-icon { display: block; font-size: 1.6rem; margin-bottom: 6px; }
.dicom-dropzone .dz-main { display: block; font-weight: 600; color: var(--text); }
.dicom-dropzone .dz-sub  { display: block; font-size: 0.75rem; margin-top: 2px; }

.dicom-status {
  display: none;
  font-size: 0.75rem;
  line-height: 1.45;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.dicom-status.show { display: block; }
.dicom-status.ok   { background: rgba(22, 163, 74, 0.10);  color: #15803d; }
.dicom-status.warn { background: rgba(217, 119, 6, 0.10);  color: #b45309; }
.dicom-status.err  { background: rgba(220, 38, 38, 0.10);  color: #b91c1c; }


/* --------------------------------------------------------------------------
   Results column — analysis card
   -------------------------------------------------------------------------- */
.results-column { display: flex; flex-direction: column; gap: 24px; }

.results-top-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.gauge-container { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.gauge-ring { width: 140px; height: 140px; }
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gauge-score { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.gauge-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: capitalize; }

.results-meta { display: flex; flex-direction: column; gap: 6px; }
.read-time-display { display: flex; align-items: baseline; gap: 4px; }
.read-time-value { font-size: 2rem; font-weight: 800; color: var(--text); }
.read-time-unit { font-size: 0.9rem; color: var(--text-muted); }
.read-time-range { font-size: 0.8rem; color: var(--text-muted); }

.badge {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Formula breakdown */
.breakdown-section { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.breakdown-row {
  display: grid;
  grid-template-columns: 64px 1fr 48px;
  align-items: center;
  gap: 10px;
}
.breakdown-label { font-size: 0.8rem; color: var(--text-secondary); }
.breakdown-bar-track { height: 8px; background: #eef1f5; border-radius: var(--radius-pill); overflow: hidden; }
.breakdown-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: var(--radius-pill); transition: width 0.6s ease; }
.breakdown-value { font-size: 0.8rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }


/* --------------------------------------------------------------------------
   Assignment card
   -------------------------------------------------------------------------- */
.assignment-arrow { display: flex; justify-content: center; color: var(--accent); margin-bottom: 8px; }
.assignment-body { display: flex; align-items: center; gap: 16px; }

.assignment-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: var(--accent);
}
.assignment-details { display: flex; flex-direction: column; gap: 2px; }
.assignment-name { font-weight: 700; font-size: 1rem; }
.assignment-specialty { font-size: 0.85rem; color: var(--text-secondary); }
.assignment-reason { font-size: 0.82rem; color: var(--text-muted); }
.assignment-load { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }


/* --------------------------------------------------------------------------
   Radiologist dashboard grid
   -------------------------------------------------------------------------- */
.radiologist-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.rad-card {
  padding: 16px;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.rad-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.rad-card.highlight { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.rad-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.rad-avatar {
  position: relative;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.rad-status-dot {
  position: absolute;
  bottom: 0; right: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
}
.rad-info { min-width: 0; }
.rad-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rad-specialty { font-size: 0.78rem; color: var(--text-muted); }

.rad-metrics { display: flex; flex-direction: column; gap: 8px; }
.rad-metric-row { display: flex; flex-direction: column; gap: 4px; }
.rad-metric-label { font-size: 0.78rem; color: var(--text-secondary); }
.rad-progress-track { height: 6px; background: #eef1f5; border-radius: var(--radius-pill); overflow: hidden; }
.rad-progress-fill { height: 100%; border-radius: var(--radius-pill); transition: width 0.4s ease; }

.rad-cases-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.no-cases-text { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }

.case-badge {
  padding: 2px 7px;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  cursor: default;
}
.case-badge.complexity-low       { background: rgba(107,114,128,0.12); color: #4b5563; }
.case-badge.complexity-medium    { background: rgba(37,99,235,0.12);  color: #1d4ed8; }
.case-badge.complexity-high      { background: rgba(234,88,12,0.12);  color: #c2410c; }
.case-badge.complexity-very_high { background: rgba(220,38,38,0.12);  color: #b91c1c; }


/* --------------------------------------------------------------------------
   Bottom section — workload chart + timeline
   -------------------------------------------------------------------------- */
.bottom-section {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  flex-direction: unset;
}

.chart-container { display: flex; flex-direction: column; gap: 12px; }
.chart-row { display: grid; grid-template-columns: 36px 1fr 44px; align-items: center; gap: 10px; }
.chart-label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.chart-bar-track { height: 12px; background: #eef1f5; border-radius: var(--radius-pill); overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: var(--radius-pill); transition: width 0.5s ease; min-width: 2px; }
.chart-value { font-size: 0.8rem; font-weight: 600; text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.timeline-list { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.timeline-empty { font-size: 0.85rem; color: var(--text-muted); font-style: italic; padding: 8px 0; }
.timeline-entry { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.timeline-text { flex: 1; color: var(--text-secondary); }
.timeline-text strong { color: var(--text); font-weight: 600; }
.timeline-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }


/* --------------------------------------------------------------------------
   Controls bar + stats
   -------------------------------------------------------------------------- */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stats-row { display: flex; gap: 32px; }
.stat-item { display: flex; flex-direction: column; align-items: flex-end; }
.stat-value { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-top: 2px; }


/* --------------------------------------------------------------------------
   Complexity color helpers (applied dynamically)
   -------------------------------------------------------------------------- */
.complexity-text-low       { color: var(--low) !important; }
.complexity-text-medium    { color: var(--medium) !important; }
.complexity-text-high      { color: var(--high) !important; }
.complexity-text-very_high { color: var(--very-high) !important; }

.complexity-bg-low       { background: var(--low) !important;       color: #fff !important; }
.complexity-bg-medium    { background: var(--medium) !important;    color: #fff !important; }
.complexity-bg-high      { background: var(--high) !important;      color: #fff !important; }
.complexity-bg-very_high { background: var(--very-high) !important; color: #fff !important; }


/* --------------------------------------------------------------------------
   State & animation helpers
   -------------------------------------------------------------------------- */
.hidden { display: none !important; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

.fade-in  { animation: fadeInUp 0.4s ease-out; }
.slide-in { animation: slideInRight 0.4s ease-out; }


/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 1fr; }
  .radiologist-grid { grid-template-columns: repeat(2, 1fr); }
  .bottom-section { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app-container { padding: 14px; gap: 16px; }
  .radiologist-grid { grid-template-columns: 1fr; }
  .header-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .controls-bar { flex-direction: column; align-items: stretch; gap: 14px; }
  .stats-row { justify-content: space-between; }
  .stat-item { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
