/* HeartenQA Chile - Main Stylesheet (Vanilla CSS) */

/* CSS Variables & Theme System */
:root {
  /* Colors */
  --teal-primary: #0f766e;
  --teal-hover: #0d9488;
  --teal-dark: #115e59;
  --teal-light: #f0fdfa;
  --teal-glow: rgba(15, 118, 110, 0.15);
  
  --emerald-success: #059669;
  --emerald-light: #ecfdf5;
  --emerald-border: #a7f3d0;
  
  --amber-warning: #d97706;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;
  
  --red-danger: #e11d48;
  --red-light: #fff1f2;
  --red-border: #fecdd3;
  --red-glow: rgba(225, 29, 72, 0.15);

  --slate-bg: #f8fafc;
  --slate-card: #ffffff;
  --slate-text: #0f172a;
  --slate-secondary: #64748b;
  --slate-border: #e2e8f0;
  --slate-hover: #f1f5f9;

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Shadows & Radius */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;

  /* Layout */
  --sidebar-width: 280px;
  --header-height: 80px;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--slate-bg);
  color: var(--slate-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--slate-text);
}

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--slate-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--slate-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--slate-secondary);
}

/* App Container Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation (Mobile First: Hidden Drawer) */
.sidebar {
  width: var(--sidebar-width);
  background-color: #0f172a; /* Sleek dark slate blue */
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Backdrop (Mobile Drawer) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.menu-open .sidebar {
  transform: translateX(0);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
}

body.menu-open .sidebar-backdrop {
  display: block;
  opacity: 1;
}

.btn-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--slate-card);
  border: 1px solid var(--slate-border);
  color: var(--slate-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-menu-toggle:hover {
  background-color: var(--slate-hover);
  color: var(--slate-text);
}

.btn-menu-toggle svg {
  width: 24px;
  height: 24px;
}

.header-title-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background-color: var(--teal-primary);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--teal-glow);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
}

.brand-text h1 {
  font-size: 1.25rem;
  color: #fff;
  line-height: 1.2;
}

