/* InfinityMedical Enterprise PMS Design System */

:root, :root[data-theme="dark"] {
  --bg-primary: #080e1a;
  --bg-secondary: #0f172a;
  --bg-card: #131e33;
  --bg-card-hover: #1a2742;
  --bg-elevated: #1e2c4a;
  --bg-surface: #0f172a;
  --bg-surface-secondary: #131e33;
  --border-color: #243452;
  --border-subtle: #1a263d;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --medical-cyan: #22d3ee;
  --medical-teal: #0d9488;
  --medical-blue: #0284c7;
  --medical-emerald: #10b981;
  --medical-amber: #f59e0b;
  --medical-rose: #f43f5e;
  
  --neon-border: 1.5px solid rgba(34, 211, 238, 0.85);
  --neon-shadow: 0 0 16px rgba(6, 182, 212, 0.45), inset 0 0 10px rgba(6, 182, 212, 0.18);
  --neon-bg: linear-gradient(135deg, rgba(6, 182, 212, 0.22) 0%, rgba(99, 102, 241, 0.22) 50%, rgba(168, 85, 247, 0.22) 100%);
  --neon-bar: linear-gradient(90deg, transparent, #22d3ee, #a855f7, transparent);
  --neon-text-color: #ffffff;
  --neon-svg-stroke: #22d3ee;
  --modal-overlay-bg: rgba(8, 14, 26, 0.78);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

:root[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-elevated: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-secondary: #f1f5f9;
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --medical-cyan: #0891b2;
  --medical-teal: #0d9488;
  --medical-blue: #0284c7;
  --medical-emerald: #059669;
  --medical-amber: #d97706;
  --medical-rose: #e11d48;
  
  --neon-border: 1.5px solid rgba(14, 165, 233, 0.95);
  --neon-shadow: 0 0 14px rgba(14, 165, 233, 0.35), inset 0 0 6px rgba(14, 165, 233, 0.12);
  --neon-bg: linear-gradient(135deg, rgba(14, 165, 233, 0.16) 0%, rgba(99, 102, 241, 0.16) 50%, rgba(168, 85, 247, 0.16) 100%);
  --neon-bar: linear-gradient(90deg, transparent, #0284c7, #7c3aed, transparent);
  --neon-text-color: #0f172a;
  --neon-svg-stroke: #0284c7;
  --modal-overlay-bg: rgba(15, 23, 42, 0.45);
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1:focus, h1:focus-visible,
h2:focus, h2:focus-visible,
h3:focus, h3:focus-visible,
[tabindex="-1"]:focus {
  outline: none !important;
  box-shadow: none !important;
}

html {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Glowing Neon Border & Halo Standard (AGENTS.md) */
.glowing-neon-active {
  border: var(--neon-border) !important;
  box-shadow: var(--neon-shadow) !important;
  background: var(--neon-bg) !important;
  color: var(--neon-text-color) !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  position: relative;
}

.glowing-neon-active svg {
  stroke: var(--neon-svg-stroke) !important;
}

.glowing-neon-active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  background: var(--neon-bar);
  border-radius: 9999px;
}

.nav-neon-active {
  border: var(--neon-border) !important;
  box-shadow: var(--neon-shadow) !important;
  background: var(--neon-bg) !important;
  color: var(--neon-text-color) !important;
  font-weight: 700 !important;
  text-decoration: none !important;
}

.nav-neon-active svg {
  stroke: var(--neon-svg-stroke) !important;
}

/* Modal Dialog Solid Container with Glowing Neon Halo (Strictly Respects Active Theme) */
.med-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-overlay-bg) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  backdrop-filter: blur(6px) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: 20px;
}

.med-modal-card {
  background: var(--bg-card) !important; /* Solid opaque surface using active theme token */
  border: var(--neon-border) !important;
  box-shadow: var(--shadow-lg), var(--neon-shadow) !important;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  color: var(--text-primary) !important;
}

.med-modal-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--neon-bar);
}

.pulse-neon-dot {
  width: 8px;
  height: 8px;
  background-color: #22d3ee;
  border-radius: 50%;
  box-shadow: 0 0 8px #22d3ee;
  animation: pulse-dot 1.8s infinite;
  display: inline-block;
  margin-right: 6px;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(34, 211, 238, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); }
}

/* Layout Shell */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  max-width: 100vw;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-primary);
}

.sidebar {
  width: 260px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
  width: 68px;
}

