﻿/* =============================================
   style.css - เธฃเธฐเธเธเน€เธเนเธเธเธทเนเธญเธเธฑเธเน€เธฃเธตเธขเธ
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #1a56db;
  --primary-dark: #1341a8;
  --primary-light: #e8f0fe;
  --secondary: #0e9f6e;
  --secondary-light: #def7ec;
  --danger: #f05252;
  --danger-light: #fde8e8;
  --warning: #e3a008;
  --warning-light: #fdf6b2;
  --info: #3f83f8;
  --info-light: #e1effe;
  --dark: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;
  --sidebar-w: 260px;
  --header-h: 60px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --transition: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  color: var(--gray-700);
  background: var(--gray-50);
  min-height: 100vh;
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a56db 0%, #0e9f6e 100%);
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, #1a56db, #1341a8);
  color: white;
  padding: 32px 32px 24px;
  text-align: center;
}
.login-header .school-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}
.login-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-header p { font-size: 13px; opacity: 0.85; }
.login-role-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  margin-top: 10px;
}
.login-body { padding: 28px 32px 32px; }
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.input-wrap { position: relative; }
.input-wrap input {
  width: 100%;
  padding: 10px 42px 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  color: var(--gray-800);
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--white);
}
.input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 17px;
  padding: 2px;
  transition: color var(--transition);
}
.toggle-pw:hover { color: var(--primary); }
.btn-login {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 6px;
}
.btn-login:hover { opacity: 0.92; transform: translateY(-1px); }
.login-links {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--gray-500);
}
.login-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  margin: 0 8px;
}
.login-links a:hover { text-decoration: underline; }
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-danger { background: var(--danger-light); color: #9b1c1c; border-left: 3px solid var(--danger); }
.alert-success { background: var(--secondary-light); color: #03543f; border-left: 3px solid var(--secondary); }
.alert-info { background: var(--info-light); color: #1e429f; border-left: 3px solid var(--info); }
.alert-warning { background: var(--warning-light); color: #92400e; border-left: 3px solid var(--warning); }

/* classroom select in parent login */
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  color: var(--gray-800);
  background: var(--white);
  cursor: pointer;
  transition: border-color var(--transition);
}
.form-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.15); }

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--gray-800);
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow: hidden;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-icon { font-size: 28px; }
.sidebar-brand .brand-name {
  font-size: 15px;
  font-weight: 700;
  color: white;
  line-height: 1.3;
  margin-top: 4px;
}
.sidebar-brand .brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,.5);
}
.sidebar-user {
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}
.user-info .user-name { font-size: 13px; font-weight: 600; color: white; }
.user-info .user-role { font-size: 11px; color: rgba(255,255,255,.5); }
  .sidebar-footer {
    display: flex !important;
    flex: 0 0 auto !important;
    height: 64px !important;
    padding: 0 8px 0 0 !important;
    border-top: 0 !important;
    border-left: 1px solid rgba(255,255,255,.12) !important;
    align-items: center !important;
  }

  .btn-logout {
    width: 58px !important;
    min-width: 58px !important;
    height: 64px !important;
    padding: 0 !important;
    border-radius: 0 !important;
    justify-content: center !important;
    gap: 0 !important;
    font-size: 0 !important;
    background: transparent !important;
  }
  .btn-logout::before {
    content: '🚪';
    font-size: 22px !important;
    color: #fca5a5 !important;
  }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: scroll; overflow-x: hidden; min-height: 0; max-height: calc(100vh - 180px); }
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 8px 20px 4px;
}
.nav-item { display: block; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: white; }
.nav-link.active {
  background: rgba(26,86,219,.25);
  color: white;
  border-left-color: var(--primary);
}
.nav-link .nav-icon { font-size: 17px; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: rgba(240,82,82,.15);
  color: #fca5a5;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}
.btn-logout:hover { background: rgba(240,82,82,.25); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--gray-800); }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--gray-500); }
.page-content { padding: 24px; flex: 1; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.page-subtitle { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: var(--secondary-light); }
.stat-icon.red { background: var(--danger-light); }
.stat-icon.yellow { background: var(--warning-light); }
.stat-icon.purple { background: #f3e8ff; }
.stat-info .stat-value { font-size: 26px; font-weight: 700; color: var(--gray-800); line-height: 1; }
.stat-info .stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--secondary); color: white; }
.btn-success:hover { background: #057a55; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c81e1e; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-light); }

/* ===== FORM ===== */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-col { flex: 1; min-width: 200px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: 7px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-control-sm { padding: 6px 10px; font-size: 13px; }

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-present { background: #d1fae5; color: #065f46; }
.status-absent { background: #fee2e2; color: #991b1b; }
.status-late { background: #fef3c7; color: #92400e; }
.status-leave { background: #dbeafe; color: #1e40af; }
.status-sick { background: #ede9fe; color: #5b21b6; }

/* ===== ATTENDANCE GRID ===== */
.attendance-grid { display: flex; flex-direction: column; gap: 4px; }
.att-student-row {
  display: grid;
  grid-template-columns: 40px 1fr repeat(5,80px);
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}
.att-student-row:hover { background: var(--gray-50); }
.att-num { font-size: 13px; color: var(--gray-400); text-align: center; }
.att-name { font-size: 14px; font-weight: 500; }
.att-code { font-size: 11px; color: var(--gray-400); }
.att-btn {
  padding: 5px 8px;
  border: 1.5px solid var(--gray-300);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  background: white;
  transition: all var(--transition);
  text-align: center;
}
.att-btn:hover { transform: scale(1.05); }
.att-btn.active-present { background: #d1fae5; border-color: #10b981; color: #065f46; }
.att-btn.active-absent { background: #fee2e2; border-color: #f05252; color: #991b1b; }
.att-btn.active-late { background: #fef3c7; border-color: #e3a008; color: #92400e; }
.att-btn.active-leave { background: #dbeafe; border-color: #3f83f8; color: #1e40af; }
.att-btn.active-sick { background: #ede9fe; border-color: #8b5cf6; color: #5b21b6; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-400); padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Sarabun', sans-serif;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== SUMMARY / REPORT ===== */
.summary-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.summary-item {
  flex: 1;
  min-width: 100px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.summary-item .val { font-size: 28px; font-weight: 700; }
.summary-item .lbl { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ===== PARENT SUMMARY ===== */
.att-calendar {
  display: grid;
  grid-template-columns: repeat(7,1fr);
  gap: 4px;
}
.att-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.att-day.header { background: var(--gray-100); color: var(--gray-600); font-size: 11px; }
.att-day.present { background: #d1fae5; color: #065f46; }
.att-day.absent { background: #fee2e2; color: #991b1b; }
.att-day.late { background: #fef3c7; color: #92400e; }
.att-day.leave { background: #dbeafe; color: #1e40af; }
.att-day.sick { background: #ede9fe; color: #5b21b6; }
.att-day.holiday { background: var(--gray-100); color: var(--gray-400); }
.att-day.empty { background: transparent; }

/* ===== UTILS ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; } .align-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }

/* ===== RESPONSIVE ===== */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-700);
  padding: 4px 8px;
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .att-student-row { grid-template-columns: 30px 1fr; }
  .att-status-btns { grid-column: 1/-1; display: flex; gap: 4px; flex-wrap: wrap; }
}

/* ===== COLLAPSIBLE SIDEBAR FIX ===== */
.sidebar {
  width: var(--sidebar-w);
  overflow: visible !important;
}

.main-content {
  margin-left: var(--sidebar-w);
  transition: margin-left .2s ease;
}

body.sidebar-collapsed {
  --sidebar-w: 76px;
}

.sidebar > .sidebar-collapse-toggle {
  position: fixed !important;
  left: var(--sidebar-w) !important;
  top: 50% !important;
  transform: translateY(-50%) !important;

  width: 24px !important;
  min-width: 24px !important;
  max-width: 24px !important;

  height: 132px !important;
  min-height: 132px !important;
  max-height: 132px !important;

  padding: 0 !important;
  margin: 0 !important;

  border: 1px solid #d1d5db !important;
  border-left: 0 !important;
  border-radius: 0 8px 8px 0 !important;
  background: #edf0f3 !important;
  color: #374151 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.12) !important;

  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  flex: 0 0 24px !important;
  align-self: auto !important;
  appearance: none !important;
  -webkit-appearance: none !important;

  cursor: pointer !important;
  z-index: 9999 !important;
  font-size: 24px !important;
  line-height: 1 !important;
}

body.sidebar-collapsed .sidebar-collapse-toggle .collapse-chevron {
  transform: rotate(180deg);
}

body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .brand-sub,
body.sidebar-collapsed .user-info,
body.sidebar-collapsed .nav-section-label {
  display: none;
}

body.sidebar-collapsed .sidebar-user,
body.sidebar-collapsed .nav-link,
body.sidebar-collapsed .btn-logout {
  justify-content: center;
}

body.sidebar-collapsed .nav-link {
  gap: 0;
  padding: 12px 0;
  font-size: 0;
}

body.sidebar-collapsed .nav-link .nav-icon {
  width: auto;
  font-size: 20px;
}

body.sidebar-collapsed .btn-logout {
  font-size: 0;
  gap: 0;
}
.sidebar-collapse-toggle .collapse-chevron {
  display: block;
  transition: transform .2s ease;
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
  }

  .sidebar-collapse-toggle {
    display: none !important;
  }
}
/* เนเธเนเนเธ version เธกเธทเธญเธ–เธทเธญ */
@media (max-width: 768px) {
  body.sidebar-collapsed {
    --sidebar-w: 0px;
  }

  .sidebar {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: auto !important;
    width: 100% !important;
    height: 64px !important;
    transform: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-direction: row !important;
    align-items: center !important;
    z-index: 9999 !important;
    border-bottom: 1px solid rgba(255,255,255,.12);
  }

  .sidebar-brand,
  .sidebar-user,
  .nav-section-label,
  .sidebar-collapse-toggle,
  .menu-toggle {
    display: none !important;
  }
  .sidebar-footer {
    display: flex !important;
    flex: 0 0 auto !important;
    height: 64px !important;
    padding: 0 8px 0 0 !important;
    border-top: 0 !important;
    border-left: 1px solid rgba(255,255,255,.12) !important;
    align-items: center !important;
  }

  .btn-logout {
    width: 58px !important;
    min-width: 58px !important;
    height: 64px !important;
    padding: 0 !important;
    border-radius: 0 !important;
    justify-content: center !important;
    gap: 0 !important;
    font-size: 0 !important;
    background: transparent !important;
  }
  .btn-logout::before {
    content: '🚪';
    font-size: 22px !important;
    color: #fca5a5 !important;
  }

  .sidebar-nav {
    display: flex !important;
    flex: 1 !important;
    height: 64px !important;
    max-height: none !important;
    padding: 0 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
  }

  .nav-link {
    width: 58px !important;
    min-width: 58px !important;
    height: 64px !important;
    padding: 0 !important;
    border-left: 0 !important;
    border-bottom: 3px solid transparent !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 0 !important;
    font-size: 0 !important;
  }

  .nav-link.active {
    border-left-color: transparent !important;
    border-bottom-color: var(--primary) !important;
  }

  .nav-link .nav-icon {
    width: auto !important;
    font-size: 22px !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding-top: 64px !important;
    padding-bottom: 0 !important;
  }
}

/*เธ•เธฑเธงเธเธตเนเน€เธเธดเนเธกเธฅเนเธฒเธชเธธเธ”*/
@media (max-width: 768px) {
  .sidebar-collapse-toggle,
  .sidebar > .sidebar-collapse-toggle,
  body.sidebar-collapsed .sidebar-collapse-toggle,
  body.sidebar-collapsed .sidebar > .sidebar-collapse-toggle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
}



/* ===== DESKTOP LOGOUT TEXT ===== */
@media (min-width: 769px) {
  body:not(.sidebar-collapsed) .sidebar-footer {
    display: block !important;
    padding: 12px 16px !important;
    border-top: 1px solid rgba(255,255,255,.08) !important;
  }

  body:not(.sidebar-collapsed) .btn-logout {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    height: auto !important;
    min-width: 0 !important;
    padding: 9px 14px !important;
    border-radius: 7px !important;
    font-size: 14px !important;
    background: rgba(240,82,82,.15) !important;
    color: #fca5a5 !important;
  }

  body:not(.sidebar-collapsed) .btn-logout::before {
    content: none !important;
  }
}

/* ===== DARK MODE ===== */
html.theme-dark body,
body.theme-dark {
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-light: #1e3a5f;
  --secondary: #34d399;
  --secondary-light: #064e3b;
  --danger-light: #4c1d1d;
  --warning-light: #451a03;
  --info-light: #172554;
  --dark: #f9fafb;
  --gray-800: #f3f4f6;
  --gray-700: #e5e7eb;
  --gray-600: #d1d5db;
  --gray-500: #9ca3af;
  --gray-400: #6b7280;
  --gray-300: #4b5563;
  --gray-200: #374151;
  --gray-100: #1f2937;
  --gray-50: #111827;
  --white: #182231;
  --shadow: 0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.28);
  --shadow-md: 0 4px 10px rgba(0,0,0,.32);
  --shadow-lg: 0 18px 40px rgba(0,0,0,.38);
  color-scheme: dark;
}

html.theme-dark body,
body.theme-dark {
  background: #0f172a;
  color: var(--gray-700);
}

body.theme-dark .main-content,
body.theme-dark .page-content {
  background: #0f172a;
}

body.theme-dark .sidebar {
  background: #111827;
}

body.theme-dark .topbar,
body.theme-dark .card,
body.theme-dark .stat-card,
body.theme-dark .summary-item,
body.theme-dark .modal,
body.theme-dark .modal-box,
body.theme-dark .login-card {
  background: var(--white);
  border-color: var(--gray-200);
}

body.theme-dark .att-row,
body.theme-dark .att-header-row,
body.theme-dark .att-student-row,
body.theme-dark tbody tr:hover,
body.theme-dark .att-row:hover,
body.theme-dark thead th {
  background: var(--gray-50);
}

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark .input-wrap input,
body.theme-dark .note-input,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #0f172a;
  border-color: var(--gray-300);
  color: var(--gray-700);
}

body.theme-dark .att-status-btn,
body.theme-dark .att-sb,
body.theme-dark .att-btn,
body.theme-dark .btn-outline,
body.theme-dark .btn-lock-att {
  background: #0f172a;
  border-color: var(--gray-300);
  color: var(--gray-700);
}

body.theme-dark [style*="background:white"],
body.theme-dark [style*="background: white"],
body.theme-dark [style*="background:#fff"],
body.theme-dark [style*="background: #fff"],
body.theme-dark [style*="background:#ffffff"],
body.theme-dark [style*="background: #ffffff"] {
  background: var(--white) !important;
}

body.theme-dark [style*="background:#f3f4f6"],
body.theme-dark [style*="background: #f3f4f6"],
body.theme-dark [style*="background:#f9fafb"],
body.theme-dark [style*="background: #f9fafb"] {
  background: var(--gray-50) !important;
}

body.theme-dark [style*="color:#374151"],
body.theme-dark [style*="color: #374151"],
body.theme-dark [style*="color:#111827"],
body.theme-dark [style*="color: #111827"] {
  color: var(--gray-700) !important;
}

body.theme-dark .theme-toggle-btn {
  background: #111827;
  border-color: #475569;
  color: #fde68a;
}

.theme-toggle-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border: 1.5px solid var(--gray-300);
  border-radius: 9px;
  background: var(--white);
  color: var(--gray-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  color: var(--primary);
}

.topbar-logout-btn {
  height: 34px;
  padding: 0 12px;
  border: 1.5px solid #fecaca;
  border-radius: 9px;
  background: #fff7f7;
  color: #dc2626;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.topbar-logout-btn:hover {
  transform: translateY(-1px);
  border-color: #ef4444;
  background: #fee2e2;
  color: #b91c1c;
}

body.theme-dark .topbar-logout-btn {
  border-color: #7f1d1d;
  background: #2b1717;
  color: #fca5a5;
}

@media (max-width: 480px) {
  .topbar-logout-btn {
    width: 34px;
    min-width: 34px;
    padding: 0;
  }

  .topbar-logout-label {
    display: none;
  }
}