.brand-text h1 span {
  color: var(--teal-hover);
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--slate-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.sidebar-menu {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.menu-icon {
  width: 20px;
  height: 20px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.menu-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.menu-item:hover .menu-icon {
  opacity: 1;
}

.menu-item.active {
  background-color: var(--teal-primary);
  color: #fff;
}

.menu-item.active .menu-icon {
  opacity: 1;
}

.sidebar-legal-footer {
  padding: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background-color: rgba(0, 0, 0, 0.1);
  text-align: center;
}

.legal-badge {
  display: inline-block;
  background-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.sidebar-legal-footer p {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* Main Content Panel (Mobile First: Full Width) */
.main-content {
  margin-left: 0;
  width: 100%;
  flex-grow: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Bar */
.main-header {
  height: var(--header-height);
  background-color: var(--slate-card);
  border-bottom: 1px solid var(--slate-border);
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.header-title-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--slate-text);
}

.text-secondary {
  color: var(--slate-secondary);
  font-size: 0.875rem;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.date-badge {
  background-color: var(--slate-bg);
  border: 1px solid var(--slate-border);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-secondary);
}

/* View Viewport Container */
.view-viewport {
  padding: 40px;
  flex-grow: 1;
}

/* SPA View Section Transitions */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease-in-out forwards;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Card Component */
.card {
  background-color: var(--slate-card);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--slate-border);
}

.card-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 8px;
}

.btn-primary {
  background-color: var(--teal-primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--teal-hover);
  box-shadow: 0 0 10px rgba(15, 118, 110, 0.2);
}

.btn-secondary {
  background-color: var(--slate-bg);
  border: 1px solid var(--slate-border);
  color: var(--slate-secondary);
}

.btn-secondary:hover {
  background-color: var(--slate-hover);
  color: var(--slate-text);
  border-color: #cbd5e1;
}

.btn-danger {
  background-color: var(--red-light);
  color: var(--red-danger);
  border: 1px solid var(--red-border);
}

.btn-danger:hover {
  background-color: var(--red-danger);
  color: #fff;
}

.btn-success {
  background-color: var(--emerald-success);
  color: #fff;
}

.btn-success:hover {
  background-color: #047857;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* KPI Metrics Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.kpi-card {
  background-color: var(--slate-card);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-icon-wrapper {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background-color: var(--kpi-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-wrapper svg {
  width: 26px;
  height: 26px;
}

.pulsing-card-icon {
  animation: softPulse 2s infinite ease-in-out;
}

@keyframes softPulse {
  0% {
    box-shadow: 0 0 0 0 var(--red-glow);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(225, 29, 72, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0);
  }
}

.kpi-data {
  display: flex;
  flex-direction: column;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-heading);
  line-height: 1.1;
  color: var(--slate-text);
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--slate-secondary);
  margin-top: 4px;
  font-weight: 500;
}

.text-danger {
  color: var(--red-danger) !important;
}

/* Dashboard Filter Bar */
.search-filter-bar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.search-filter-large-bar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.search-input-wrapper {
  width: 100%;
}

.filter-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* Form Controls & Inputs */
.form-input {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--slate-text);
  background-color: #fff;
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.15s ease;
}

.form-input:focus {
  border-color: var(--teal-primary);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.form-input-small {
  width: 100px;
  display: inline-block;
  text-align: center;
}

.input-suffix {
  margin-left: 8px;
  font-size: 0.9rem;
  color: var(--slate-secondary);
  font-weight: 600;
}

.form-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.form-field-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-secondary);
}

.required {
  display: none !important;
}

.input-hint {
  font-size: 0.75rem;
  color: var(--slate-secondary);
  margin-top: 2px;
}

.error-msg {
  display: none;
  color: var(--red-danger);
  font-size: 0.8rem;
  margin-top: 4px;
  font-weight: 500;
}

/* Validation Style rules as per modern guidance */
/* Target only inputs that are invalid AFTER the user interacts or submits */
input:user-invalid, select:user-invalid, textarea:user-invalid,
input.user-invalid-fallback, select.user-invalid-fallback, textarea.user-invalid-fallback {
  border-color: var(--red-danger);
  background-color: var(--red-light);
}

input:user-invalid + .error-msg, select:user-invalid + .error-msg,
input.user-invalid-fallback + .error-msg, select.user-invalid-fallback + .error-msg {
  display: block;
}

input:user-valid, select:user-valid,
input.user-valid-fallback, select.user-valid-fallback {
  border-color: var(--emerald-success);
}

/* Table Style */
.table-scroll-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-border);
}

.clinical-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.clinical-table th {
  background-color: var(--slate-bg);
  padding: 14px 18px;
  font-weight: 600;
  color: var(--slate-secondary);
  border-bottom: 1.5px solid var(--slate-border);
}

.clinical-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--slate-border);
  vertical-align: middle;
  color: var(--slate-text);
}

.clinical-table tbody tr:hover {
  background-color: var(--slate-hover);
}

.clinical-table tbody tr:last-child td {
  border-bottom: none;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.empty-state-row td {
  padding: 40px;
  color: var(--slate-secondary);
  font-style: italic;
}

/* Badge Styles */
.risk-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}

.badge-bajo {
  background-color: var(--emerald-light);
  color: var(--emerald-success);
  border: 1px solid var(--emerald-border);
}

.badge-medio {
  background-color: var(--amber-light);
  color: var(--amber-warning);
  border: 1px solid var(--amber-border);
}

.badge-alto {
  background-color: var(--red-light);
  color: var(--red-danger);
  border: 1px solid var(--red-border);
}

.badge-type {
  background-color: var(--slate-hover);
  color: var(--slate-secondary);
  border: 1px solid var(--slate-border);
  font-weight: 600;
}

/* Form Wizard Layout styling */
.form-wizard-layout {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 32px;
  align-items: start;
}

