/* ==============================================================================
   CG-MedSAM Clinical Web Demo — Design System & Stylesheet
   Modern Glassmorphic Dark UI, Vibrant Cyber-Clinical Accents, Fluid Layout
   ============================================================================== */

:root {
  /* Color Tokens */
  --bg-base: #090D16;
  --bg-panel: rgba(17, 24, 39, 0.72);
  --bg-panel-hover: rgba(24, 33, 53, 0.85);
  --bg-card: rgba(30, 41, 59, 0.65);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(15, 23, 42, 0.8);

  --accent-cyan: #00F0FF;
  --accent-cyan-glow: rgba(0, 240, 255, 0.28);
  --accent-emerald: #10B981;
  --accent-purple: #8B5CF6;
  --accent-amber: #F59E0B;
  --accent-rose: #F43F5E;

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Typography */
  --font-display: 'Outfit', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions & Shadows */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.45);
  --glow-shadow: 0 0 25px var(--accent-cyan-glow);
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(0, 240, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 45%);
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Navigation Bar */
.app-header {
  height: 64px;
  background: rgba(13, 19, 33, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-badge {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #050811;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-tag {
  background: rgba(0, 240, 255, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 240, 255, 0.3);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-weight: 600;
}

.brand-subtitle {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 5px 12px;
  border-radius: 20px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-label {
  font-size: 12px;
  color: #A7F3D0;
  font-weight: 500;
}

/* Workspace 3-Column Layout */
.workspace-grid {
  display: grid;
  grid-template-columns: 340px 1fr 340px;
  gap: 18px;
  padding: 18px;
  flex: 1;
  max-width: 1720px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 1280px) {
  .workspace-grid {
    grid-template-columns: 320px 1fr;
  }
  .telemetry-panel {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Glassmorphic Panel Styles */
.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.control-panel, .telemetry-panel {
  padding: 18px;
  gap: 18px;
  overflow-y: auto;
  max-height: calc(100vh - 100px);
}

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

.section-title {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Sample Cards */
.sample-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sample-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sample-card:hover {
  background: var(--bg-panel-hover);
  border-color: rgba(0, 240, 255, 0.4);
  transform: translateY(-1px);
}

.sample-card.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.08);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.15);
}

.sample-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sample-info {
  flex: 1;
}

.sample-title {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
}

.sample-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.sample-fst-tag {
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
}

.tag-dark { background: rgba(180, 83, 9, 0.25); color: #FCD34D; }
.tag-med { background: rgba(217, 119, 6, 0.2); color: #FBBF24; }
.tag-light { background: rgba(16, 185, 129, 0.2); color: #6EE7B7; }

/* Custom Upload Dropzone */
.upload-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.4);
  transition: var(--transition-fast);
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.04);
}

.upload-icon {
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.upload-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.highlight-link {
  color: var(--accent-cyan);
  text-decoration: underline;
}

.upload-specs {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Model Selector Radios */
.model-select-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.model-option:hover {
  background: var(--bg-panel-hover);
}

.model-option.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.07);
}

.model-option input[type="radio"] {
  accent-color: var(--accent-cyan);
  margin-top: 3px;
}

.model-meta {
  flex: 1;
}

.model-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.model-name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
}

.pill-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 12px;
  font-weight: 600;
}

.pill-badge.recommended {
  background: rgba(0, 240, 255, 0.18);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

.pill-badge.baseline {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.model-desc {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Prompt Action Buttons & Coordinate Grid */
.prompt-action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.coord-inputs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.input-field label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.input-field input {
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  transition: var(--transition-fast);
}

.input-field input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

/* Primary Segmentation Button */
.primary-action-btn {
  background: linear-gradient(135deg, #00F0FF, #3B82F6);
  color: #030712;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
  transition: var(--transition-fast);
  margin-top: auto;
}

.primary-action-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(0, 240, 255, 0.5);
}

.primary-action-btn:active {
  transform: translateY(0);
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: #030712;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Visualizer Panel (Center) */
.visualizer-panel {
  display: flex;
  flex-direction: column;
}

.visualizer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--bg-card-border);
  background: rgba(15, 23, 42, 0.4);
}

.tab-pill-group {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--bg-card-border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.tab-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-pill:hover {
  color: var(--text-primary);
}

.tab-pill.active {
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  font-weight: 600;
}

.canvas-toggles {
  display: flex;
  gap: 14px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-label input {
  display: none;
}

.toggle-custom {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--text-muted);
  display: inline-block;
  transition: var(--transition-fast);
}

.toggle-label input:checked + .core-check {
  background: #38BDF8;
  border-color: #38BDF8;
}

.toggle-label input:checked + .ring-check {
  background: #A855F7;
  border-color: #A855F7;
}

/* Canvas Viewport */
.canvas-viewport {
  flex: 1;
  min-height: 480px;
  background: #030712;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#mainCanvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: crosshair;
}

.canvas-overlay-ui {
  position: absolute;
  bottom: 12px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--bg-card-border);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 11.5px;
  color: var(--text-secondary);
  pointer-events: none;
}

/* Visualizer Footer */
.visualizer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--bg-card-border);
  background: rgba(15, 23, 42, 0.4);
}

.dimensions-display {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.export-actions {
  display: flex;
  gap: 8px;
}

.action-sub-btn {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition-fast);
}

.action-sub-btn:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.action-sub-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Generic Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.secondary-btn {
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: 12px;
  padding: 7px 12px;
  flex: 1;
}

.secondary-btn:hover {
  background: rgba(0, 240, 255, 0.2);
}

.ghost-btn {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 7px 12px;
}

.ghost-btn:hover {
  color: var(--text-primary);
  background: var(--bg-panel-hover);
}

/* Telemetry Panel (Right) */
.telemetry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.telemetry-live-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 14px;
}

.metric-card.highlight-card {
  border-color: rgba(0, 240, 255, 0.25);
  background: linear-gradient(145deg, rgba(0, 240, 255, 0.04), rgba(139, 92, 246, 0.04));
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.05);
}

.metric-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.metric-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.metric-symbol {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
}

/* Gauge 1 */
.gauge-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.circular-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.metric-big-num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-cyan);
  line-height: 1;
}

.metric-unit {
  font-size: 10px;
  color: var(--text-muted);
}

.gauge-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gauge-track {
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.gauge-fill {
  height: 100%;
  background: linear-gradient(90deg, #10B981, #00F0FF, #8B5CF6);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.metric-footnote {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Gate Gamma Card */
.gate-value-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.gate-big-val {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  color: var(--text-primary);
}

.gate-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.formula-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  color: #A5B4FC;
  margin-bottom: 8px;
  overflow-x: auto;
}

.gate-explanation {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Skin Tone Card */
.skin-cohort-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--bg-card-border);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.tone-circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #A1A1AA;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.tone-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.skin-submetrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.submetric-col {
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 10px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

.sub-label {
  font-size: 10px;
  color: var(--text-muted);
}

.sub-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Morphometry Grid */
.morph-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.morph-item {
  background: rgba(0, 0, 0, 0.2);
  padding: 7px 10px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

.morph-key {
  font-size: 10px;
  color: var(--text-muted);
}

.morph-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-top: 2px;
}
