/* MedFlow HIS — Design System & Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colors */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #38bdf8;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;

  --accent-teal: #0d9488;
  --accent-teal-light: #ccfbf1;

  --danger: #e11d48;
  --danger-light: #ffe4e6;
  --danger-dark: #9f1239;

  --warning: #d97706;
  --warning-light: #fef3c7;

  --success: #16a34a;
  --success-light: #dcfce7;

  --urgent-pulse: #f43f5e;
  --header-bg: #0f172a;
  --header-text: #f8fafc;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.15s ease;
}
a:hover {
  color: var(--primary-hover);
}

/* Header & Navigation */
.navbar {
  background-color: var(--header-bg);
  color: var(--header-text);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 0 15px rgba(2, 132, 199, 0.4);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-item {
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}
/* Un boton dentro de la barra: el navegador le pone fondo, borde y su propia
   tipografia, asi que hay que devolverlo al aspecto de los enlaces vecinos. */
.nav-item-boton {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-item:hover, .nav-item.active {
  color: white;
  background-color: rgba(255, 255, 255, 0.08);
}

.nav-lis-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.3);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: #38bdf8;
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Layout */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Hero & Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.page-title-group h1 {
  font-size: 1.75rem;
  color: #0f172a;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

/* Metric Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.metric-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}
.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Service Badges & Filter Tabs */
.filter-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.85rem;
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.filter-tab:hover, .filter-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Grid of Beds / Boxes */
.boxes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.box-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: all 0.2s ease;
}
.box-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.box-card.reanimacion {
  border-left: 5px solid var(--danger);
}
.box-card.urgencias {
  border-left: 5px solid var(--primary);
}
.box-card.uci {
  border-left: 5px solid #8b5cf6;
}
.box-card.hospitalizados {
  border-left: 5px solid var(--accent-teal);
}
.box-card.disponible {
  background: #f8fafc;
  border-style: dashed;
  opacity: 0.85;
}

.box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.box-title {
  font-size: 1.05rem;
  font-weight: 700;
}
.box-service {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.badge-reanimacion { background: var(--danger-light); color: var(--danger-dark); }
.badge-urgencias { background: var(--primary-light); color: var(--primary); }
.badge-uci { background: #ede9fe; color: #6d28d9; }
.badge-hosp { background: var(--accent-teal-light); color: var(--accent-teal); }
.badge-disponible { background: #f1f5f9; color: #64748b; }

.patient-info-snippet {
  margin-bottom: 1rem;
}
.patient-name-box {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.15rem;
}
.patient-meta-box {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
}

.diagnosis-box {
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.825rem;
  color: #334155;
  margin-bottom: 1rem;
  border-left: 3px solid #64748b;
}

.card-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f5f9;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}
.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  color: white;
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}
.btn-danger:hover {
  background-color: var(--danger-dark);
}

.btn-outline {
  background-color: white;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

/* Ficha del Paciente */
.ficha-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 1024px) {
  .ficha-layout {
    grid-template-columns: 1fr;
  }
}

.patient-banner {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.patient-banner-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.patient-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

.patient-banner-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
}
.patient-banner-tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}
.tag-rut { background: #f1f5f9; color: #334155; }
.tag-age { background: #f1f5f9; color: #334155; }
.tag-allergy { background: var(--danger-light); color: var(--danger-dark); font-weight: 700; }
.tag-location { background: #e0f2fe; color: #0369a1; font-weight: 700; }

/* Clinical Sections */
.clinical-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.card-title-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title-header h2 {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.clinical-text-block {
  margin-bottom: 1rem;
}
.clinical-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.clinical-val {
  font-size: 0.9rem;
  color: #1e293b;
  line-height: 1.45;
}

/* Exam Selector Presets */
.preset-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.btn-preset {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-preset:hover {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0369a1;
}

.exam-checklist-area {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.exam-check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: white;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}
.exam-check-item:hover {
  border-color: var(--primary);
  background: #f0f9ff;
}

.exam-check-info {
  display: flex;
  flex-direction: column;
}
.exam-check-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}
.exam-check-sub {
  font-size: 0.725rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.35rem;
}

/* Results Table */
.results-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}

.results-table th {
  background: #f8fafc;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 2px solid var(--border-color);
}

.results-table td {
  padding: 0.75rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #f1f5f9;
}

.results-table tr:hover td {
  background-color: #f8fafc;
}

/* Flag badges */
.flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

.flag-normal {
  background: var(--success-light);
  color: var(--success);
}
.flag-high {
  background: var(--warning-light);
  color: var(--warning);
}
.flag-low {
  background: #eff6ff;
  color: #1d4ed8;
}
.flag-critical {
  background: var(--danger);
  color: white;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(225, 29, 72, 0.4);
  animation: pulse-danger 1.5s infinite;
}

@keyframes pulse-danger {
  0% { opacity: 0.9; }
  50% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0.9; }
}

/* Modal for Interop Viewer */
.interop-code-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  max-height: 400px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ==========================================================================
   NUEVOS ESTILOS: SEPARACIÓN ESTUDIANTE VS DOCENTE & PANEL DE SIMULACIÓN
   ========================================================================== */

/* Role Selector in Navbar */
.role-selector-container {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.25rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
  gap: 0.25rem;
}

.role-pill {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.role-pill:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.role-pill.active-estudiante {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.role-pill.active-docente {
  background: #6366f1;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* Censo Hero Header */
.censo-hero-header {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.badge-hospital-service {
  background: #0284c7;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-tubo {
  background: #f1f5f9;
  color: #334155;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

.badge-loinc {
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

.badge-role-docente {
  background: #6366f1;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
}

/* Panel Docente Container */
.panel-docente-container {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  border: 1px solid #4338ca;
  border-radius: var(--radius-lg);
  color: #f8fafc;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.4);
}

.panel-docente-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
}

.panel-docente-body {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 1.25rem;
}

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

.docente-cronometro-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.timer-display {
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 800;
  color: #38bdf8;
  line-height: 1;
  margin: 0.5rem 0 0.25rem 0;
  letter-spacing: 0.05em;
  text-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.timer-phase {
  font-size: 0.78rem;
  color: #cbd5e1;
  margin-bottom: 0.85rem;
  font-weight: 500;
}

.timer-controls {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.timeline-steps {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

.timeline-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #94a3b8;
}

.timeline-step.active {
  color: #38bdf8;
  font-weight: 600;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.timeline-step.active .step-dot {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

.docente-guia-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.checklist-rubrica {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rubrica-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #cbd5e1;
  line-height: 1.4;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.rubrica-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.rubrica-check {
  margin-top: 0.15rem;
  accent-color: #10b981;
  width: 15px;
  height: 15px;
}

/* Docente Ficha Box */
.docente-ficha-box {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  border: 1px solid #6366f1;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: #f8fafc;
  box-shadow: var(--shadow-md);
}

/* Flash alerts */
.flash-alert {
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  margin: 1rem 1.5rem 0 1.5rem;
  display: flex;
  align-items: center;
}

.flash-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.flash-danger {
  background: #ffe4e6;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.main-footer {
  margin-top: auto;
  padding: 1.5rem 1.5rem;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  color: #64748b;
  font-size: 0.8rem;
}

/* ==========================================================================
   HOSPITAL BLUEPRINT & INTERACTIVE FLOOR PLAN (PLANO ARQUITECTÓNICO)
   ========================================================================== */

/* Selector de Modo de Vista (Plano vs. Tarjetas) */
.view-mode-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.view-mode-toggle {
  display: inline-flex;
  background: #ffffff;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  gap: 0.25rem;
}

.btn-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-view-toggle:hover {
  color: var(--text-main);
  background: #f1f5f9;
}

.btn-view-toggle.active {
  background: var(--header-bg);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* Contenedor Maestro del Plano Hospitalario */
.hospital-blueprint-container {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

/* Encabezado del Plano */
.blueprint-top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 2px dashed #e2e8f0;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.blueprint-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.blueprint-badge {
  background: #0284c7;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
}

.blueprint-legend {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.occupied { background: #0284c7; }
.legend-dot.urgent { background: #e11d48; animation: pulse-urgent 1.5s infinite; }
.legend-dot.available { background: #10b981; }

/* Separa los dos sistemas de la leyenda: a la izquierda el estado de la unidad
   (punto), a la derecha el aislamiento del paciente (píldora). Antes los
   aislamientos estaban en pantalla con color propio y sin explicar. */
.legend-separator {
  width: 1px;
  height: 14px;
  background: #cbd5e1;
  margin: 0 0.35rem;
}

/* En la leyenda la píldora va sin texto: solo muestra el color y el ícono. */
.blueprint-legend .isolation-badge-pill {
  margin-bottom: 0;
  padding: 0.1rem 0.3rem;
}

/* Grid de Unidades / Alas del Hospital */
.hospital-wings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Ala Hospitalaria (Wing Container) */
.hospital-wing {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hospital-wing:hover {
  border-color: #94a3b8;
  box-shadow: var(--shadow-sm);
}

/* Un solo significado por paleta.
 *
 * El estado es lo único que se lee sin texto —es un punto—, así que se reserva
 * el azul/rojo/verde de la leyenda y nadie más los usa. El servicio ya se
 * identifica por su ícono y su nombre; cuando además tenía color propio, el
 * ala "Toma de Muestras" usaba #0284c7, exactamente el mismo azul que el punto
 * de "Ocupado". Dos cosas distintas, el mismo color, en la misma pantalla.
 *
 * La categoría la lleva la forma: punto = estado, píldora = aislamiento. */
.hospital-wing.wing-toma,
.hospital-wing.wing-pediatria,
.hospital-wing.wing-mq {
  border-top: 5px solid #94a3b8;
  background: linear-gradient(180deg, #f8fafc 0%, #f8fafc 40%);
}

.wing-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.wing-title {
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.wing-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.15rem;
}

/* La línea del guion docente es material fuera de la ficción: rondas, grupos y
   estaciones. Se marca visualmente para que el docente vea de un golpe qué está
   viendo él y no el estudiante. */
.wing-guion {
  color: #6d28d9;
  background: #f5f3ff;
  border-left: 3px solid #a78bfa;
  padding: 0.2rem 0.45rem;
  margin-top: 0.3rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-weight: 600;
}

.wing-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.wing-toma .wing-tag,
.wing-pediatria .wing-tag,
.wing-mq .wing-tag { background: #f1f5f9; color: #475569; }

/* Distribución de Habitaciones / Boxes dentro del Ala */
.rooms-in-wing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  flex: 1;
}

/* Habitación Arquitectónica (Room Box) */
.architectural-room {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 180px;
  text-decoration: none;
  color: inherit;
}

.architectural-room:hover {
  transform: translateY(-3px);
  border-color: #0284c7;
  box-shadow: var(--shadow-md);
}

/* Puerta / Acceso Arquitectónico */
.room-door-indicator {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 8px;
  background: #cbd5e1;
  border-radius: 4px;
  border: 1px solid #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.room-door-indicator::after {
  content: '';
  width: 16px;
  height: 2px;
  background: #ffffff;
}

/* Cabecera de la Habitación */
.room-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.room-code-tag {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.78rem;
  color: #1e293b;
}

.room-status-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
}

.room-status-badge.occupied {
  background: #0284c7;
}

.room-status-badge.urgent-order {
  background: #e11d48;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.25);
  animation: pulse-urgent 1.5s infinite;
}

@keyframes pulse-urgent {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(225, 29, 72, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}

/* Área del Paciente Internado */
.room-patient-summary {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.room-patient-name {
  font-weight: 800;
  font-size: 0.85rem;
  color: #0f172a;
  line-height: 1.25;
}

.room-patient-rut {
  font-size: 0.7rem;
  color: #64748b;
  font-family: var(--font-mono);
  font-weight: 600;
}

.room-diagnosis-chip {
  font-size: 0.7rem;
  color: #334155;
  background: #f1f5f9;
  padding: 0.3rem 0.45rem;
  border-radius: 4px;
  line-height: 1.3;
  border-left: 3px solid #0284c7;
  margin-top: 0.25rem;
}

/* Campos de formulario.
 *
 * No habia ningun estilo para label ni input, asi que caian en el
 * comportamiento por defecto del navegador —ambos en linea— y las pantallas de
 * acceso salian con la etiqueta pegada al campo y anchos distintos. */
.card-body label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted, #64748b);
  margin-bottom: 0.3rem;
}

.card-body input[type="text"],
.card-body input[type="password"],
.card-body input[type="email"] {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.9rem;
  font: inherit;
  color: #1e293b;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card-body input[type="text"]:focus,
.card-body input[type="password"]:focus,
.card-body input[type="email"]:focus {
  outline: none;
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Insignias de Aislamiento Preventivo */
.isolation-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.35rem;
  width: fit-content;
}

.isolation-gotitas {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.isolation-contacto {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.isolation-protector {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* Estado de Orden de Laboratorio en el Room */
.room-lab-status {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e0f2fe;
  color: #0369a1;
  margin-top: auto;
  border: 1px solid #bae6fd;
}

.room-lab-status.stat {
  background: #ffe4e6;
  color: #be123c;
  border-color: #fecdd3;
}

/* Habitación Disponible / Vacía */
.room-available-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  padding: 1rem 0;
  color: var(--text-muted);
}

.room-available-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.room-available-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: #10b981;
}

/* Pasillo Hospitalario Central y Conector LIS */
.hospital-central-hallway {
  background: #f1f5f9;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  position: relative;
}

.hallway-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
}

.hallway-direction {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
}

.hallway-lis-hub {
  background: #0f172a;
  color: #ffffff;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: background 0.15s ease;
}

/* ==========================================================================
   ILUSTRACIÓN VISUAL DE CAMAS CLÍNICAS, MONITORES Y AVATARES (HYPERREALISM)
   ========================================================================== */

/* Contenedor Gráfico de la Cama y Monitor dentro del Box */
.room-graphic-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  margin-bottom: 0.65rem;
  gap: 0.5rem;
}

/* Ilustración de Cama Clínica (SVG/CSS) */
.clinical-bed-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.bed-frame-svg {
  width: 46px;
  height: 32px;
  flex-shrink: 0;
}

.avatar-portrait {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: #e0f2fe;
  border: 2px solid #bae6fd;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.avatar-portrait.pediatrico {
  background: #ccfbf1;
  border-color: #99f6e4;
}

.avatar-portrait.geriatrico {
  background: #e0e7ff;
  border-color: #c7d2fe;
}

.avatar-portrait.onco {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Monitor de Signos Vitales Multiparámetro */
.vital-monitor-screen {
  background: #0f172a;
  border: 1.5px solid #334155;
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 82px;
  height: 40px;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

.monitor-wave-row {
  display: flex;
  align-items: center;
  height: 14px;
  overflow: hidden;
}

.ecg-svg {
  width: 100%;
  height: 12px;
}

.ecg-path {
  fill: none;
  stroke: #22c55e;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.monitor-vitals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

.monitor-hr { color: #22c55e; }
.monitor-sat { color: #38bdf8; }

/* Umbral y Triage en la Puerta del Box */
.triage-door-tag {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.triage-c1 {
  background: #ffe4e6;
  color: #be123c;
  border: 1px solid #fecdd3;
  animation: pulse-urgent 1.5s infinite;
}

.triage-c2 {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.triage-c3 {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fef08a;
}