.wizard-container {
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

/* Form Wizard Progress Indicators */
.wizard-steps-indicator {
  display: flex;
  justify-content: space-between;
  margin-bottom: 36px;
  position: relative;
}

.wizard-steps-indicator::before {
  content: '';
  position: absolute;
  height: 3px;
  background-color: var(--slate-border);
  top: 18px;
  left: 20px;
  right: 20px;
  z-index: 1;
}

.step-indicator {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.step-num {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: #fff;
  border: 3px solid var(--slate-border);
  color: var(--slate-secondary);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.step-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate-secondary);
  transition: all 0.3s ease;
  text-align: center;
}

.step-indicator.active .step-num {
  border-color: var(--teal-primary);
  background-color: var(--teal-primary);
  color: #fff;
  box-shadow: 0 0 10px var(--teal-glow);
}

.step-indicator.active .step-text {
  color: var(--teal-primary);
  font-weight: 700;
}

.step-indicator.completed .step-num {
  border-color: var(--emerald-success);
  background-color: var(--emerald-success);
  color: #fff;
}

.step-indicator.completed .step-text {
  color: var(--emerald-success);
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

/* Wizard Panels switcher */
.wizard-step-panel {
  display: none;
  animation: panelFade 0.25s ease-in-out;
}

.wizard-step-panel.active {
  display: block;
}

@keyframes panelFade {
  from { opacity: 0; transform: translateX(15px); }
  to { opacity: 1; transform: translateX(0); }
}

.panel-section-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--slate-text);
  margin-bottom: 24px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--teal-primary);
  display: inline-block;
}

/* Question Rows */
.questionnaire-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-divider {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--teal-primary);
  border-bottom: 1px solid var(--slate-border);
  padding-bottom: 6px;
  margin-top: 15px;
}

.question-row {
  background-color: var(--slate-bg);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.question-row:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.question-text {
  font-size: 0.95rem;
  color: var(--slate-text);
}

.question-text strong {
  color: var(--slate-text);
}

.question-help {
  display: block;
  font-size: 0.8rem;
  color: var(--slate-secondary);
  margin-top: 2px;
}

.question-options {
  display: flex;
  gap: 16px;
}

.question-options-input {
  display: flex;
  align-items: center;
}

/* Custom Radio Cards */
.radio-card {
  flex: 1;
  cursor: pointer;
}

.radio-card input {
  display: none;
}

.radio-card span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background-color: #fff;
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--slate-secondary);
  transition: all 0.15s ease;
}

.radio-card input:checked + span {
  background-color: var(--teal-primary);
  color: #fff;
  border-color: var(--teal-primary);
  box-shadow: 0 2px 4px var(--teal-glow);
}

/* Detail fields reveal */
.detail-field {
  display: none;
  animation: collapseOpen 0.2s ease forwards;
  margin-top: 6px;
}

.question-row:has(input[value="Sí"]:checked) .detail-field,
.question-row:has(input[name="sa-via-aerea"][value="Sí"]:checked) .detail-field,
.question-row:has(input[name="sa-hipertermia"][value="Sí"]:checked) .detail-field,
.question-row:has(input[name="sa-cardiorespiratorio"][value="Sí"]:checked) .detail-field,
.question-row:has(input[name="sa-habitos"][value="Sí"]:checked) .detail-field,
.question-row:has(input[name="sa-anticoagulante"][value="Sí"]:checked) .detail-field,
.question-row:has(input[name="si-clips"][value="Sí"]:checked) .detail-field,
.question-row:has(input[name="si-alergia-contraste"][value="Sí"]:checked) .detail-field,
.question-row:has(input[name="si-claustro-parche"][value="Sí"]:checked) .detail-field,
.question-row:has(input[name="sw-embarazo"][value="Sí"]:checked) .detail-field {
  display: block;
}

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

.detail-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate-secondary);
  margin-bottom: 4px;
  display: block;
}

.detail-field textarea {
  height: 70px;
  resize: vertical;
}

/* Wizard Actions Footer */
.wizard-actions-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--slate-border);
}

/* Sticky Right Alerts Sidebar */
.form-alerts-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 20px);
}

.sidebar-alerts-card h3 {
  font-size: 1.05rem;
  color: var(--slate-text);
  border-bottom: 2px solid var(--teal-primary);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.sidebar-alerts-intro {
  font-size: 0.75rem;
  color: var(--slate-secondary);
  margin-bottom: 12px;
}

.sidebar-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.live-alert-ok {
  background-color: var(--emerald-light);
  color: var(--emerald-success);
  border: 1px solid var(--emerald-border);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
}

.live-alert-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  line-height: 1.4;
  border-left-width: 4px;
  animation: alertPulse 1.5s ease;
}

