/* Modern Medical Data Entry Styling System */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Color Palette - Light Mode (Medical Data Dense) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --primary: #1e40af; /* Navy blue */
  --primary-hover: #1e3a8a;
  --primary-light: #eff6ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --border-color: #cbd5e1;
  --input-bg: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius: 8px; /* Compact density */
  --transition: all 0.2s ease-out; /* Snappier transitions */
}

.dark-theme {
  /* Color Palette - Dark Mode */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #3b82f6; /* Lighter blue for dark mode */
  --primary-hover: #60a5fa;
  --primary-light: #1e3a8a40;
  --success: #34d399;
  --success-light: #065f462a;
  --warning: #fbbf24;
  --warning-light: #78350f2a;
  --danger: #f87171;
  --danger-light: #7f1d1d2a;
  --border-color: #475569;
  --input-bg: #1e293b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  background-color: #ffffff; /* White background for seamless look */
  color: var(--text-primary);
  line-height: 1.5;
  transition: var(--transition);
  padding-bottom: 40px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .app-container {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

/* App Layout */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  background: transparent;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  background: var(--primary);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 14px 0 rgba(2, 132, 199, 0.4);
}

.brand-info h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-info p {
  font-size: 13px;
  color: var(--text-muted);
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

.user-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-meta strong {
  font-size: 13px;
}

.user-meta span {
  font-size: 11px;
  color: var(--text-muted);
}

/* Dashboard Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-tertiary);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  background: #e2e8f0;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }

.stat-info h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 2px;
}

.stat-info p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Action Controls Panel */
.controls-panel {
  background: transparent;
  padding: 16px 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  width: 100%;
  max-width: 400px;
  gap: 10px;
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  outline: none;
  width: 100%;
  font-size: 14px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-select {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.filter-select:focus {
  border-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  outline: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

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

.btn-success:hover {
  background: #059669;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

.btn-secondary:hover {
  background: var(--border-color);
}

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

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-tertiary);
}

/* Main grid - always single column (form is now fullscreen overlay) */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

/* Fullscreen Form Overlay */
.form-panel {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: var(--bg-primary);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: formSlideUp 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

.form-panel.active {
  display: flex;
}

.form-panel .form-body-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 40px 32px;
  scroll-behavior: smooth;
}

@media(max-width: 768px) {
  .form-panel .form-body-scroll {
    padding: 16px 12px 24px;
  }
}

.form-body-scroll::-webkit-scrollbar {
  width: 6px;
}
.form-body-scroll::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.form-body-inner {
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 40px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 10;
}

@media(max-width: 768px) {
  .form-header {
    padding: 12px 16px;
  }
}

.form-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Step Wizard Navigation - hidden in fullscreen mode */
.step-wizard {
  display: none;
}

/* Step Contents - all visible in fullscreen mode (vertical scroll) */
.step-content {
  display: block;
  margin-bottom: 8px;
  padding: 20px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.step-content:last-of-type {
  margin-bottom: 0;
}

.step-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 18px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Form Fields Grid - 4 columns on large screens */
.fields-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.col-span-1 {
  grid-column: span 1;
}

.col-span-2 {
  grid-column: span 2;
}

.col-span-3 {
  grid-column: span 3;
}

.col-span-4 {
  grid-column: span 4;
}

/* 4-column grid on medium+ screens */
@media(min-width: 768px) {
  .fields-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .col-span-3 {
    grid-column: span 3;
  }
  .form-group.full-width, .col-span-4 {
    grid-column: span 4;
  }
}

@media(min-width: 540px) and (max-width: 767px) {
  .fields-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .col-span-3, .col-span-4 {
    grid-column: span 2;
  }
}

label {
  font-size: 13.8px;
  font-weight: 700;
  color: var(--text-primary);
}

label.required::after {
  content: ' *';
  color: var(--danger);
}

input, select, textarea {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1.5px solid var(--border-color);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  width: 100%;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.2); /* Stronger focus ring */
}

input:disabled, select:disabled, textarea:disabled {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* BMI Status Badges */
.bmi-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
}

.bmi-badge {
  padding: 2px 8px;
  border-radius: 4px;
}

.bmi-thin { background: var(--warning-light); color: var(--warning); }
.bmi-normal { background: var(--success-light); color: var(--success); }
.bmi-overweight { background: var(--warning-light); color: var(--warning); }
.bmi-obese { background: var(--danger-light); color: var(--danger); }

/* Form Footer - sticky at bottom of fullscreen overlay */
.form-footer {
  padding: 14px 40px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

@media(max-width: 768px) {
  .form-footer {
    padding: 12px 16px;
  }
}

/* Data Table Panel */
.table-panel {
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0; /* Prevents flex items from overflowing their container */
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color); /* Keep border just for the scrollable table area to prevent bleeding */
  border-radius: 8px;
  max-height: 600px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

th, td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

tr:hover td {
  background-color: var(--bg-primary);
}

.sticky-col {
  position: sticky;
  background: var(--bg-secondary);
  z-index: 5;
}

.left-sticky {
  left: 0;
  border-right: 1px solid var(--border-color);
}

.right-sticky {
  right: 0;
  border-left: 1px solid var(--border-color);
}

tr:hover .sticky-col {
  background-color: var(--bg-primary);
}

.table-actions {
  display: flex;
  gap: 8px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--border-color);
}

/* Modal Dialogs */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.auth-overlay {
  z-index: 10050;
}

.admin-overlay {
  z-index: 220;
}

.user-form-overlay {
  z-index: 230;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content.wide {
  max-width: 1200px;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 14px;
}

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

.hidden {
  display: none !important;
}

.permission-hidden {
  display: none !important;
}

.auth-modal {
  max-width: 760px;
}

.auth-modal-body {
  display: grid;
  gap: 18px;
}

.auth-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
  border: 1px solid var(--border-color);
}

.auth-brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #fff;
  flex-shrink: 0;
}

.auth-brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-brand-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-brand-text strong {
  font-size: 18px;
}

.auth-brand-text span {
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
}

.auth-brand-text p {
  font-size: 12px;
  color: var(--text-muted);
}

.auth-form {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.auth-note,
.help-text {
  font-size: 12px;
  color: var(--text-muted);
}

.form-error {
  min-height: 18px;
  font-size: 12px;
  color: var(--danger);
  font-weight: 600;
}

.admin-modal {
  max-width: 1280px;
}

.admin-modal-body {
  display: grid;
  gap: 18px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-tab {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.admin-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.admin-section {
  display: none;
}

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

.admin-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.admin-card h4 {
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 800;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px 16px;
}

@media (min-width: 768px) {
  .admin-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.admin-table-wrapper {
  max-height: 400px;
  overflow-y: auto;
}

.admin-table-wrapper table {
  min-width: 860px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.permission-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  cursor: pointer;
  transition: var(--transition);
}

.permission-option:hover {
  border-color: var(--primary);
  background: var(--bg-secondary);
}

.permission-option input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.permission-option-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.permission-option-content strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.permission-option-content small {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}

.admin-logo-preview {
  margin-top: 10px;
  width: 100%;
  max-width: 160px;
  height: 72px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: #fff;
  padding: 6px;
}

.auth-header-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Detail view styling */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media(min-width: 640px) {
  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.detail-section {
  grid-column: span 2;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-top: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.detail-section:first-child {
  margin-top: 0;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1), toastFadeOut 0.3s ease 2.7s forwards;
  font-size: 14px;
  font-weight: 500;
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }

/* Custom Switch for Theme Mode */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch-track {
  width: 44px;
  height: 24px;
  background: var(--border-color);
  border-radius: 12px;
  position: relative;
  transition: var(--transition);
}

.switch-thumb {
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.dark-theme .switch-track {
  background: var(--primary);
}

.dark-theme .switch-thumb {
  left: 23px;
}

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

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

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

@keyframes toastFadeOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); visibility: hidden; }
}

/* Excel upload area style */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-primary);
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-area i {
  font-size: 32px;
  color: var(--primary);
  margin-bottom: 12px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Custom Styles for Blood Pressure and PARA Inputs */
.bp-badge {
  padding: 4px 10px;
  border-radius: 4px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
  text-align: center;
}
.bp-normal { background-color: var(--success); }
.bp-pre { background-color: var(--warning); color: #000; }
.bp-stage1 { background-color: #d97706; }
.bp-stage2 { background-color: var(--danger); }
.bp-crisis { background-color: #7f1d1d; animation: pulseRed 1s infinite alternate; }

@keyframes pulseRed {
  from { opacity: 0.8; }
  to { opacity: 1; box-shadow: 0 0 8px #ef4444; }
}

/* PARA Grid input styling */
.para-inputs-group input {
  font-size: 15px;
  font-weight: 700;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--input-bg);
  color: var(--text-primary);
  text-align: center;
}

/* Background classes for analytics progress bars */
.bg-success { background-color: var(--success) !important; }
.bg-warning { background-color: var(--warning) !important; }
.bg-danger { background-color: var(--danger) !important; }
.bg-primary { background-color: var(--primary) !important; }
.bg-info { background-color: #0ea5e9 !important; }
.bg-orange { background-color: #d97706 !important; }

/* PRINT MEDIA STYLING */
@media print {
  html, body {
    background-color: #fff !important;
    color: #000 !important;
    font-size: 12px !important;
    padding: 0 !important;
    margin: 0 !important;
    height: auto;
  }

  .app-container,
  .modal-overlay,
  .toast-container,
  header,
  .stats-grid,
  .analytics-panel,
  .controls-panel,
  .main-grid,
  footer {
    display: none !important;
  }

  .print-only {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 auto !important;
    background: white !important;
  }

  @page {
    size: A4 portrait;
    margin: 0 !important;
  }

  @page a3-layout {
    size: A3 landscape;
    margin: 0 !important;
  }

  .print-page-a3-wrapper {
    page: a3-layout;
    width: 420mm !important;
    height: 297mm !important;
    background: #fff;
    color: #000;
  }

  .print-a3-sheet {
    width: 420mm !important;
    height: 297mm !important;
    page-break-after: always;
    display: flex;
    box-sizing: border-box !important;
  }

  .print-a3-sheet:last-child {
    page-break-after: avoid;
  }

  .print-a3-col {
    width: 210mm !important;
    height: 297mm !important;
    box-sizing: border-box !important;
    font-family: "Times New Roman", Times, serif !important;
    font-size: 12.5px;
    line-height: 1.4;
    color: #000;
    background: #fff;
    overflow: hidden;
    position: relative;
  }

  .print-a3-col-left {
    padding: 12mm 25mm 12mm 15mm !important;
  }

  .print-a3-col-right {
    padding: 12mm 15mm 12mm 25mm !important;
  }

  .print-page {
    width: 210mm !important;
    height: 297mm !important;
    page-break-after: always;
    box-sizing: border-box !important;
    font-family: "Times New Roman", Times, serif !important;
    font-size: 12.5px;
    line-height: 1.4;
    color: #000;
    background: #fff;
    padding: 12mm 15mm 12mm 25mm !important; /* Margins: Top 12mm, Right 15mm, Bottom 12mm, Left 25mm */
    overflow: hidden;
    position: relative;
  }

  .print-page:last-child {
    page-break-after: avoid;
  }

  .print-book-header {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    line-height: 1.3;
    margin-bottom: 15px;
  }

  .print-book-header-left {
    text-align: center;
    width: 45%;
  }

  .print-book-header-right {
    text-align: center;
    width: 50%;
  }

  .print-book-title {
    text-align: center;
    font-size: 15px;
    font-weight: bold;
    text-transform: uppercase;
    margin: 15px 0 15px 0;
  }

  /* --- Box & Checkbox Print Styles --- */
  .print-box-char {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1px solid #000 !important;
    text-align: center;
    line-height: 14px;
    font-weight: bold;
    font-size: 11px;
    margin-right: 2px;
    background: #fff;
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-checkbox {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1px solid #000 !important;
    text-align: center;
    line-height: 10px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 5px;
    margin-right: 15px;
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
  }

  .print-header h1 {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
  }

  .print-header p {
    font-size: 11px;
    margin: 2px 0;
  }

  .print-section-title {
    font-size: 13px;
    font-weight: bold;
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 6px 10px;
    margin: 15px 0 10px 0;
    border-left: 4px solid #000;
    text-transform: uppercase;
  }

  .print-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 20px;
    margin-bottom: 10px;
  }

  .print-item {
    display: flex;
    font-size: 12px;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 3px;
  }

  .print-label {
    font-weight: bold;
    min-width: 150px;
    color: #333;
  }

  .print-value {
    flex-grow: 1;
    color: #000;
  }

  .print-full-width {
    grid-column: span 2;
  }

  .print-footer-signatures {
    margin-top: 40px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    text-align: center;
    page-break-inside: avoid;
  }

  .print-signature-box {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 120px;
  }

  .print-signature-title {
    font-weight: bold;
  }

  .print-signature-name {
    font-style: italic;
  }
}

/* --- Custom Searchable Select Styles --- */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-input {
  cursor: text;
  padding-right: 32px !important; /* make room for the arrow */
}

.custom-select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--transition);
  z-index: 2;
}

.custom-select-wrapper.open .custom-select-arrow {
  transform: translateY(-50%) rotate(180deg);
  color: var(--primary);
}

.custom-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  max-height: 250px;
  overflow-y: auto;
  display: none;
}

.custom-select-wrapper.open .custom-select-dropdown {
  display: block;
}

.custom-select-option {
  padding: 10px 14px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-select-option:hover {
  background: var(--bg-tertiary);
}

.custom-select-option.selected {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.custom-select-option.hidden {
  display: none;
}

.custom-select-option-code {
  font-size: 11px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: normal;
}

/* --- Suggestions Popover (ICD-10 & Place of Issue) --- */
.suggestions-popover {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}

.suggestions-popover.active {
  display: block;
}

.suggestion-item {
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.2s;
  text-align: left;
}

.suggestion-item:hover, .suggestion-item.active {
  background: var(--bg-tertiary);
  color: var(--primary);
}

.suggestion-item-code {
  font-weight: 600;
  color: var(--primary);
  margin-right: 8px;
}

/* --- Input Pinning Styles --- */
.btn-pin-ma-co-so {
  font-size: 11px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: var(--transition);
}

.btn-pin-ma-co-so:hover, .btn-pin-ma-co-so.pinned {
  color: var(--primary);
}

.btn-pin-ma-co-so.pinned i {
  color: var(--success);
}

/* --- Brand Logo Styling --- */
.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color);
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: var(--transition);
}

.brand-logo:hover {
  transform: scale(1.05) rotate(5deg);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.brand-desc {
  font-size: 12px !important;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- App Footer Styles --- */
.app-footer {
  margin-top: 32px;
  background: transparent;
  border: none;
  padding: 16px 0;
  border-top: 1px solid var(--border-color); /* Just a subtle top border */
  border-radius: 0;
  transition: var(--transition);
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: center;
}

@media (min-width: 768px) {
  .footer-content {
    flex-direction: row;
    text-align: left;
  }
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.footer-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.footer-copyright {
  font-size: 13px;
  color: var(--text-secondary);
}

.footer-copyright strong {
  color: var(--primary);
  font-weight: 600;
}

.footer-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}



/* --- Form Tab Navigation --- */
.form-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 40px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  flex-wrap: wrap;
  z-index: 9;
}

@media(max-width: 768px) {
  .form-tabs {
    padding: 10px 12px;
  }
}

.form-tab {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  outline: none;
}

.form-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.form-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.form-tab.has-error {
  border-color: var(--danger);
  color: var(--danger);
}

/* --- Patient Code & Status Badge --- */
.patient-code-display {
  font-family: 'Courier New', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
  background: var(--primary-light);
  border: 1.5px solid var(--primary);
  border-radius: 8px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