.sidebar.collapsed .brand-title,
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-footer-text,
.sidebar.collapsed .sidebar-badge {
  display: none !important;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .brand-box {
  padding: 16px 14px;
  justify-content: center;
}

/* 2nd-Level Patient Side Panel */
.patient-drawer {
  width: 300px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.2s ease;
  overflow-y: auto;
}

.patient-drawer-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--bg-elevated);
}

.patient-drawer-menu {
  list-style: none;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.patient-drawer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  cursor: pointer;
}

.patient-drawer-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.patient-drawer-item.active {
  border: var(--neon-border);
  box-shadow: var(--neon-shadow);
  background: var(--neon-bg);
  color: var(--neon-text-color) !important;
  font-weight: 700;
}

.patient-drawer-item.active svg {
  stroke: var(--neon-svg-stroke) !important;
}

.main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-primary);
  position: relative;
}

.top-header {
  height: 64px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  width: 100%;
  position: relative;
  z-index: 100;
  overflow: visible;
}

.page-body {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
}

/* Brand & Typography */
.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 10px;
  color: var(--medical-cyan);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

/* Nav Menu */
.nav-list {
  list-style: none;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
  border: 1.5px solid transparent;
}

.nav-link:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  color: var(--text-muted);
}

.nav-link:hover svg {
  color: var(--medical-cyan);
}

/* UI Cards */
.med-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.med-card:hover {
  border-color: var(--border-subtle);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Buttons */
.btn-med {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--medical-blue);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #0369a1;
}

.btn-secondary {
  background-color: var(--bg-elevated);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--medical-cyan);
}

.btn-outline-neon {
  background-color: transparent;
  border: 1.5px solid var(--medical-cyan);
  color: var(--medical-cyan);
}

.btn-outline-neon:hover {
  background: var(--neon-bg);
  box-shadow: var(--neon-shadow);
  color: var(--neon-text-color) !important;
}

.btn-logout {
  background: rgba(244, 63, 94, 0.12) !important;
  border: 1px solid rgba(244, 63, 94, 0.45) !important;
  color: #fca5a5 !important;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background: rgba(244, 63, 94, 0.25) !important;
  border-color: rgba(244, 63, 94, 0.9) !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.5) !important;
}

/* User Profile & Clinic Session Dropdown */
.profile-menu-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 100000;
}

.dropdown-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99998;
  background: transparent;
  cursor: default;
}

.profile-trigger-btn {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1.5px solid var(--border-color) !important;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
  font-family: inherit;
  font-size: 13px;
  white-space: nowrap;
  outline: none;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 100000;
}

.profile-trigger-btn:hover {
  border-color: var(--medical-cyan) !important;
  box-shadow: var(--shadow-md), 0 0 12px rgba(34, 211, 238, 0.35) !important;
}

.profile-dropdown-card {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  background-color: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1.5px solid var(--border-color) !important;
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 20px rgba(6, 182, 212, 0.25);
  padding: 16px;
  z-index: 100001;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: dropdown-fade-in 0.15s ease-out;
}

@keyframes dropdown-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.profile-dropdown-section {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-elevated);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.profile-dropdown-item:hover {
  border-color: var(--medical-cyan);
}

/* Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.badge-waiting {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-consult {
  background-color: rgba(34, 211, 238, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(34, 211, 238, 0.3);
}

.badge-completed {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-critical {
  background-color: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.35);
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(244, 63, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

/* Form Controls */
.med-input, .med-select, .med-textarea {
  width: 100%;
  padding: 9px 12px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.med-input:focus, .med-select:focus, .med-textarea:focus {
  border: var(--neon-border);
  box-shadow: var(--neon-shadow);
}

.med-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

/* Data Table */
.med-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.med-table th {
  padding: 12px 16px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.med-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.med-table tr:hover td {
  background-color: var(--bg-card-hover);
}

/* DICOM Viewport */
.dicom-viewport-container {
  background-color: #000000;
  border: 1px solid #1e293b;
  border-radius: 8px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  overflow: hidden;
}

.dicom-overlay-info {
  position: absolute;
  top: 14px;
  left: 14px;
  color: #22d3ee;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.5;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.dicom-overlay-tools {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
}

/* Viewport-Fitted Layout Standard (Zero Outer Page Scroll) */
.viewport-fitted-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px - 32px);
  max-height: calc(100vh - 64px - 32px);
  overflow: hidden;
  gap: 10px;
}

/* Compact Stat Bar & Cards */
.compact-stat-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .compact-stat-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.compact-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  transition: all 0.15s ease;
}

.compact-stat-card:hover {
  border-color: var(--medical-cyan);
}

.compact-stat-val {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.1;
}