@keyframes alertPulse {
  0% { transform: scale(0.98); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.live-alert-warning {
  background-color: var(--amber-light);
  color: #92400e;
  border: 1px solid var(--amber-border);
  border-left-color: var(--amber-warning);
}

.live-alert-danger {
  background-color: var(--red-light);
  color: #9f1239;
  border: 1px solid var(--red-border);
  border-left-color: var(--red-danger);
}

/* Risk Score Display Card */
.risk-score-display-card {
  background-color: var(--slate-bg);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.risk-score-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 1.05rem;
  font-weight: 600;
}

.risk-gfr-calculator-output {
  background-color: #fff;
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.risk-gfr-calculator-output h4 {
  font-size: 0.85rem;
  color: var(--slate-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.gfr-metric {
  margin-bottom: 4px;
}

.gfr-value {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--teal-primary);
}

.gfr-unit {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--slate-secondary);
  margin-left: 4px;
}

.gfr-interpretation {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate-secondary);
}

.risk-disclaimer {
  font-size: 0.775rem;
  color: var(--slate-secondary);
  line-height: 1.4;
  background-color: #fff;
  border: 1px dashed var(--slate-border);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.active-alerts-section h4 {
  font-size: 0.95rem;
  color: var(--slate-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-empty-state {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--emerald-light);
  border: 1px solid var(--emerald-border);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  color: var(--emerald-success);
  font-size: 0.85rem;
}

.alert-empty-state .alert-icon {
  font-size: 1.2rem;
  font-weight: 700;
}

/* Legal Consent & Firmas (Step 4) */
.legal-consent-card {
  background-color: var(--slate-bg);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.legal-consent-card h3 {
  font-size: 1rem;
  color: var(--slate-text);
  margin-bottom: 12px;
}

.legal-text-scroll {
  height: 120px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.8rem;
  color: var(--slate-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.legal-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.825rem;
  color: var(--slate-text);
}

.legal-checkbox-row input {
  margin-top: 4px;
}

.signatures-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

.signature-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.signature-box label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-secondary);
}

.canvas-wrapper {
  background-color: #fff;
  border: 2px dashed var(--slate-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 150px;
  touch-action: none; /* Prevents scrolling when signing on mobile */
  position: relative;
}

.canvas-wrapper canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Detail View Layout & Styling */
.detail-actions-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
}

.detail-right-actions {
  display: flex;
  gap: 12px;
}

/* CLINICAL DOCUMENT PAPER (Hospital Printout Style) */
.clinical-document-paper {
  background-color: #fff;
  border: 1px solid #d1d5db;
  box-shadow: var(--shadow-lg);
  padding: 50px;
  border-radius: var(--radius-sm);
  max-width: 850px;
  margin: 0 auto;
  font-family: 'Inter', Georgia, serif; /* Clean clinical style */
  color: #111827;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2.5px solid #111827;
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.doc-hospital-info h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #111827;
}

.doc-hospital-info p {
  font-size: 0.75rem;
  color: #4b5563;
}

.doc-type-badge {
  text-align: right;
}

.doc-badge-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  background-color: #111827;
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.doc-badge-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: #4b5563;
  margin-top: 4px;
}

.doc-section {
  margin-bottom: 28px;
}

.doc-section-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 800;
  color: #111827;
  border-bottom: 1.5px solid #374151;
  padding-bottom: 4px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.doc-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  margin-bottom: 12px;
}

.doc-info-table th {
  text-align: left;
  font-weight: 700;
  color: #374151;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  background-color: #f9fafb;
  width: 180px;
}

.doc-info-table td {
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  color: #111827;
}

.font-bold {
  font-weight: 700;
}

.text-teal {
  color: var(--teal-primary);
}

/* Document Answers list */
.doc-answer-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.825rem;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}

.doc-answer-q {
  font-weight: 500;
  color: #374151;
}

.doc-answer-a {
  font-weight: 700;
  color: #111827;
}

.doc-answer-det {
  font-size: 0.775rem;
  color: #4b5563;
  padding: 4px 10px;
  background-color: #f9fafb;
  border-left: 3px solid #cbd5e1;
  margin-top: 4px;
  margin-bottom: 8px;
}

.doc-risk-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.doc-risk-score-label {
  font-size: 0.85rem;
  font-weight: 700;
}

.doc-risk-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 10px;
  border: 1px solid #111827;
  text-transform: uppercase;
}

