/* ==========================================================================
   DoctorSaathi Sovereign Clinician Cockpit & EMR Theme
   Design System: Clinical Dark Glassmorphic, 60-30-10 Rule, Multi-device Responsive
   ========================================================================== */

:root {
  --bg-deep: #030712;
  --bg-surface: #0b1322;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(45, 212, 191, 0.5);

  --primary-base: #0a8270;
  --primary-glow: #2dd4bf;
  --primary-subtle: rgba(45, 212, 191, 0.12);

  --cyan: #38bdf8;
  --cyan-subtle: rgba(56, 189, 248, 0.12);
  --emerald: #10b981;
  --emerald-subtle: rgba(16, 185, 129, 0.12);
  --amber: #f59e0b;
  --amber-subtle: rgba(245, 158, 11, 0.12);
  --rose: #f43f5e;
  --rose-subtle: rgba(244, 63, 94, 0.12);

  --text-main: #f8fafc;
  --text-sub: #cbd5e1;
  --text-muted: #94a3b8;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Plus Jakarta Sans', var(--font-sans);
  --font-mono: 'JetBrains Mono', monospace;

  --header-height: 64px;
  --sidebar-width: 240px;
  --mobile-nav-height: 60px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}
::-webkit-scrollbar-thumb {
  background: rgba(51, 65, 85, 0.8);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-glow);
}

/* Top App Header */
.emr-header {
  height: var(--header-height);
  background: rgba(11, 19, 34, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.emr-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.emr-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 15px rgba(45, 212, 191, 0.3);
}

.emr-brand-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
}
.emr-brand-name span {
  color: var(--primary-glow);
}

.emr-brand-badge {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--primary-glow);
  letter-spacing: 1px;
}

/* Active Token Live Ticker in Header */
.active-token-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(45, 212, 191, 0.3);
  padding: 5px 14px;
  border-radius: 20px;
}

.token-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-glow);
  box-shadow: 0 0 10px var(--primary-glow);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.active-token-text {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.emr-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clinic-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  padding: 4px 10px;
  border-radius: 14px;
}

.doctor-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  padding: 4px 10px 4px 5px;
  border-radius: 20px;
  cursor: pointer;
}

.doctor-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.doctor-info-sm {
  text-align: left;
}

.doctor-name-sm {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.doctor-specialty-sm {
  font-size: 10px;
  color: var(--text-muted);
}

/* Layout Body */
.emr-app-body {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* Sidebar */
.emr-sidebar {
  width: var(--sidebar-width);
  background: rgba(11, 19, 34, 0.7);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 12px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.nav-group-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 0 10px 8px 10px;
}

.sidebar-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-sub);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sidebar-nav-item i {
  font-size: 15px;
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.sidebar-nav-item:hover i {
  color: var(--primary-glow);
}

.sidebar-nav-item.active {
  background: rgba(45, 212, 191, 0.12);
  color: var(--primary-glow);
  border: 1px solid rgba(45, 212, 191, 0.25);
}

.sidebar-nav-item.active i {
  color: var(--primary-glow);
}

.nav-counter {
  margin-left: auto;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(45, 212, 191, 0.2);
  color: var(--primary-glow);
}

/* Main Workspace Stage */
.emr-stage {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: radial-gradient(circle at 50% 0%, rgba(10, 130, 112, 0.08) 0%, transparent 60%);
}

.view-container {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.view-container.active-view {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cockpit Layouts */
.cockpit-stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(8px);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-pill:hover {
  transform: translateY(-2px);
  border-color: rgba(45, 212, 191, 0.3);
}

.stat-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.stat-num {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-pill.emergency-pill {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

/* Clinical Modules Grid */
.clinical-modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.module-card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
  border-color: var(--primary-glow);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.module-card-icon {
  font-size: 22px;
  margin-bottom: 8px;
}

.module-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 3px;
}

.module-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* 3-Column Desktop Cockpit Grid */
.cockpit-grid {
  display: grid;
  grid-template-columns: 290px 1.4fr 320px;
  gap: 14px;
  height: calc(100vh - var(--header-height) - 180px);
  min-height: 520px;
}

/* Cards & Containers */
.emr-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
}

.emr-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-glass);
}

.emr-card-title {
  font-family: var(--font-heading);
  font-size: 14.5px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Form Controls & Inputs */
.rx-input {
  width: 100%;
  background: rgba(3, 7, 18, 0.65);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 8px 12px;
  color: #ffffff;
  font-size: 13px;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.rx-input:focus {
  outline: none;
  border-color: var(--primary-glow);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
  background: rgba(3, 7, 18, 0.9);
}

.rx-input::placeholder {
  color: #64748b;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Buttons */
.btn-emr {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-emr-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-emr-primary {
  background: var(--primary-base);
  color: #ffffff;
  border-color: var(--primary-glow);
}

.btn-emr-primary:hover {
  background: #086b5c;
  box-shadow: 0 0 15px rgba(45, 212, 191, 0.4);
}

.btn-emr-outline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-glass);
}

.btn-emr-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.btn-icon-emr {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-emr:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--primary-glow);
}

/* Vitals Matrix Row */
.rx-vitals-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 10px 0 14px 0;
}

.vital-box {
  background: rgba(3, 7, 18, 0.5);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 6px 10px;
  text-align: center;
}

.vital-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.vital-value {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  margin-top: 2px;
}

.vitals-input-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

/* Prescriptions & Tables */
.rx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0;
}

.rx-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-glass);
}

