/* ==========================================================================
   DentaSOTA AI — Modern Clinical Radiology Workstation Stylesheet
   Built with Modern Web Guidance Design Tokens & Glassmorphism Aesthetics
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg-darkest: #07090e;
  --bg-base: #0b0f19;
  --bg-surface: #121826;
  --bg-surface-elevated: #1a2236;
  --bg-card: rgba(26, 34, 54, 0.7);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(56, 189, 248, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Clinical Diagnostic Palette */
  --color-fdi: #38bdf8;
  --color-fdi-glow: rgba(56, 189, 248, 0.25);
  --color-caries: #f59e0b;
  --color-caries-glow: rgba(245, 158, 11, 0.25);
  --color-periapical: #c084fc;
  --color-periapical-glow: rgba(192, 132, 252, 0.25);
  --color-impacted: #f43f5e;
  --color-impacted-glow: rgba(244, 63, 94, 0.25);
  --color-healthy: #10b981;
  --color-healthy-glow: rgba(16, 185, 129, 0.25);
  
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --header-height: 60px;
  --odontogram-height: 180px;
  --sidebar-width: 380px;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px var(--color-fdi-glow);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-darkest);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Header Navigation & Clinical Tools
   ========================================================================== */
.header {
  height: var(--header-height);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 20px;
  z-index: 50;
  flex-shrink: 0;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.brand-logo svg {
  width: 26px;
  height: 26px;
  color: var(--color-fdi);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(16, 185, 129, 0.12);
  color: var(--color-healthy);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.live-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-healthy);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Language Switcher */
.lang-switch-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--color-fdi);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.case-selector-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select-wrapper {
  position: relative;
}

select.case-dropdown {
  appearance: none;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 7px 32px 7px 12px;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

select.case-dropdown:hover, select.case-dropdown:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px var(--color-fdi-glow);
}

.select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px dashed var(--border-subtle);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-upload:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--color-fdi);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 0 16px var(--color-fdi-glow);
}

/* ==========================================================================
   Main App Layout
   ========================================================================== */
.main-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

.viewport-section {
  display: flex;
  flex-direction: column;
  position: relative;
  background: #040609;
  overflow: hidden;
  border-right: 1px solid var(--border-subtle);
}

/* Canvas Toolbar */
.canvas-header-toolbar {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  pointer-events: none;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 22, 36, 0.8);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  padding: 4px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}

.tool-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.tool-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--color-fdi);
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.filter-badge.active-fdi {
  background: rgba(56, 189, 248, 0.12);
  color: var(--color-fdi);
  border-color: rgba(56, 189, 248, 0.3);
}

.filter-badge.active-caries {
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-caries);
  border-color: rgba(245, 158, 11, 0.3);
}

.filter-badge.active-periapical {
  background: rgba(192, 132, 252, 0.12);
  color: var(--color-periapical);
  border-color: rgba(192, 132, 252, 0.3);
}

.filter-badge.active-impacted {
  background: rgba(244, 63, 94, 0.12);
  color: var(--color-impacted);
  border-color: rgba(244, 63, 94, 0.3);
}

.filter-badge.active-filling {
  background: rgba(6, 182, 212, 0.12);
  color: #06b6d4;
  border-color: rgba(6, 182, 212, 0.3);
}

.filter-badge.active-crown {
  background: rgba(234, 179, 8, 0.12);
  color: #eab308;
  border-color: rgba(234, 179, 8, 0.3);
}

.filter-badge.active-root_canal {
  background: rgba(20, 184, 166, 0.12);
  color: #14b8a6;
  border-color: rgba(20, 184, 166, 0.3);
}

.canvas-viewport {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100% - var(--odontogram-height));
  cursor: grab;
  overflow: hidden;
}

.canvas-viewport:active {
  cursor: grabbing;
}

canvas#viewportCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Viewport HUD info */
.hud-overlay {
  position: absolute;
  bottom: 12px;
  left: 16px;
  display: flex;
  gap: 12px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  pointer-events: none;
  background: rgba(11, 15, 25, 0.6);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Bottom Odontogram (32-Tooth Digital Dental Chart)
   ========================================================================== */
.odontogram-panel {
  height: var(--odontogram-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
  z-index: 10;
  flex-shrink: 0;
}

.odontogram-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.odontogram-arch-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-block: 2px;
}

.quadrant-divider {
  width: 2px;
  height: 38px;
  background: var(--border-active);
  margin-inline: 6px;
  opacity: 0.6;
}

.tooth-chip {
  flex: 1;
  max-width: 44px;
  height: 48px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.tooth-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.tooth-chip.selected {
  border-color: var(--color-fdi);
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 12px var(--color-fdi-glow);
}

.tooth-chip.has-caries {
  border-color: var(--color-caries);
  background: rgba(245, 158, 11, 0.15);
}

.tooth-chip.has-periapical {
  border-color: var(--color-periapical);
  background: rgba(192, 132, 252, 0.15);
}

.tooth-chip.has-impacted {
  border-color: var(--color-impacted);
  background: rgba(244, 63, 94, 0.15);
}

.tooth-chip.is-missing {
  opacity: 0.35;
  border-style: dashed;
}

.tooth-fdi-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tooth-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: transparent;
}

.tooth-chip.has-caries .tooth-indicator-dot {
  background-color: var(--color-caries);
  box-shadow: 0 0 6px var(--color-caries);
}

.tooth-chip.has-periapical .tooth-indicator-dot {
  background-color: var(--color-periapical);
  box-shadow: 0 0 6px var(--color-periapical);
}

.tooth-chip.has-impacted .tooth-indicator-dot {
  background-color: var(--color-impacted);
  box-shadow: 0 0 6px var(--color-impacted);
}

/* ==========================================================================
   Right Sidebar (Clinical Intelligence & Inspector)
   ========================================================================== */
.sidebar {
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-left: 1px solid var(--border-subtle);
}

.sidebar-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Critical Alerts Box */
.alert-box {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.alert-box svg {
  color: var(--color-impacted);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.alert-text {
  font-size: 0.78rem;
  line-height: 1.4;
  color: #fca5a5;
}

/* Tooth Inspector Card */
.inspector-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 14px;
}

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

.inspector-tooth-badge {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-fdi);
}

.inspector-status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
}

.inspector-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding-block: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.inspector-row:last-child {
  border-bottom: none;
}

/* Findings List */
.findings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.finding-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.finding-item:hover {
  border-color: var(--border-active);
  transform: translateX(3px);
}

.finding-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.finding-tag.caries {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-caries);
}

.finding-tag.periapical {
  background: rgba(192, 132, 252, 0.15);
  color: var(--color-periapical);
}

.finding-tag.impacted {
  background: rgba(244, 63, 94, 0.15);
  color: var(--color-impacted);
}

.impression-text {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Report Modal Dialog
   ========================================================================== */
dialog#reportDialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(720px, 90vw);
  max-height: 85vh;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  z-index: 100;
}

dialog#reportDialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.btn-close:hover {
  color: var(--text-primary);
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--color-fdi);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Glassmorphic Tooth HUD Tooltip */
.canvas-tooth-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  color: #f8fafc;
  font-size: 0.80rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -120%);
  transition: opacity 0.12s ease;
  white-space: nowrap;
}

.canvas-tooth-tooltip .tooltip-header {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