.doc-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-alert-card {
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-left-width: 4px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.doc-alert-card.warn {
  background-color: var(--amber-light);
  border-color: var(--amber-border);
  border-left-color: var(--amber-warning);
  color: #78350f;
}

.doc-alert-card.crit {
  background-color: var(--red-light);
  border-color: var(--red-border);
  border-left-color: var(--red-danger);
  color: #9d174d;
}

.doc-legal-text {
  font-size: 0.75rem;
  color: #4b5563;
  line-height: 1.4;
  margin-bottom: 24px;
  text-align: justify;
}

.doc-signatures-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
  margin-top: 36px;
}

.doc-signature-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.doc-signature-line {
  width: 100%;
  height: 90px;
  border-bottom: 1.5px solid #111827;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-signature-image {
  max-width: 200px;
  max-height: 80px;
  object-fit: contain;
}

.doc-signature-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #111827;
}

.doc-signature-subtext {
  font-size: 0.725rem;
  color: #4b5563;
  margin-top: 2px;
}

.doc-footer {
  border-top: 1px solid #e5e7eb;
  padding-top: 14px;
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
  font-size: 0.675rem;
  color: #9ca3af;
}

/* PRINT-SPECIFIC CSS RULES */
@media print {
  /* Hide all interactive/web elements */
  body {
    background-color: #fff !important;
    color: #000 !important;
  }
  
  .sidebar, .main-header, .detail-actions-bar, .no-print {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    min-height: auto !important;
  }

  .view-viewport {
    padding: 0 !important;
  }

  .view-section {
    display: none !important;
  }

  #view-detail.view-section {
    display: block !important;
    animation: none !important;
  }

  /* Optimize Document for paper sheet */
  .clinical-document-paper {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .doc-legal-text {
    font-size: 10pt !important;
  }

  .doc-badge-title {
    background-color: #000 !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Modal Dialog System */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6); /* Backdrop slate overlay */
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease-out;
}

.modal.active {
  display: flex;
}

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

.modal-content {
  background-color: var(--slate-card);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(20px) scale(0.96); }
  to { transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--slate-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--slate-text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--slate-secondary);
  cursor: pointer;
  transition: color 0.15s ease;
  line-height: 1;
}

.modal-close:hover {
  color: var(--red-danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

.fhir-code-wrapper {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid #1e293b;
}

.fhir-code-wrapper pre {
  margin: 0;
  padding: 16px;
  background-color: #0f172a; /* Slate 900 */
  max-height: 320px;
  overflow-y: auto;
}

.fhir-code-wrapper code {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 0.8rem;
  color: #38bdf8; /* Sky-400 code color */
  white-space: pre-wrap;
  word-break: break-all;
  display: block;
}

.btn-copy-fhir {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
  z-index: 10;
  cursor: pointer;
}

.btn-copy-fhir:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.modal-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--slate-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* RESPONSIVE DESIGN (Tablets / Mobile) */

/* Large Screens Overrides (Show Sidebar permanently) */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0);
    z-index: 100;
  }
  
  .sidebar-backdrop {
    display: none !important;
  }
  
  .btn-menu-toggle {
    display: none !important;
  }
  
  .main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }
}

@media (max-width: 1100px) {
  .form-wizard-layout {
    grid-template-columns: 1fr;
  }
  .form-alerts-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  /* Hide labels in wizard progress indicators to avoid overlap */
  .step-text {
    display: none;
  }
  .wizard-steps-indicator::before {
    top: 19px;
  }
  
  .main-header {
    padding: 0 20px;
  }
  .view-viewport {
    padding: 20px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .signatures-grid, .doc-signatures-wrapper {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  
  .search-filter-bar {
    grid-template-columns: 1fr;
  }
  
  .clinical-document-paper {
    padding: 24px;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  /* Hide non-critical columns on mobile table display to prevent overflow */
  .clinical-table th:nth-child(4),
  .clinical-table td:nth-child(4),
  .clinical-table th:nth-child(6),
  .clinical-table td:nth-child(6) {
    display: none;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  /* Stack footer buttons on narrow mobile screen sizes */
  .wizard-actions-footer {
    flex-direction: column-reverse;
    gap: 12px;
  }
  
  .wizard-actions-footer .btn {
    width: 100%;
  }
  
  /* Hide date badge to avoid header wrapping */
  .date-badge {
    display: none;
  }
}