.compact-stat-lbl {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Compact Table Row Styling */
.med-table.table-compact th {
  padding: 6px 10px !important;
  font-size: 11px !important;
  height: 32px;
}

.med-table.table-compact td {
  padding: 4px 10px !important;
  font-size: 12px !important;
  height: 36px !important;
  vertical-align: middle;
}

/* Critical Trajectory Red Warning Triangle & Popover */
.trajectory-warning-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.7));
  margin-right: 6px;
  vertical-align: middle;
}

.trajectory-warning-icon:hover {
  transform: scale(1.22);
  filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.95));
}

.pinned-popover {
  position: absolute;
  left: 26px;
  top: -12px;
  z-index: 9999;
  width: 320px;
  background: var(--bg-card);
  border: 1.5px solid #ef4444;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 14px rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  padding: 12px;
  animation: popoverFadeIn 0.15s ease-out;
  text-align: left;
  white-space: normal;
  color: var(--text-primary);
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Right Slide-Out Details Panel */
.slideout-details-panel {
  position: fixed;
  top: 64px;
  right: 0;
  width: 480px;
  max-width: 90vw;
  height: calc(100vh - 64px);
  background: var(--bg-card);
  border-left: 1.5px solid var(--medical-cyan);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6), inset 0 0 16px rgba(6, 182, 212, 0.12);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: slideInRight 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.slideout-backdrop {
  position: fixed;
  top: 64px;
  left: 0;
  width: 100vw;
  height: calc(100vh - 64px);
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 9999;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* Standardized Slide-Out Right-Side Panel (Drawer) System */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 200000 !important;
  animation: backdropFadeIn 0.2s ease-out;
}

@keyframes backdropFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.med-modal, .modal-dialog {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 680px;
  max-width: 95vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  background: var(--bg-card) !important;
  border-left: 1.5px solid rgba(34, 211, 238, 0.85) !important;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.75), 0 0 20px rgba(6, 182, 212, 0.35), inset 0 0 10px rgba(6, 182, 212, 0.15) !important;
  z-index: 200001 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.med-modal .modal-header, .modal-dialog .modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  flex-shrink: 0;
  min-height: 60px;
}

.med-modal .modal-header h3, .modal-dialog .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.med-modal .btn-close, .modal-dialog .btn-close, .panel-btn-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.med-modal .btn-close:hover, .modal-dialog .btn-close:hover, .panel-btn-close:hover {
  color: #ffffff;
  background: rgba(244, 63, 94, 0.85);
  border-color: rgba(244, 63, 94, 1);
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.5);
}

/* Encounter Workspace Full-Height Non-Scrolling Container Layout */
.page-body:has(.encounter-workspace-page) {
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
}

.encounter-workspace-page {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  height: 100%;
  max-height: calc(100vh - 105px);
  min-height: 0;
  overflow: hidden;
  gap: 8px;
}