.rx-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.savings-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* Badges */
.badge-status {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.badge-risk {
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.badge-risk-high {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-risk-mod {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-risk-low {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

/* Modals */
.emr-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.emr-modal-box {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  width: 90%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}

.emr-modal-head {
  padding: 14px 20px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.emr-modal-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #ffffff;
}

.emr-modal-body {
  overflow-y: auto;
  flex: 1;
}

.emr-modal-foot {
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.85);
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Directory Toolbar & Tabs */
.directory-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.dir-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dir-filter-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 16px 0;
  overflow-x: auto;
}

.dir-tab {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 6px 14px;
  color: var(--text-sub);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.dir-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.dir-tab.active {
  background: rgba(45, 212, 191, 0.15);
  border-color: var(--primary-glow);
  color: var(--primary-glow);
}

/* Patients Grid */
.patients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.patient-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

.patient-card:hover {
  border-color: rgba(45, 212, 191, 0.4);
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}

.patient-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.p-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(45, 212, 191, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.p-main-info {
  flex: 1;
}

.p-name {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.p-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.p-abha {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--primary-glow);
  margin-top: 2px;
}

.patient-card-vitals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 10px 0;
  background: rgba(3, 7, 18, 0.4);
  padding: 6px;
  border-radius: 6px;
}

.v-mini {
  text-align: center;
}

.v-mini-lbl {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 700;
}

.v-mini-val {
  font-size: 11.5px;
  font-weight: 800;
  color: #ffffff;
}

.patient-card-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.condition-chip {
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--text-sub);
}

.patient-card-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.p-phone {
  font-size: 11.5px;
  color: var(--text-muted);
}

.p-actions {
  display: flex;
  gap: 6px;
}

/* Dossier Modal Tabs */
.dossier-tab-bar {
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--border-glass);
  overflow-x: auto;
}

.dossier-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.dossier-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.dossier-tab.active {
  color: var(--primary-glow);
  background: rgba(45, 212, 191, 0.12);
}

.dossier-tab-panel {
  display: none;
}

.dossier-tab-panel.active {
  display: block;
}

.vitals-matrix-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.v-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.v-card-lbl {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.v-card-val {
  font-size: 16px;
  font-weight: 800;
  margin: 4px 0 2px 0;
}

.v-card-sub {
  font-size: 9.5px;
  color: #64748b;
}

/* Kanban Queue Grid */
.queue-kanban-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.queue-col {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.queue-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 8px;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-glass);
}

.queue-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.empty-q-col {
  padding: 30px 10px;
  text-align: center;
  color: #64748b;
  font-size: 12px;
}

.q-ticket-card {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 12px;
  transition: all 0.2s ease;
}

.q-ticket-card.active-ticket {
  border-color: var(--primary-glow);
  box-shadow: 0 0 20px rgba(45, 212, 191, 0.2);
  background: rgba(45, 212, 191, 0.08);
}

.q-ticket-card.emergency-ticket {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.q-token-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 900;
  color: #ffffff;
}

/* Analytics */
.analytics-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 14px;
}

.metric-lbl {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.metric-val {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 900;
  margin: 4px 0;
}

.metric-sub {
  font-size: 11px;
  color: #64748b;
}

.charts-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.diagnosis-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.diag-name {
  width: 150px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diag-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.diag-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.diag-pct {
  width: 32px;
  text-align: right;
  font-weight: 700;
  color: #ffffff;
}

.hourly-bar {
  flex: 1;
  background: linear-gradient(to top, rgba(45, 212, 191, 0.2), #2dd4bf);
  border-radius: 4px 4px 0 0;
  position: relative;
  display: flex;
  justify-content: center;
}

.bar-lbl {
  position: absolute;
  bottom: -20px;
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Call Control Buttons */
.call-ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.call-ctrl-btn.active {
  background: var(--primary-glow);
  color: #020617;
}

.call-ctrl-btn.end-call-btn {
  background: #dc2626;
  border-color: #ef4444;
}

.call-ctrl-btn.end-call-btn:hover {
  background: #b91c1c;
}

/* Mobile Bottom Navigation Bar */
.mobile-nav-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--mobile-nav-height);
  background: rgba(11, 19, 34, 0.95);
  backdrop-filter: blur(15px);
  border-top: 1px solid var(--border-glass);
  z-index: 1000;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-decoration: none;
  padding: 4px;
  flex: 1;
}

.mobile-nav-item i {
  font-size: 17px;
  margin-bottom: 2px;
}

.mobile-nav-item.active {
  color: var(--primary-glow);
}

/* ==========================================================================
   Responsive Breakpoints: Laptop, Tablet & Mobile Phone
   ========================================================================== */

/* Laptop / Desktop Wide (max-width: 1200px) */
@media (max-width: 1200px) {
  .cockpit-grid {
    grid-template-columns: 260px 1.2fr 280px;
  }
}

/* Tablet Layout (max-width: 1024px) */
@media (max-width: 1024px) {
  .emr-sidebar {
    width: 70px;
    padding: 16px 8px;
  }
  .emr-sidebar .nav-group-title,
  .emr-sidebar .sidebar-nav-item span,
  .emr-sidebar .nav-counter,
  .emr-sidebar > div:last-child {
    display: none;
  }
  .emr-sidebar .sidebar-nav-item {
    justify-content: center;
    padding: 12px 0;
  }
  .emr-sidebar .sidebar-nav-item i {
    font-size: 18px;
    width: auto;
  }

  .cockpit-grid {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: visible;
  }
  .charts-2col {
    grid-template-columns: 1fr;
  }
  .queue-kanban-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile Phone Layout (max-width: 768px) */
@media (max-width: 768px) {
  .emr-sidebar {
    display: none;
  }
  .mobile-nav-bar {
    display: flex;
  }
  .emr-app-body {
    height: calc(100vh - var(--header-height) - var(--mobile-nav-height));
  }
  .emr-stage {
    padding: 12px;
  }
  .active-token-pill {
    padding: 4px 8px;
  }
  .active-token-text {
    font-size: 11px;
  }
  .doctor-profile-badge .doctor-info-sm {
    display: none;
  }
  .rx-vitals-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
  .vitals-matrix-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .directory-top-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .dir-actions {
    justify-content: space-between;
  }
}

/* ==========================================================================
   Dual-Printer Print Stylesheet (@media print)
   Supports A4 Laser Letterhead & 80mm/58mm Thermal POS Receipt Printers
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt;
    line-height: 1.35;
  }

  .emr-header,
  .emr-sidebar,
  .mobile-nav-bar,
  .btn-emr,
  .btn-icon-emr,
  .modal-close-btn,
  .emr-modal-foot,
  .emr-modal-head,
  .savings-chip,
  #emrToast {
    display: none !important;
  }

  .emr-modal-backdrop {
    position: static !important;
    background: #ffffff !important;
    padding: 0 !important;
  }

  .emr-modal-box {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
  }

  #printModal {
    display: block !important;
    position: static !important;
    background: #ffffff !important;
    box-shadow: none !important;
  }

  #printModalBody {
    padding: 0 !important;
  }

  /* Prevent awkward page cuts in table rows & signature blocks */
  table, tr, td, th, .history-section, .alert-item, .vitals-matrix-row {
    page-break-inside: avoid !important;
  }

  /* Thermal Receipt Mode */
  .thermal-receipt-mode {
    width: 80mm !important;
    max-width: 80mm !important;
    margin: 0 auto !important;
    font-size: 10pt !important;
    font-family: 'Courier New', monospace !important;
  }

  /* Sharp pure-black contrast */
  h1, h2, h3, h4, strong, b, td, th, div, span, p {
    color: #000000 !important;
  }
}

/* Accessibility Focus States (WCAG 2.1 AA) */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary-glow) !important;
  outline-offset: 2px !important;
}

/* Screen Reader Only Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}


/* Appended Cloud Sync & Quick Clinical Chips */
.emr-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 50px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  user-select: none;
}
.emr-sync-badge:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(45, 212, 191, 0.4);
}
.emr-sync-badge.synced {
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.25);
}
.emr-sync-badge.syncing {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.25);
}
.emr-sync-badge.offline {
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.2);
}
.emr-sync-badge.error {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.25);
}

