/* Alertix - Estilos Oficiales del Sistema de Enfermería Escolar y Gestión Estudiantil */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

:root {
  --cca-blue-dark: #123c73;      /* Sophisticated deep school blue */
  --cca-blue-primary: #154785;   /* Institutional classic school blue */
  --cca-blue-light: #205ea6;     /* Shined variant of school blue */
  --cca-blue-hover: #0e305a;     /* Deep navy for hovering buttons */
  --cca-gold: #dfa116;           /* Subtle golden yellow for details, non-saturated */
  --cca-gold-dark: #b47e09;      /* Darker golden shade */
  --cca-amber-bg: #fdfaf2;       /* Cream light background for alerts */
  --cca-amber-border: #f0e1bc;   /* Very soft border for alerts */
  --cca-amber-text: #855d05;     /* Soft dark gold text */
  
  --bg-app: #f8fafc;             /* Ultra-clean institutional background */
  --bg-card: #ffffff;
  --text-primary: #1e293b;       /* Soft charcoal with blue undertones */
  --text-secondary: #475569;     /* Standard readably gray */
  --text-muted: #64748b;
  --border-color: #e2e8f0;       /* Super thin, clean borders */
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #dfa116;
  --warning-bg: #fdfaf2;
  --info: #205ea6;
  --info-bg: #eff6ff;

  --font-family: 'Roboto', 'Arial', sans-serif;
  --border-radius-sm: 6px;       /* Traditional and clean border radius */
  --border-radius-md: 6px;       /* Traditional and clean border radius */
  --border-radius-lg: 6px;       /* Consistent neat rounded corners */
  --shadow-sm: none;             /* Inexistent shadows for flat paper design */
  --shadow-md: none;             /* Inexistent shadows for flat paper design */
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.02); /* Extremely soft dropdown shadow */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Loading Shroud */
#app-shroud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #ffffff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.shroud-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f1f5f9;
  border-top-color: var(--cca-blue-primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --- SPLIT LOGIN PAGE (Matches Image 3 & Image 4) --- */
.login-screen {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  background-color: #ffffff;
}

.login-banner {
  flex: 1.1;
  background-image: url('https://res.cloudinary.com/dtz0urit6/image/upload/q_auto,f_png/cloudinary-tools-uploads/tz4rhy0locxur7lj1wfm');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
}

.login-banner-content {
  display: none; /* Hide marketing text overlays to keep design beautifully minimal and pure */
}

.login-form-container {
  flex: 0.9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background-color: #f8fafc;
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  text-align: center;
  box-shadow: none;
}

.login-logo-img {
  width: 120px; /* Beautifully sized, centered crest logo */
  height: auto;
  margin: 0 auto 32px auto;
  display: block;
}

.login-brand {
  display: none; /* Hide ALERTIX giant text on login, matches Image 3 style rules */
}

.login-subtitle {
  display: none; /* Hide subtitle, as Logo says it all */
}

.login-title-form {
  font-size: 21px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 28px;
  text-align: center;
  letter-spacing: -0.2px;
}

.login-error-box {
  background-color: var(--danger-bg);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  text-align: left;
  display: none;
  border-left: 4px solid var(--danger);
}

.login-form {
  width: 100%;
}

.input-group {
  position: relative;
  margin-bottom: 18px;
  text-align: left;
}

.form-label {
  display: none; /* Hide floating external labels, relying purely on inline placeholders per Image 3 */
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 44px;
  border: 1px solid #dcdfe6;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background-color: #ffffff;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--cca-blue-primary);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(21, 71, 133, 0.08);
}

.input-icon-left {
  position: absolute;
  left: 14px;
  top: 12px; /* Mathematically centered vertically since there is no floating label */
  color: #909399;
  font-size: 20px;
  pointer-events: none;
}

.input-icon-right {
  position: absolute;
  right: 14px;
  top: 12px; /* Mathematically centered vertically */
  color: #909399;
  font-size: 20px;
  cursor: pointer;
}

.btn-submit {
  width: 100%;
  height: 44px;
  background-color: var(--cca-blue-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-submit:hover {
  background-color: var(--cca-blue-hover);
}

.btn-submit:active {
  transform: scale(0.99);
}

.btn-google {
  width: 100%;
  height: 44px;
  background-color: #ffffff;
  color: var(--text-primary);
  border: 1px solid #dcdfe6;
  border-radius: var(--border-radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-google:hover {
  background-color: #f5f7fa;
  border-color: #c0c4cc;
}

/* Forgot Password Link styling per Image 3 */
.forgot-password-container {
  margin-top: 24px;
  text-align: center;
}

.forgot-password-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--cca-blue-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.forgot-password-link:hover {
  color: var(--cca-blue-hover);
  text-decoration: underline;
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e4e7ed;
}

.login-divider:not(:empty)::before {
  margin-right: .5em;
}

.login-divider:not(:empty)::after {
  margin-left: .5em;
}

/* Quick Login Shortcuts */
.quick-login-container {
  margin-top: 20px;
  text-align: left;
}

.quick-login-title {
  font-size: 11px;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.quick-login-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.quick-login-pill {
  padding: 8px 12px;
  border: 1px solid #e4e7ed;
  border-radius: var(--border-radius-sm);
  background-color: #fcfdfe;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.quick-login-pill:hover {
  background-color: #f5f7fa;
  border-color: var(--cca-blue-primary);
}

.quick-login-role {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quick-login-name {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-color-parent { color: var(--cca-blue-primary); }
.role-color-nurse { color: var(--success); }
.role-color-teacher { color: var(--info); }
.role-color-admin { color: var(--danger); }

/* --- STATE 2: DASHBOARD LAYOUT --- */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar navigation (Matches Image 5 White Minimalist Style) */
.dashboard-sidebar {
  width: 260px;
  background-color: #ffffff;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 100;
  border-right: 1px solid var(--border-color);
}

.sidebar-brand-area {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2.5px solid var(--cca-gold);
}

.sidebar-logo {
  width: 40px;
  height: auto;
}

.sidebar-brand-name {
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.5px;
  color: var(--cca-blue-primary);
}

.sidebar-brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: bold;
  margin-top: -2px;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  color: #4a5568;
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
}

.menu-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-item-icon {
  font-size: 18px;
  color: #718096;
  transition: color 0.2s ease;
}

.menu-item:hover {
  background-color: #f7fafc;
  color: #1a2536;
}

.menu-item:hover .menu-item-icon {
  color: var(--cca-blue-primary);
}

.menu-item.active {
  background-color: #f4f8fc;
  color: var(--cca-blue-primary);
  font-weight: 600;
  border-left: 3px solid var(--cca-blue-primary);
}

.menu-item.active .menu-item-icon {
  color: var(--cca-blue-primary);
}

.menu-item-badge-plus {
  background-color: var(--danger);
  color: #ffffff;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
}

.sidebar-footer {
  padding: 16px;
  background-color: #f8fafc;
  border-top: 1px solid #cbd5e1;
}

.sidebar-profile-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sidebar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #e0f2fe;
  color: var(--cca-blue-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 15px;
  border: 2px solid #ffffff;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.sidebar-user-details {
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 13.5px;
  font-weight: bold;
  color: var(--text-primary);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--cca-blue-primary);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-sidebar-logout {
  width: 100%;
  padding: 10px;
  background-color: rgba(239, 68, 68, 0.05);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.1);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-sidebar-logout:hover {
  background-color: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

/* Main Viewport */
.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Top bar */
.topbar {
  height: 64px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

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

.topbar-menu-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: none; /* Block on mobile */
  align-items: center;
}

.topbar-logo {
  width: 32px;
  height: auto;
}

.topbar-title {
  font-size: 18px;
  font-weight: bold;
  color: var(--cca-blue-dark);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

.bell-container {
  position: relative;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  color: var(--text-secondary);
}

.bell-container:hover {
  background-color: #f1f5f9;
}

.bell-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--danger);
  border: 1.5px solid #ffffff;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--cca-blue-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 13.5px;
  cursor: pointer;
}

/* Dropdown list inside Topbar */
.notification-dropdown {
  position: absolute;
  top: 50px;
  right: 0;
  width: 320px;
  background-color: #ffffff;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  z-index: 200;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.notification-dropdown.active {
  display: flex;
}

.notif-dropdown-header {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: bold;
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.notif-dropdown-list {
  max-height: 280px;
  overflow-y: auto;
}

.notif-dropdown-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.notif-dropdown-item:hover {
  background-color: #f8fafc;
}

.notif-dropdown-title {
  font-size: 13px;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.notif-dropdown-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.notif-dropdown-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.header-gold-bar {
  height: 2px;
  background-color: var(--cca-gold);
  flex-shrink: 0;
}

/* Alerts Banner */
.alert-banner {
  background-color: var(--cca-amber-bg);
  border-bottom: 1.5px solid var(--cca-amber-border);
  color: var(--cca-amber-text);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.alert-icon {
  font-size: 18px;
}

.alert-link {
  text-decoration: underline;
  cursor: pointer;
  font-weight: bold;
}

/* Central View Workspace */
.dashboard-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  position: relative;
}

.dashboard-view-section {
  display: none;
}

.dashboard-view-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.section-title-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 24px;
  font-weight: 900;
  color: var(--cca-blue-dark);
  position: relative;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 40px;
  height: 3px;
  background-color: var(--cca-gold);
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Hero Banner Card displaying school facilities */
.hero-banner-card {
  position: relative;
  width: 100%;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--cca-blue-primary);
  border-radius: var(--border-radius-sm);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  color: var(--text-primary);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.hero-banner-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--cca-blue-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hero-banner-text {
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 820px;
  line-height: 1.5;
  font-weight: 400;
}

/* --- STUDENTS GRID & INFO CARDS --- */
.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.student-card {
  background-color: #ffffff;
  border-radius: var(--border-radius-md);
  border: 1px solid #e2e8f0;
  padding: 16px;
  display: flex;
  gap: 16px;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.student-card:hover {
  background-color: #f8fafc;
  border-color: var(--cca-blue-primary);
}

.student-photo-frame {
  width: 75px;
  height: 85px;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  background-color: #f1f5f9;
  border: 1.5px solid var(--border-color);
  flex-shrink: 0;
}

.student-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.student-card-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.student-card-name {
  font-size: 15px;
  font-weight: bold;
  color: var(--cca-blue-dark);
  line-height: 1.3;
  margin-bottom: 4px;
}

.student-card-id {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: bold;
}

.student-card-meta {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

.student-status-badge {
  font-size: 11px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 12px;
  align-self: flex-start;
  margin-top: 6px;
}

.status-green {
  background-color: var(--success-bg);
  color: var(--success);
}

.status-red {
  background-color: var(--danger-bg);
  color: var(--danger);
}

/* Warning badges for chronic illnesses on Teacher view */
.allergy-badge-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.allergy-badge {
  font-size: 10.5px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.alert-allergy {
  background-color: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(225, 29, 72, 0.3);
}

.alert-condition {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.3);
}

/* --- DETAILS TABS & CLINICAL SHEETS --- */
.bento-medical-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 1024px) {
  .bento-medical-grid {
    grid-template-columns: 1fr;
  }
}

.clinical-card {
  background-color: #ffffff;
  border-radius: var(--border-radius-lg);
  border: 1.5px solid var(--border-color);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.clinical-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: bold;
  color: var(--cca-blue-dark);
  border-bottom: 1.5px solid #f1f5f9;
  padding-bottom: 12px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.clinical-header-icon {
  color: var(--cca-blue-primary);
  font-size: 22px;
}

.clinical-field {
  margin-bottom: 16px;
}

.clinical-label {
  font-size: 12px;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.clinical-value {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
}

.clinical-value-badge {
  display: inline-block;
  font-weight: bold;
  color: var(--danger);
  background-color: var(--danger-bg);
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  border-left: 3px solid var(--danger);
  margin-top: 4px;
}

.clinical-value-badge-warning {
  display: inline-block;
  font-weight: bold;
  color: var(--warning);
  background-color: var(--warning-bg);
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  border-left: 3px solid var(--warning);
  margin-top: 4px;
}

/* QR Code styling */
.qr-card-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border: 1.5px dashed var(--border-color);
  border-radius: var(--border-radius-lg);
  background-color: #f8fafc;
  text-align: center;
}

.qr-image-wrapper {
  background-color: #ffffff;
  padding: 16px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.qr-image-svg {
  width: 140px;
  height: 140px;
  display: block;
}

.qr-caption {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- TAB SELECTION FOR MEDICAL HISTORY --- */
.history-table-container {
  background-color: #ffffff;
  border-radius: var(--border-radius-lg);
  border: 1.5px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-top: 15px;
}

.history-header-filters {
  padding: 16px 24px;
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.history-filter-select {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--border-radius-sm);
  border: 1.5px solid var(--border-color);
  font-size: 13.5px;
  background-color: #ffffff;
}

.history-filter-select:focus {
  outline: none;
  border-color: var(--cca-blue-primary);
}

.alertix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.alertix-table th {
  padding: 14px 20px;
  font-size: 12px;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1.5px solid var(--border-color);
  background-color: #f8fafc;
}

.alertix-table td {
  padding: 16px 20px;
  font-size: 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
  vertical-align: middle;
}

.alertix-table tbody tr:hover {
  background-color: #f8fafc;
}

.severity-pill {
  font-size: 11px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  display: inline-block;
}

.severity-minor { background-color: var(--info-bg); color: var(--info); }
.severity-moderate { background-color: var(--warning-bg); color: var(--warning); }
.severity-emergency { background-color: var(--danger-bg); color: var(--danger); }

/* --- CLINICAL VISIT FORM & REGISTERS --- */
.clinical-form-card {
  background-color: #ffffff;
  border-radius: var(--border-radius-lg);
  border: 1.5px solid var(--border-color);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

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

@media (max-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

.form-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-md);
  font-size: 14.5px;
  background-color: #f8fafc;
  transition: all 0.2s ease;
  resize: vertical;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--cca-blue-primary);
  background-color: #ffffff;
}

.form-select-student {
  width: 100%;
  height: 46px;
  padding: 0 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-md);
  font-size: 15px;
  background-color: #f8fafc;
  cursor: pointer;
}

.form-select-student:focus {
  outline: none;
  border-color: var(--cca-blue-primary);
}

.btn-form-action {
  background-color: var(--success);
  color: #ffffff;
  border: none;
  border-radius: var(--border-radius-md);
  padding: 12px 24px;
  font-weight: bold;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.btn-form-action:hover {
  background-color: #0b7a70;
}

/* File upload drag-and-drop */
.file-upload-dragzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-md);
  background-color: #f8fafc;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 16px;
}

.file-upload-dragzone:hover, .file-upload-dragzone.dragover {
  border-color: var(--cca-blue-primary);
  background-color: rgba(29, 78, 216, 0.05);
}

.dragzone-icon {
  font-size: 32px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dragzone-text {
  font-size: 13.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.dragzone-subtext {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- CHAT MODULE STYLING --- */
.chat-container {
  display: flex;
  height: 480px;
  background-color: #ffffff;
  border-radius: var(--border-radius-lg);
  border: 1.5px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-sidebar {
  width: 240px;
  border-right: 1.5px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background-color: #f8fafc;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .chat-sidebar {
    width: 80px;
  }
  .chat-sidebar-name {
    display: none;
  }
}

.chat-sidebar-header {
  padding: 16px;
  font-weight: bold;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

.chat-thread-list {
  flex: 1;
  overflow-y: auto;
}

.chat-thread-item {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.2s ease;
}

.chat-thread-item:hover {
  background-color: #f1f5f9;
}

.chat-thread-item.active {
  background-color: #e0f2fe;
  border-left: 4px solid var(--cca-blue-primary);
}

.chat-thread-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--cca-blue-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
}

.chat-thread-details {
  flex: 1;
  overflow: hidden;
}

.chat-sidebar-name {
  font-size: 13px;
  font-weight: bold;
  color: var(--text-primary);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #f1f5f9;
}

.chat-main-header {
  height: 56px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-title {
  font-size: 14px;
  font-weight: bold;
  color: var(--cca-blue-dark);
}

.chat-messages-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-bubble-received {
  background-color: #ffffff;
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-bubble-sent {
  background-color: var(--cca-blue-primary);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.chat-bubble-meta {
  font-size: 10px;
  margin-top: 4px;
  text-align: right;
  opacity: 0.7;
}

.chat-input-area {
  padding: 12px;
  background-color: #ffffff;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
}

.chat-input-field {
  flex: 1;
  height: 40px;
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  padding: 0 16px;
  font-size: 14px;
}

.chat-input-field:focus {
  outline: none;
  border-color: var(--cca-blue-primary);
}

.btn-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--cca-blue-primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.btn-chat-send:hover {
  background-color: var(--cca-blue-hover);
}

/* --- STATS PANEL GRAPHICS --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box-summary {
  background-color: #ffffff;
  border-radius: var(--border-radius-lg);
  border: 1.5px solid var(--border-color);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-box-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-box-data {
  display: flex;
  flex-direction: column;
}

.stat-box-number {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-primary);
}

.stat-box-title {
  font-size: 12px;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background-color: #ffffff;
  border-radius: var(--border-radius-lg);
  border: 1.5px solid var(--border-color);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.chart-card-title {
  font-size: 14px;
  font-weight: bold;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* Custom CSS SVG Bar Chart */
.svg-chart-container {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 20px;
  padding: 10px 20px 20px 20px;
  border-bottom: 2px solid var(--border-color);
}

.svg-chart-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.svg-chart-bar {
  width: 100%;
  max-width: 32px;
  background-color: var(--cca-blue-primary);
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  position: relative;
  transition: height 0.5s ease;
  animation: growBar 0.8s ease-out;
}

@keyframes growBar {
  from { height: 0; }
}

.svg-chart-bar-label {
  font-size: 10.5px;
  font-weight: bold;
  color: var(--text-muted);
  margin-top: 8px;
  white-space: nowrap;
}

.svg-chart-bar-value {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: bold;
  color: var(--text-primary);
}

/* --- SUPABASE CONFIG CONSOLE PANEL --- */
.supabase-sync-panel {
  background-color: var(--cca-blue-dark);
  color: #ffffff;
  padding: 16px 24px;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  margin-top: 30px;
  border: 2px solid var(--cca-gold);
}

.sync-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.sync-panel-title {
  font-size: 15px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cca-gold);
}

.sync-status-indicator {
  font-size: 11px;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}

.sync-status-sim { background-color: var(--warning); color: #ffffff; }
.sync-status-real { background-color: var(--success); color: #ffffff; }

.sync-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: flex-end;
}

@media (max-width: 768px) {
  .sync-form {
    grid-template-columns: 1fr;
  }
}

.sync-label {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 4px;
  display: block;
}

.sync-input {
  width: 100%;
  height: 38px;
  border: 1px solid rgba(255,255,255,0.25);
  background-color: rgba(255,255,255,0.1);
  color: #ffffff;
  border-radius: var(--border-radius-sm);
  padding: 0 10px;
  font-size: 13px;
}

.sync-input::placeholder {
  color: rgba(255,255,255,0.4);
}

.sync-input:focus {
  outline: none;
  background-color: rgba(255,255,255,0.2);
  border-color: var(--cca-gold);
}

.sync-btn-connect {
  height: 38px;
  background-color: var(--cca-gold);
  color: var(--cca-blue-dark);
  font-weight: bold;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 13px;
}

.sync-btn-connect:hover {
  background-color: #fcd34d;
}

.sync-logs-area {
  margin-top: 15px;
  background-color: rgba(0,0,0,0.3);
  padding: 12px;
  border-radius: var(--border-radius-sm);
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  max-height: 120px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.1);
}

.sync-log-line {
  margin-bottom: 4px;
  border-bottom: 1px dashed rgba(255,255,255,0.05);
  padding-bottom: 4px;
  white-space: pre-wrap;
  color: #a7f3d0;
}

.sync-log-line.fail {
  color: #fca5a5;
}

/* --- ADMIN MODULE TABLES & UTILS --- */
.user-management-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn-admin-add {
  background-color: var(--cca-blue-primary);
  color: #ffffff;
  height: 38px;
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 0 16px;
  font-weight: bold;
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-admin-add:hover {
  background-color: var(--cca-blue-hover);
}

/* Modal form layouts */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background-color: #ffffff;
  width: 90%;
  max-width: 580px;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 24px;
  background-color: var(--cca-blue-dark);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-close-modal {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
}

.btn-close-modal:hover {
  opacity: 1;
}

.modal-body {
  padding: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

/* Toast notices */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #1e293b;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 14.5px;
  font-weight: 500;
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

/* Mobile responsive fixes */
@media (max-width: 768px) {
  .dashboard-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  
  .dashboard-sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .topbar-menu-btn {
    display: flex;
  }
  
  .login-screen {
    flex-direction: column;
  }
  
  .login-banner {
    display: none;
  }
  
  .login-form-container {
    flex: 1;
    padding: 20px;
  }
}

/* Custom Profile Configuration Styles */
.config-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .config-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.config-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: var(--bg-card);
  padding: 16px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  height: fit-content;
}

.config-tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: none;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.config-tab-btn:hover {
  background-color: var(--bg-app);
  color: var(--cca-blue-primary);
}

.config-tab-btn.active {
  background-color: var(--info-bg);
  color: var(--cca-blue-primary);
  font-weight: bold;
}

.config-content-panel {
  background-color: var(--bg-card);
  padding: 24px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
}

.config-panel-title {
  font-size: 17px;
  font-weight: bold;
  color: var(--cca-blue-dark);
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-field-group {
  margin-bottom: 16px;
}

.config-checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background-color: #f8fafc;
  border-radius: var(--border-radius-sm);
  border: 1.5px solid var(--border-color);
}

.config-checkbox-group input {
  margin-top: 3px;
}

.theme-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.theme-preview-card {
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 16px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.theme-preview-card:hover {
  border-color: var(--cca-blue-primary);
}

.theme-preview-card.active {
  border-color: var(--cca-blue-primary);
  background-color: var(--info-bg);
}

.theme-swatch-light {
  height: 40px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius-sm);
  margin-bottom: 8px;
}

.theme-swatch-dark {
  height: 40px;
  background-color: #1e293b;
  border: 1px solid #0f172a;
  border-radius: var(--border-radius-sm);
  margin-bottom: 8px;
}

.theme-swatch-system {
  height: 40px;
  background: linear-gradient(90deg, #f8fafc 50%, #1e293b 50%);
  border: 1px solid #cbd5e1;
  border-radius: var(--border-radius-sm);
  margin-bottom: 8px;
}
