/* CephaloTrace Professional Encephalometric & Cephalometric Analysis System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #090d14;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.9);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-bright: rgba(0, 242, 254, 0.3);
  
  --primary-cyan: #00f2fe;
  --primary-blue: #4facfe;
  --accent-green: #38ef7d;
  --accent-emerald: #11998e;
  --accent-amber: #ffb703;
  --accent-red: #ff4b5c;
  --accent-purple: #9d4edd;
  --accent-pink: #ff758c;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --sidebar-width: 270px;
  --right-panel-width: 295px;
  --header-height: 52px;
  --footer-height: 38px;

  --shadow-glow: 0 0 20px rgba(0, 242, 254, 0.15);
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --glass-backdrop: blur(16px) saturate(180%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-cyan);
}

/* App Header */
.app-header {
  height: var(--header-height);
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: var(--glass-backdrop);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-cyan));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #090d14;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffffff, var(--primary-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.3px;
}

.patient-info-strip {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.4rem 1rem;
  border-radius: 30px;
  border: 1px solid var(--panel-border);
  font-size: 0.82rem;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.info-item label {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.info-item span {
  font-weight: 600;
  color: var(--primary-cyan);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* App Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #00c6ff, #0072ff);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 198, 255, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 198, 255, 0.45);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-green));
  color: #090d14;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(56, 239, 125, 0.3);
}
.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(56, 239, 125, 0.45);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
}
.btn-glass:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon-only {
  padding: 0.5rem;
  border-radius: 8px;
}

/* Layout Body */
.app-container {
  display: flex;
  height: calc(100vh - var(--header-height) - var(--footer-height));
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Sidebar Panels */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(13, 17, 23, 0.7);
  backdrop-filter: var(--glass-backdrop);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.right-panel {
  width: var(--right-panel-width);
  background: rgba(13, 17, 23, 0.7);
  backdrop-filter: var(--glass-backdrop);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.panel-section {
  padding: 1.25rem;
  border-bottom: 1px solid var(--panel-border);
}

.panel-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title svg {
  color: var(--primary-cyan);
}

/* Control Controls (Sliders & Switches) */
.control-group {
  margin-bottom: 1rem;
}
.control-group:last-child {
  margin-bottom: 0;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.control-val {
  font-family: 'JetBrains Mono', monospace;
  color: var(--primary-cyan);
  font-size: 0.78rem;
}

input[type="range"] {
  width: 100%;
  height: 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--primary-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary-cyan);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.toggle-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 0.5rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: rgba(0, 242, 254, 0.1);
  border-color: var(--primary-cyan);
  color: var(--primary-cyan);
  box-shadow: inset 0 0 10px rgba(0, 242, 254, 0.1);
}

/* Landmark Category Accordion / List */
.landmark-group {
  margin-bottom: 0.75rem;
}

.group-header {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.4rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.landmark-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  margin: 0.25rem 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.landmark-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.landmark-item.active {
  background: rgba(0, 242, 254, 0.12);
  border-color: var(--primary-cyan);
}

.landmark-item.placed {
  border-left: 3px solid var(--accent-green);
}

.landmark-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.landmark-code {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--primary-cyan);
  width: 32px;
}

.landmark-name {
  font-size: 0.78rem;
  color: var(--text-main);
}

.landmark-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.landmark-item.placed .landmark-status {
  color: var(--accent-green);
}

/* Active Landmark Guidance Banner */
.guidance-box {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.08), rgba(79, 172, 254, 0.04));
  border: 1px solid var(--panel-border-bright);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.guidance-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--primary-cyan);
  margin-bottom: 0.3rem;
}

.guidance-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Center Main Radiograph Viewport */
.viewport-container {
  flex: 1;
  background: #04060a;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
}

.canvas-wrapper {
  position: relative;
  transform-origin: center center;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

canvas#xrayCanvas, canvas#overlayCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

canvas#xrayCanvas {
  z-index: 1;
}

canvas#overlayCanvas {
  z-index: 2;
  pointer-events: auto;
}

/* Viewport Controls Overlay */
.viewport-floating-controls {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--panel-border);
  padding: 0.4rem 0.8rem;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 20;
  box-shadow: var(--shadow-card);
}

.viewport-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.viewport-btn:hover {
  color: var(--primary-cyan);
  background: rgba(255, 255, 255, 0.08);
}

.zoom-indicator {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-main);
  min-width: 45px;
  text-align: center;
}

/* Live Magnifying Loupe Window */
.loupe-window {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 2px solid var(--primary-cyan);
  box-shadow: 0 0 25px rgba(0, 242, 254, 0.4), inset 0 0 15px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
  display: none;
  background: #000;
}

.loupe-window canvas {
  position: absolute;
  top: 0;
  left: 0;
}

.loupe-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 35;
}

.loupe-crosshair::before, .loupe-crosshair::after {
  content: '';
  position: absolute;
  background: var(--accent-red);
}

.loupe-crosshair::before {
  top: 9px;
  left: 0;
  width: 20px;
  height: 2px;
}

.loupe-crosshair::after {
  top: 0;
  left: 9px;
  width: 2px;
  height: 20px;
}

/* Diagnostic Analysis Cards & Gauges */
.metric-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  transition: all 0.2s ease;
}

.metric-card:hover {
  border-color: rgba(0, 242, 254, 0.25);
  background: rgba(255, 255, 255, 0.04);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.metric-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.metric-norm {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.metric-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-cyan);
}

.metric-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-normal {
  background: rgba(56, 239, 125, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(56, 239, 125, 0.3);
}

.badge-mild {
  background: rgba(255, 183, 3, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(255, 183, 3, 0.3);
}

.badge-severe {
  background: rgba(255, 75, 92, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(255, 75, 92, 0.3);
}

/* Linear Gauge Bar */
.gauge-bar {
  height: 4px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin-top: 0.5rem;
  position: relative;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease, background 0.3s ease;
}

/* Clinical Impression Summary Box */
.impression-card {
  background: linear-gradient(135deg, rgba(17, 153, 142, 0.1), rgba(56, 239, 125, 0.05));
  border: 1px solid rgba(56, 239, 125, 0.25);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 0.5rem;
}

.impression-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-green);
  margin-bottom: 0.5rem;
}

.impression-text {
  font-size: 0.78rem;
  color: var(--text-main);
  line-height: 1.45;
}

/* Footer Toolbar */
.app-footer {
  height: var(--footer-height);
  background: rgba(13, 17, 23, 0.95);
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-samples {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sample-chip {
  padding: 0.25rem 0.65rem;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  font-size: 0.74rem;
  transition: all 0.15s;
}

.sample-chip:hover, .sample-chip.active {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--primary-cyan);
  color: var(--primary-cyan);
}

.footer-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: #0d1117;
  border: 1px solid var(--panel-border-bright);
  border-radius: 16px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card), 0 0 40px rgba(0, 242, 254, 0.2);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
}

.modal-body {
  padding: 1.5rem;
}

/* Print / Report Styles */
@page {
  size: A4 portrait;
  margin: 8mm 10mm 8mm 10mm;
}
@media print {
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
    height: auto !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .app-header, .sidebar, .right-panel, .app-footer, .viewport-floating-controls, .loupe-window, .modal-header, .modal-footer {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    display: block !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .modal-card {
    position: static !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    border: none !important;
  }
  .modal-body {
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }
  #reportCanvasSnapshot {
    max-height: 440px !important;
    width: auto !important;
    margin: 0 auto 0.8rem auto !important;
    display: block !important;
    border: 1px solid #ccc !important;
  }
}
