/* ══════════════════════════════════════════════════════
   ScabiesGuard — Student Monitor System
   Complete Responsive CSS
   ══════════════════════════════════════════════════════ */

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --danger: #dc3545;
  --danger-light: #fde8ea;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --success: #10b981;
  --success-light: #d1fae5;
  --info: #6366f1;
  --info-light: #e0e7ff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --bg-body: #f0f4f8;
  --bg-card: #ffffff;
  --bg-sidebar: #111827;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 260px;
  --header-height: 60px;
  --bottom-nav-height: 64px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── SCROLLBAR ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ══════════════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════════════ */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a73e8 0%, #6366f1 50%, #8b5cf6 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 30px 30px;
  animation: loginBgMove 20s linear infinite;
}

@keyframes loginBgMove {
  from { transform: translate(0, 0); }
  to { transform: translate(30px, 30px); }
}

.login-card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--info));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 36px;
  color: white;
  box-shadow: 0 8px 24px rgba(26,115,232,0.3);
}

.login-header h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-form label i {
  margin-right: 6px;
  color: var(--primary);
}

.login-form input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
  background: var(--bg-body);
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(26,115,232,0.1);
  background: white;
}

.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 16px;
}

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(26,115,232,0.3);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,115,232,0.4); }
.btn-primary:active { transform: translateY(0); }

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

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

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

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

.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }

.btn-icon {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  font-size: 16px;
}
.btn-icon:hover { background: var(--bg-body); color: var(--primary); }

/* ══════════════════════════════════════════════════════
   TOP HEADER
   ══════════════════════════════════════════════════════ */

.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  margin-right: 8px;
}

.header-brand {
  display: none;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

.header-brand i { font-size: 22px; }

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

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-header {
  padding: 28px 24px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--info));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 24px;
  color: white;
}

.sidebar-header h2 {
  color: white;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-subtitle {
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  margin-top: 2px;
}

.nav-menu {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  color: rgba(255,255,255,0.6);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
}

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

.nav-item.active {
  color: white;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(26,115,232,0.4);
}

.nav-item i { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}

.sidebar-footer p {
  color: rgba(255,255,255,0.3);
  font-size: 11px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

/* ══════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════ */

.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 24px;
  min-height: calc(100vh - var(--header-height));
}

.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header h1 i { color: var(--primary); font-size: 22px; }

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  width: 100%;
}