.encounter-workspace-top {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.encounter-workspace-grid {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: grid;
  gap: 10px;
  align-items: stretch;
  transition: grid-template-columns 0.2s ease;
}

.encounter-soap-column {
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 6px;
}

.encounter-side-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.med-modal .modal-body, .modal-dialog .modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.med-modal .modal-footer, .modal-dialog .modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-elevated);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* Heuristic Correlation & Match Highlighting */
mark.heuristic-match {
  background: rgba(234, 179, 8, 0.28) !important;
  border-bottom: 2px solid #eab308 !important;
  color: #fef08a !important;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

:root[data-theme="light"] mark.heuristic-match {
  background: rgba(234, 179, 8, 0.22) !important;
  border-bottom: 2px solid #d97706 !important;
  color: #92400e !important;
}

.card-heuristic-connected {
  border-left: 3.5px solid #eab308 !important;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.08) 0%, rgba(20, 25, 40, 0.95) 100%) !important;
  box-shadow: 0 0 14px rgba(234, 179, 8, 0.25) !important;
}

:root[data-theme="light"] .card-heuristic-connected {
  border-left: 3.5px solid #d97706 !important;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, #ffffff 100%) !important;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.2) !important;
}

.badge-heuristic-match {
  background: rgba(234, 179, 8, 0.18);
  border: 1px solid #eab308;
  color: #fef08a;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

:root[data-theme="light"] .badge-heuristic-match {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid #d97706;
  color: #92400e;
}

/* Split-Screen Clinical Consultation */
.split-screen-container {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1200px) {
  .split-screen-container {
    grid-template-columns: 340px 1fr;
  }
}

/* Animated Glowing Neon Progress Bar (AI Working State) */
.neon-progress-container {
  width: 100%;
  height: 6px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 6px rgba(6, 182, 212, 0.25), 0 0 10px rgba(6, 182, 212, 0.2);
}

.neon-progress-bar-indeterminate {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, transparent, #22d3ee 30%, #818cf8 60%, #a855f7 90%, transparent);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.9), 0 0 8px rgba(168, 85, 247, 0.7);
  border-radius: 999px;
  animation: neonProgressSlide 1.3s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes neonProgressSlide {
  0% {
    left: -50%;
    width: 35%;
  }
  50% {
    left: 25%;
    width: 60%;
  }
  100% {
    left: 100%;
    width: 35%;
  }
}

/* Telehealth Dedicated Floating Window (Non-Modal, Draggable, Resizable, PiP) */
.telehealth-floating-window {
  position: fixed !important;
  z-index: 20000 !important;
  background: var(--bg-card) !important;
  border: 1.5px solid rgba(34, 211, 238, 0.85) !important;
  box-shadow: 0 0 24px rgba(6, 182, 212, 0.45), 0 12px 36px rgba(0, 0, 0, 0.75) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
}

.telehealth-floating-window.telehealth-normal {
  top: 75px;
  right: 30px;
  width: 640px;
  max-width: 92vw;
  height: 640px;
  max-height: 84vh;
  border-radius: 12px;
}

.telehealth-floating-window.telehealth-pip {
  bottom: 24px;
  right: 24px;
  top: auto;
  left: auto;
  width: 400px;
  height: 420px;
  max-height: 420px;
  border-radius: 12px;
}

.telehealth-floating-window.telehealth-minimized {
  bottom: 24px;
  right: 24px;
  top: auto;
  left: auto;
  width: 380px;
  height: 48px;
  max-height: 48px;
  border-radius: 24px;
  overflow: hidden;
  padding: 0;
}

.telehealth-resize-handle {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  color: var(--medical-cyan);
  -webkit-user-select: none;
  user-select: none;
}

/* Draggable Splitter between SOAP Charting and Prescriptions */
.soap-split-resizer {
  height: 10px;
  cursor: row-resize;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
  transition: all 0.2s ease;
  margin: -2px 0;
  padding: 2px 0;
}

.soap-split-resizer-line {
  width: 100%;
  height: 2px;
  background: var(--border-color);
  border-radius: 2px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.soap-split-resizer-pill {
  width: 48px;
  height: 6px;
  background: var(--border-color);
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.soap-split-resizer-dot {
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s ease;
}

.soap-split-resizer:hover .soap-split-resizer-line,
.soap-split-resizer:active .soap-split-resizer-line {
  background: rgba(34, 211, 238, 0.7);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

.soap-split-resizer:hover .soap-split-resizer-pill,
.soap-split-resizer:active .soap-split-resizer-pill {
  background: rgba(6, 182, 212, 0.3);
  border: 1px solid rgba(34, 211, 238, 0.85);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.45), inset 0 0 10px rgba(6, 182, 212, 0.18);
}

.soap-split-resizer:hover .soap-split-resizer-dot,
.soap-split-resizer:active .soap-split-resizer-dot {
  background: #22d3ee;
  box-shadow: 0 0 6px rgba(34, 211, 238, 0.9);
}

/* Draggable Splitter for Past Encounters Left Panel */
.left-panel-resizer {
  position: absolute;
  top: 0;
  right: -6px;
  width: 12px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
}

.left-panel-resizer-line {
  width: 4px;
  height: 48px;
  background: var(--border-color);
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.left-panel-resizer:hover .left-panel-resizer-line,
.left-panel-resizer:active .left-panel-resizer-line {
  background: rgba(34, 211, 238, 0.9);
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.6), inset 0 0 6px rgba(6, 182, 212, 0.3);
  height: 72px;
  width: 5px;
}

/* Integrated Searchable Select */
.searchable-select-container {
  width: 100%;
}
.searchable-select-trigger:hover {
  border-color: rgba(34, 211, 238, 0.6) !important;
}
.searchable-select-menu {
  background: var(--bg-card) !important; /* Fully opaque solid background using active theme token */
  border: var(--neon-border) !important;
  box-shadow: var(--shadow-lg), 0 0 16px rgba(6, 182, 212, 0.25) !important;
  color: var(--text-primary) !important;
  opacity: 1 !important;
}
.searchable-option-item {
  transition: background 0.15s ease, color 0.15s ease;
  color: var(--text-primary);
}
.searchable-option-item:hover {
  background: rgba(34, 211, 238, 0.14) !important;
  color: var(--medical-cyan) !important;
}
.selected-neon-option {
  border-left: 2px solid var(--medical-cyan) !important;
}