.quick-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.quick-chip:hover {
  background: rgba(45, 212, 191, 0.2);
  border-color: rgba(45, 212, 191, 0.5);
  color: #2dd4bf;
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .emr-sync-badge .sync-label {
    display: none !important;
  }
}

/* ==========================================================================
   Slide-Over Drawer & Completed Patient Styling
   ========================================================================== */
.slideover-drawer {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  justify-content: flex-end;
}
.slideover-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 29, 0.65);
  backdrop-filter: blur(4px);
}
.slideover-panel {
  position: relative;
  width: 55vw;
  min-width: 360px;
  max-width: 820px;
  height: 100vh;
  background: #0b1329;
  border-left: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: -15px 0 35px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  z-index: 2;
  overflow: hidden;
  transform: translateX(0);
  animation: slideInRight 0.2s ease-out;
}
@keyframes slideInRight {
  from { transform: translateX(50px); opacity: 0.8; }
  to { transform: translateX(0); opacity: 1; }
}
@media (max-width: 900px) {
  .slideover-panel {
    width: 85%;
    min-width: 320px;
  }
}

/* Completed & Archived Patient Record Styling */
.q-ticket-card.completed-dimmed,
.patient-row-completed {
  opacity: 0.42 !important;
  filter: grayscale(45%) !important;
  background: rgba(15, 23, 42, 0.45) !important;
  border: 1px dashed #475569 !important;
  transition: all 0.25s ease;
}
.q-ticket-card.completed-dimmed:hover,
.patient-row-completed:hover {
  opacity: 0.75 !important;
  filter: grayscale(10%) !important;
}

/* ==========================================================================
   Clinical Quick Tools Ribbon & Master Patient Worklist Table (Front View)
   ========================================================================== */
.clinical-quick-tools-ribbon {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  margin-bottom: 14px;
}
.quick-tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.quick-tool-pill:hover {
  background: rgba(45, 212, 191, 0.15);
  border-color: rgba(45, 212, 191, 0.4);
  color: #2dd4bf;
  transform: translateY(-1px);
}
.quick-tool-pill i {
  font-size: 12.5px;
}

.doc-worklist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}
.doc-worklist-table thead th {
  background: rgba(15, 23, 42, 0.95);
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}
.doc-worklist-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
  background: rgba(15, 23, 42, 0.4);
}
.doc-worklist-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.5);
}
.doc-worklist-table tbody td {
  padding: 12px 14px;
  vertical-align: middle;
}
.doc-worklist-table tr.active-row {
  border-left: 3.5px solid #10b981;
}
.doc-worklist-table tr.emergency-row {
  border-left: 3.5px solid #ef4444;
}
.doc-worklist-table tr.completed-row {
  opacity: 0.45;
  border-left: 3.5px solid #64748b;
  background: rgba(15, 23, 42, 0.25);
}
}