/* ══════════════════════════════════════════════════════
   STATS CARDS
   ══════════════════════════════════════════════════════ */

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

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-total { border-left-color: var(--primary); }
.stat-infected { border-left-color: var(--danger); }
.stat-treatment { border-left-color: var(--warning); }
.stat-cured { border-left-color: var(--success); }
.stat-healthy { border-left-color: #06b6d4; }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-total .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-infected .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-treatment .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-cured .stat-icon { background: var(--success-light); color: var(--success); }
.stat-healthy .stat-icon { background: #cffafe; color: #06b6d4; }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--text-primary); }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-top: 2px; }

/* ══════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h3 i { color: var(--primary); font-size: 16px; }

.card-body { padding: 20px; }

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

/* ══════════════════════════════════════════════════════
   DATA TABLE
   ══════════════════════════════════════════════════════ */

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table thead {
  background: var(--bg-body);
}

.data-table th {
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-align: left;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: var(--primary-light); }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-healthy { background: var(--success-light); color: #059669; }
.badge-infected { background: var(--danger-light); color: var(--danger); }
.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-under_treatment, .badge-under-treatment { background: var(--warning-light); color: #d97706; }
.badge-cured { background: #dbeafe; color: var(--primary); }
.badge-mild { background: var(--warning-light); color: #d97706; }
.badge-moderate { background: #fed7aa; color: #c2410c; }
.badge-severe { background: var(--danger-light); color: var(--danger); }
.badge-active { background: var(--success-light); color: #059669; }
.badge-completed { background: var(--primary-light); color: var(--primary); }
.badge-pending { background: var(--warning-light); color: #d97706; }
.badge-ongoing { background: var(--info-light); color: var(--info); }

/* ══════════════════════════════════════════════════════
   FILTERS
   ══════════════════════════════════════════════════════ */

.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(26,115,232,0.1);
}

.filter-select {
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 150px;
  transition: var(--transition);
}

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

/* ══════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════ */

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(26,115,232,0.1);
}

textarea.form-control { resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-body);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.checkbox-label:has(input:checked) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
}

.range-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  margin-top: 4px;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ══════════════════════════════════════════════════════
   IMAGE UPLOAD
   ══════════════════════════════════════════════════════ */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 16px;
  background: var(--bg-body);
  position: relative;
  overflow: hidden;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone-small { padding: 20px; }

.upload-placeholder i {
  font-size: 40px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.upload-placeholder p {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.upload-placeholder span {
  font-size: 12px;
  color: var(--text-light);
}

.image-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

/* ══════════════════════════════════════════════════════
   DETECTION LAYOUT
   ══════════════════════════════════════════════════════ */

.detection-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.detection-upload-card { grid-row: 1 / 3; }

/* ══════════════════════════════════════════════════════
   TIMELINE
   ══════════════════════════════════════════════════════ */

.timeline {
  position: relative;
  padding-left: 30px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
  animation: fadeIn 0.3s ease;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.timeline-item.type-detection::before { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-light); }
.timeline-item.type-treatment::before { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-light); }
.timeline-item.type-checkup::before { background: var(--success); box-shadow: 0 0 0 3px var(--success-light); }
.timeline-item.type-medication_applied::before { background: var(--info); box-shadow: 0 0 0 3px var(--info-light); }

.timeline-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--primary);
}

.timeline-card h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-light);
}

.timeline-meta i { font-size: 11px; }

/* ══════════════════════════════════════════════════════
   DETECTION HISTORY ITEMS
   ══════════════════════════════════════════════════════ */

.detection-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.detection-item:last-child { border-bottom: none; }

.detection-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-body);
}

.detection-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

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

/* ══════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlide 0.3s ease;
}

.modal-large { max-width: 800px; }

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header h3 i { color: var(--primary); }

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-light);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: var(--transition);
}
.modal-close:hover { color: var(--danger); }

.modal-body { padding: 24px; }

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

/* Student Detail sections */
.detail-section { margin-bottom: 24px; }
.detail-section h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.detail-item {
  padding: 10px 14px;
  background: var(--bg-body);
  border-radius: var(--radius-sm);
}

.detail-item .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-item .value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════════
   CHART BARS (CSS-only)
   ══════════════════════════════════════════════════════ */

.chart-bar-container { margin-top: 8px; }

.chart-bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-bar-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 80px;
  text-align: right;
}

.chart-bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg-body);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 12px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding-left: 10px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  min-width: 32px;
}

.chart-bar-fill.bar-primary { background: linear-gradient(90deg, var(--primary), #3b82f6); }
.chart-bar-fill.bar-danger { background: linear-gradient(90deg, var(--danger), #ef4444); }
.chart-bar-fill.bar-warning { background: linear-gradient(90deg, var(--warning), #f59e0b); }
.chart-bar-fill.bar-success { background: linear-gradient(90deg, var(--success), #34d399); }

/* ══════════════════════════════════════════════════════
   AI DETECTION RESULT PANEL
   ══════════════════════════════════════════════════════ */

.ai-result-panel {
  margin-top: 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  animation: fadeIn 0.4s ease;
}

.ai-result-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  color: white;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.ai-result-header.result-positive { background: linear-gradient(135deg, #dc3545, #ef4444); }
.ai-result-header.result-negative { background: linear-gradient(135deg, #10b981, #34d399); }

.ai-result-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.ai-result-header h3 { font-size: 18px; font-weight: 700; margin: 0; }
.ai-result-header p { font-size: 12px; opacity: 0.85; margin: 2px 0 0; }

.ai-confidence-bar {
  padding: 16px 20px;
  background: var(--bg-body);
}

.ai-confidence-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.ai-confidence-label strong {
  font-size: 24px;
  color: var(--text-primary);
}

.ai-confidence-track {
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.ai-confidence-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #10b981, #f59e0b, #dc3545);
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
}

.ai-detail-item {
  padding: 14px 16px;
  background: var(--bg-card);
  text-align: center;
}

.ai-detail-item .ai-detail-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.ai-detail-item .ai-detail-label {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.ai-recommendations {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.ai-recommendations h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-rec-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.ai-rec-item:last-child { border-bottom: none; }

.ai-rec-priority {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.ai-rec-priority.priority-urgent { background: #fee2e2; color: #b91c1c; }
.ai-rec-priority.priority-high { background: #fed7aa; color: #c2410c; }
.ai-rec-priority.priority-medium { background: var(--warning-light); color: #d97706; }
.ai-rec-priority.priority-low { background: var(--primary-light); color: var(--primary); }
.ai-rec-priority.priority-info { background: #e0e7ff; color: #4f46e5; }

.ai-rec-text { color: var(--text-secondary); line-height: 1.4; }

/* ML Status badge */
.ml-status {
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--success-light);
  color: #059669;
}

.ml-status i { font-size: 7px; }
.ml-status.status-offline { background: var(--danger-light); color: var(--danger); }

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

/* Loading state for detection button */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading i {
  animation: spin 1s linear infinite;
}

/* Detection result badge in history */
.detection-result-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.detection-result-badge.scabies-positive { background: #fee2e2; color: #b91c1c; }
.detection-result-badge.scabies-negative { background: var(--success-light); color: #059669; }

/* ══════════════════════════════════════════════════════
   TOAST NOTIFICATION
   ══════════════════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937;
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: var(--transition);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast i { color: var(--success); font-size: 18px; }
.toast.toast-error i { color: var(--danger); }

/* ══════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* ══════════════════════════════════════════════════════
   BOTTOM NAVIGATION (Mobile)
   ══════════════════════════════════════════════════════ */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  min-width: 56px;
}

.bottom-nav-item i { font-size: 20px; }

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active i {
  transform: scale(1.1);
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 1024px)
   ══════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }

  .top-header { left: 0; }
  .menu-toggle { display: block; }
  .header-brand { display: flex; }

  .main-content { margin-left: 0; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .detection-layout { grid-template-columns: 1fr; }
  .detection-upload-card { grid-row: auto; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
   ══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .main-content {
    padding: 16px;
    padding-bottom: calc(var(--bottom-nav-height) + 20px);
  }

  .bottom-nav { display: flex; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }

  .page-header h1 { font-size: 20px; }
  .page-header .btn .btn-text { display: none; }

  .form-row { grid-template-columns: 1fr; gap: 0; }

  .modal { margin: 10px; max-height: 95vh; }
  .modal-body { padding: 16px; }

  .detail-grid { grid-template-columns: 1fr; }

  .data-table th, .data-table td {
    padding: 10px 12px;
    font-size: 13px;
  }

  .user-name { display: none; }

  .filters-bar { flex-direction: column; }
  .filter-select { min-width: 100%; }

  .detection-layout { grid-template-columns: 1fr; }

  .login-card { padding: 28px 24px; }
  .login-icon { width: 64px; height: 64px; font-size: 28px; }
  .login-header h1 { font-size: 24px; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — SMALL PHONE (≤ 480px)
   ══════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding: 12px;
  }

  .stat-icon { margin: 0 auto; width: 36px; height: 36px; font-size: 16px; }
  .stat-value { font-size: 20px; }

  .page-header h1 { font-size: 18px; }

  .checkbox-group { gap: 6px; }
  .checkbox-label { font-size: 12px; padding: 4px 10px; }

  .upload-zone { padding: 20px; }
  .upload-placeholder i { font-size: 32px; }

  .bottom-nav-item { min-width: 48px; padding: 6px 8px; }
  .bottom-nav-item span { font-size: 9px; }
}

/* ══════════════════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════════════════ */

@media print {
  .sidebar, .top-header, .bottom-nav, .modal-overlay, .btn, .filters-bar { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .stat-card { break-inside: avoid; }
}

/* ══════════════════════════════════════════════════════
   ACCESSIBILITY & ANIMATIONS
   ══════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Loading spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }
