@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,700;1,9..40,400&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #0d6efd;
  --primary-dark: #0b5ed7;
  --page: #f0f2f5;
  --card-bg: #ffffff;
  --radius: 16px;
  --transition: 0.25s ease;
  --student-accent: #6d28d9;
  --student-light: #ede9fe;
  --student-gradient: linear-gradient(135deg, #7c3aed, #a78bfa);
  --teacher-accent: #dc2626;
  --teacher-light: #fef2f2;
  --teacher-gradient: linear-gradient(135deg, #dc2626, #f97316);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

/* Reset & base */
* { box-sizing: border-box; }
html { height: 100%; }
body {
  min-height: 100svh;
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--page);
  display: grid;
  place-items: center;       /* centers the card */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px 36px;
  background: var(--card-bg);       /* solid white, no frosted blur */
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
  text-align: center;
  animation: fade-in 0.45s ease both;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
}

.subtitle {
  font-size: 0.95rem;
  color: #6b7280;
  margin-bottom: 24px;
}

/* ---------- Form ---------- */
.field { position: relative; margin-bottom: 14px; }

.field input {
  width: 100%;
  padding: 14px 44px 14px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.field input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12);
}

.toggle-password {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: #9ca3af;
  padding: 2px 6px;
  border-radius: 8px;
}

.toggle-password:hover { color: var(--primary); }

/* ---------- Button ---------- */
.btn {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition), transform 0.05s ease;
}

.btn:hover,
.btn:focus-visible { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }

/* ---------- Messages ---------- */
#message {
  margin-top: 14px;
  font-size: 0.93rem;
  font-weight: 500;
  min-height: 1.2em;
}

.error { color: #d52731; }
.success { color: #269f53; }

/* ---------- Menu Button (hamburger) ---------- */
.menu-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.10);
  transition: background var(--transition), transform 0.05s ease;
  z-index: 1100;
}
.menu-btn i { font-size: 18px; }
.menu-btn:hover { background: #f3f4f6; }
.menu-btn:active { transform: translateY(1px); }

/* ---------- Sidebar Overlay ---------- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  z-index: 1300;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header .sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #60a5fa;
}
.sidebar-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}
.sidebar-close:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #cbd5e1;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-align: left;
  font-family: inherit;
}
.sidebar-item i { width: 20px; text-align: center; font-size: 15px; }
.sidebar-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.sidebar-footer {
  padding: 16px 10px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-item.logout { color: #f87171; }
.sidebar-item.logout:hover { background: rgba(248, 113, 113, 0.12); color: #fca5a5; }

/* ========== MAIN APP STYLES ========== */
body.logged-in {
  display: block;
  place-items: initial;
}

#mainApp {
  max-width: 1600px;
  margin: 70px auto 40px;
  padding: 0 28px;
}

.app-header {
  margin-bottom: 12px;
}

.app-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}
.app-title i { color: #7c3aed; }

.app-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  font-size: 0.95rem;
  outline: none;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.12);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ========== Dashboard Header ========== */
.dash-header {
  margin-bottom: 28px;
}
.dash-header-inner {
  background: linear-gradient(135deg, #1e1b4b, #312e81, #4c1d95);
  border-radius: 20px;
  padding: 28px 32px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(30, 27, 75, 0.3);
}
.dash-header-inner::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(167,139,250,0.25) 0%, transparent 70%);
  pointer-events: none;
}
.dash-header-inner::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: 10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(244,114,182,0.2) 0%, transparent 70%);
  pointer-events: none;
}
.dash-title {
  font-family: 'Outfit', 'DM Sans', sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.dash-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  backdrop-filter: blur(8px);
}
.dash-subtitle {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  color: rgba(255,255,255,0.7);
  margin-left: 54px;
  position: relative;
  z-index: 1;
}

/* ========== Two-Column Grid ========== */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 860px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

.dash-col {
  min-width: 0;
}

/* ========== Column Panel ========== */
.col-panel {
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid #e5e7eb;
  transition: box-shadow 0.2s;
}
.col-panel:hover {
  box-shadow: var(--shadow-lg);
}

.col-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid #f3f4f6;
  position: relative;
}
.col-panel-header--student {
  background: linear-gradient(135deg, #faf5ff, #ede9fe);
}
.col-panel-header--teacher {
  background: linear-gradient(135deg, #fff7ed, #fef2f2);
}

.col-panel-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--student-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(124,58,237,0.3);
}
.col-panel-icon--teacher {
  background: var(--teacher-gradient);
  box-shadow: 0 4px 12px rgba(220,38,38,0.3);
}

.col-panel-title {
  font-family: 'Outfit', 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: #111827;
}
.col-panel-desc {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 1px;
}

.col-count-badge {
  margin-left: auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: 'Outfit', 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}
.col-count-badge--student {
  background: var(--student-gradient);
  box-shadow: 0 4px 12px rgba(124,58,237,0.25);
}
.col-count-badge--teacher {
  background: var(--teacher-gradient);
  box-shadow: 0 4px 12px rgba(220,38,38,0.25);
}

.col-search-bar {
  padding: 14px 16px 8px;
}
.col-search-bar .email-search-input {
  height: 42px;
  border-radius: 12px;
  font-size: 0.88rem;
  border-width: 1.5px;
}

.col-list-header {
  padding: 8px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: #6d28d9;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #f3f4f6;
}
.col-list-header--teacher {
  color: #dc2626;
}
.col-list-header i {
  font-size: 0.7rem;
}

/* Override student-list inside panel */
.col-panel .student-list {
  padding: 12px 14px 16px;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
}
.col-panel .student-list::-webkit-scrollbar {
  width: 5px;
}
.col-panel .student-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

/* Compact student cards inside columns */
.col-panel .s-card {
  padding: 12px 14px;
  border-radius: 12px;
  gap: 12px;
}
.col-panel .s-name {
  font-size: 0.92rem;
}
.col-panel .s-email {
  font-size: 0.8rem;
}
.col-panel .leave-dates {
  font-size: 0.78rem;
}
.col-panel .action-btn {
  padding: 6px 10px;
  font-size: 0.82rem;
}

/* ========== Student Offday Card (sc-*) ========== */
.sc-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.sc-card:hover {
  box-shadow: 0 3px 14px rgba(0,0,0,0.06);
}
.sc-card--active {
  background: #faf5ff;
}
.sc-card--future {
  background: #fffbeb;
}

.sc-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px 6px;
}
.sc-person {
  flex: 1;
  min-width: 0;
}
.sc-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #111827;
  line-height: 1.3;
}
.sc-email {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.sc-meta .leave-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
}
.sc-actions {
  display: flex;
  gap: 3px;
}
.sc-btn {
  width: 26px;
  height: 26px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 11px;
  transition: all 0.12s;
}
.sc-btn-edit {
  color: #7c3aed;
  border-color: rgba(124,58,237,0.2);
}
.sc-btn-edit:hover {
  background: #f5f3ff;
  box-shadow: 0 2px 6px rgba(124,58,237,0.15);
}
.sc-btn-del {
  color: #dc2626;
  border-color: rgba(220,38,38,0.2);
}
.sc-btn-del:hover {
  background: #fef2f2;
  box-shadow: 0 2px 6px rgba(220,38,38,0.15);
}

.sc-dates-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 12px;
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border-top: 1px solid #f0eef5;
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
}
.sc-card--future .sc-dates-bar {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
}
.sc-dates-bar > i {
  color: #7c3aed;
  font-size: 0.72rem;
}
.sc-card--future .sc-dates-bar > i {
  color: #d97706;
}
.sc-day-count {
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: #7c3aed;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 2px;
}
.sc-card--future .sc-day-count {
  background: #d97706;
}

.sc-day-rows {
  padding: 6px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sc-day-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f0fdf4;
  border: 1px solid #dcfce7;
  font-size: 0.74rem;
}
.sc-day-row:hover {
  background: #dcfce7;
}
.sc-day-row--skip {
  background: #fffbeb;
  border-color: #fde68a;
}
.sc-day-row--skip:hover {
  background: #fef3c7;
}
.sc-day-row--pending {
  background: #f9fafb;
  border-color: #e5e7eb;
}

.sc-day-off {
  font-weight: 700;
  color: #991b1b;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.sc-day-off i {
  font-size: 0.6rem;
  color: #dc2626;
}

.sc-arrow {
  color: #b0b7c3;
  font-size: 0.65rem;
  flex-shrink: 0;
}

.sc-day-makeup {
  font-weight: 700;
  color: #166534;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.sc-day-makeup i {
  font-size: 0.6rem;
  color: #22c55e;
}

.sc-day-skip {
  font-weight: 600;
  color: #d97706;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.sc-day-skip i {
  font-size: 0.6rem;
  color: #f59e0b;
}

.sc-day-pending {
  font-weight: 600;
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-style: italic;
}
.sc-day-pending i {
  font-size: 0.55rem;
}

.sc-day-note {
  margin-left: auto;
  color: #a78bfa;
  font-size: 0.68rem;
  cursor: help;
}

/* Compact teacher cards inside columns */
.col-panel .tg-card {
  border-radius: 12px;
}
.col-panel .tg-header {
  padding: 10px 14px;
}
.col-panel .tg-email {
  font-size: 0.88rem;
}
.col-panel .tg-body {
  padding: 4px 10px 8px;
}
.col-panel .tg-combined-range {
  font-size: 0.88rem;
}

/* Section header & divider no longer needed */
.section-header { display: none; }
.section-divider { display: none; }

/* ========== Student Cards ========== */
.student-list { display: flex; flex-direction: column; gap: 10px; }

.s-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 14px 18px;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.s-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border-color: #cbd5e1;
}
.s-card.on-leave {
  border-left: none;
  background: #faf5ff;
}

.s-info { flex: 1; min-width: 0; }
.s-name { font-weight: 700; font-size: 1rem; color: #111827; }
.s-email { font-size: 0.85rem; color: #6b7280; margin-top: 2px; }
.s-class { font-size: 0.8rem; color: #4f46e5; font-weight: 600; margin-top: 4px; }

.s-leave-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 140px;
}

.leave-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.leave-dates {
  font-size: 0.82rem;
  color: #374151;
  font-weight: 500;
}
.leave-dates.no-leave {
  color: #9ca3af;
  font-style: italic;
}

.s-actions { flex-shrink: 0; }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 10px;
  background: rgba(245,243,255,0.9);
  color: #7c3aed;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.action-btn:hover {
  background: #f5f3ff;
  box-shadow: 0 4px 12px rgba(124,58,237,0.18);
  transform: translateY(-1px);
}

.loading, .empty-msg, .error-msg {
  text-align: center;
  padding: 24px;
  color: #6b7280;
  font-size: 0.95rem;
}
.error-msg { color: #dc2626; }

/* ========== Modal ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(3px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  width: min(460px, 92vw);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(16,24,40,0.18);
  animation: modalIn 0.18s ease both;
  overflow: hidden;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}
.modal-close {
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  padding: 6px 8px;
  border-radius: 8px;
}
.modal-close:hover { background: rgba(255,255,255,0.25); }

.modal-body { padding: 18px; }
.modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid #eef2f7;
  justify-content: flex-end;
}
.modal-footer .btn { width: auto; padding: 10px 16px; border-radius: 10px; }
.btn-secondary { background: #e5e7eb; color: #111827; }
.btn-secondary:hover { background: #d1d5db; }
.btn-primary { background: linear-gradient(135deg, #7c3aed, #a78bfa); color: #fff; border: none; }
.btn-primary:hover { filter: brightness(1.08); }
.modal-footer #tnClearBtn { margin-right: auto; }

.tn-student-info {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.tn-student-name { font-weight: 700; color: #4c1d95; font-size: 1rem; }
.tn-student-email { font-size: 0.85rem; color: #6b7280; margin-top: 2px; }

.tn-form { display: flex; flex-direction: column; gap: 14px; }
.tn-row { display: flex; flex-direction: column; gap: 6px; }
.tn-row label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tn-row label i { color: #7c3aed; }
.tn-row input[type="date"] {
  height: 44px;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 1rem;
  background: #f9fafb;
}
.tn-row input[type="date"]:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 4px rgba(124,58,237,0.15);
  background: #fff;
}

/* Responsive */
@media (max-width: 640px) {
  .s-card { flex-direction: column; align-items: flex-start; gap: 10px; }
  .s-leave-info { align-items: flex-start; }
}

/* ========== Email Autocomplete ========== */
.email-search-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.email-search-input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 40px;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.email-search-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 4px rgba(124,58,237,0.12);
}
.email-search-input::placeholder {
  color: #b0b7c3;
}

.auto-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
}
.auto-dropdown.show { display: block; }

.auto-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid #f3f4f6;
}
.auto-item:last-child { border-bottom: none; }
.auto-item:hover { background: #f5f3ff; }

.auto-item.no-match {
  cursor: default;
  color: #9ca3af;
  font-style: italic;
  justify-content: center;
}
.auto-item.no-match:hover { background: transparent; }

.auto-name {
  font-weight: 700;
  color: #111827;
  font-size: 0.92rem;
}
.auto-email {
  color: #6b7280;
  font-size: 0.85rem;
  flex: 1;
}
.auto-class {
  font-size: 0.78rem;
  font-weight: 600;
  color: #7c3aed;
  background: #f5f3ff;
  padding: 2px 8px;
  border-radius: 6px;
}

/* ========== Section Header ========== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #374151;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title i { color: #7c3aed; }

/* ========== Future Leave Card ========== */
.s-card.future-leave-card {
  border-left: none;
  background: #fffbeb;
}

.leave-badge.future-leave {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

/* ========== Unified Offday Styles ========== */
.section-divider {
  height: 2px;
  background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
  margin: 32px 0 8px;
}

.s-card.teacher-on-leave {
  border-left: none;
  background: #fef2f2;
}

.s-card.teacher-future-leave {
  border-left: none;
  background: #fffbeb;
}


/* ========== Shift Picker Styles ========== */
.sp-date-header {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e40af;
  padding: 8px 4px 4px;
  border-bottom: 1px solid #e5e7eb;
  margin-top: 4px;
}
.sp-date-header:first-child {
  margin-top: 0;
}

.sp-shift-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 0.92rem;
}
.sp-shift-item:hover {
  background: #f5f3ff;
  border-color: #c7d2fe;
}
.sp-shift-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #7c3aed;
  cursor: pointer;
}

.sp-shift-time {
  font-weight: 600;
  color: #111827;
  min-width: 110px;
}

.sp-shift-dept {
  font-size: 0.78rem;
  font-weight: 600;
  color: #7c3aed;
  background: #f5f3ff;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: auto;
}

/* ========== Off Popup (dynamic popup like meeting app) ========== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 11000;
}

.off-popup {
  background: #fff;
  border-radius: 18px;
  width: min(92vw, 380px);
  box-shadow: 0 24px 48px rgba(16, 24, 40, 0.22);
  overflow: hidden;
  animation: offPopIn 0.18s ease both;
  transition: width 0.25s ease, max-height 0.25s ease;
}
.off-popup.expanded {
  width: min(96vw, 720px);
}


@keyframes offPopIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.off-popup__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #312e81, #4c1d95);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}
.off-popup__header > i:first-child {
  font-size: 1rem;
  opacity: 0.85;
}
.off-popup__x {
  margin-left: auto;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
  transition: background 0.15s;
}
.off-popup__x:hover { background: rgba(255,255,255,0.22); }

.off-popup__body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.off-popup__range {
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(135deg, #faf5ff, #ede9fe);
  border: 1px solid #ddd6fe;
  border-radius: 12px;
}

.off-popup__range-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.off-popup__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4c1d95;
  display: flex;
  align-items: center;
  gap: 6px;
}
.off-popup__date {
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.off-popup__date:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}

.off-popup__range-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.off-popup__search-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter 0.15s;
  margin-top: 2px;
}
.off-popup__search-btn:hover { filter: brightness(1.08); }

.off-popup__back {
  border: none;
  background: none;
  color: #6b7280;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0 0;
  transition: color 0.15s;
}
.off-popup__back:hover { color: #111827; }

.off-popup__selectall {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}
.off-popup__selectall label {
  font-weight: 700;
  font-size: 0.85rem;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.off-popup__selectall input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #7c3aed;
}

.off-popup__shifts {
  max-height: 60vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  padding-right: 4px;
}
.off-popup__shifts::-webkit-scrollbar {
  width: 5px;
}
.off-popup__shifts::-webkit-scrollbar-thumb {
  background: #c7d2fe;
  border-radius: 10px;
}

.off-popup__day-group {
  break-inside: avoid;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 4px;
}

@media (max-width: 500px) {
  .off-popup__shifts {
    grid-template-columns: 1fr;
    max-height: 50vh;
  }
}

.off-popup__shift-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: #4c1d95;
  padding: 6px 4px 3px;
  border-bottom: 1px solid #e5e7eb;
  margin-top: 2px;
}
.off-popup__shift-header:first-child { margin-top: 0; }

.off-popup__shift-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-size: 0.88rem;
}
.off-popup__shift-item:hover {
  background: #f5f3ff;
  border-color: #c7d2fe;
}
.off-popup__shift-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #7c3aed;
  cursor: pointer;
  flex-shrink: 0;
}

.off-popup__shift-time {
  font-weight: 600;
  color: #111827;
}

.off-popup__shift-dept {
  font-size: 0.75rem;
  font-weight: 600;
  color: #7c3aed;
  background: #f5f3ff;
  padding: 1px 7px;
  border-radius: 5px;
  margin-left: auto;
}

.off-popup__confirm {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter 0.15s, transform 0.05s;
  margin-top: 2px;
}
.off-popup__confirm:hover { filter: brightness(1.08); }
.off-popup__confirm:active { transform: translateY(1px); }


/* ========== Teacher Shift Details in Cards ========== */
.s-card-top-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.t-shifts-section {
  width: 100%;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.t-shift-day {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.t-shift-day-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #4c1d95;
  background: #f5f3ff;
  padding: 2px 10px;
  border-radius: 6px;
  min-width: 72px;
  text-align: center;
  white-space: nowrap;
}

.t-shift-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.t-shift-chip {
  font-size: 0.78rem;
  font-weight: 600;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 2px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

.t-no-shifts {
  font-size: 0.82rem;
  color: #9ca3af;
  font-style: italic;
}

/* Make teacher cards column layout to fit shifts below */
.s-card[data-teacher-off-id] {
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .s-card-top-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .t-shift-day {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ========== Teacher Grouped Cards (tg-*) ========== */
.tg-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.tg-card:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,0.07);
}
.tg-card--active {
  border-left: none;
}
.tg-card--future {
  border-left: none;
}

.tg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #fefce8, #fff7ed);
  border-bottom: 1px solid #f3f4f6;
}
.tg-icon {
  color: #dc2626;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.tg-header-info { flex: 1; min-width: 0; }
.tg-email {
  font-weight: 700;
  font-size: 0.95rem;
  color: #111827;
  word-break: break-all;
}
.tg-meta {
  font-size: 0.78rem;
  color: #9ca3af;
  margin-top: 1px;
}

.tg-body {
  padding: 6px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tg-subrow {
  background: #fafafa;
  border: 1px solid #f0f0f0;
  border-radius: 10px;
  padding: 10px 12px;
  transition: background 0.12s;
}
.tg-subrow:hover {
  background: #f5f3ff;
  border-color: #e0dafb;
}

.tg-subrow-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tg-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.tg-status--active {
  background: linear-gradient(135deg, #dc2626, #f97316);
}
.tg-status--future {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.tg-dates {
  font-size: 0.88rem;
  font-weight: 600;
  color: #374151;
  flex: 1;
}

.tg-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.tg-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
  transition: all 0.12s;
}
.tg-btn-edit {
  color: #7c3aed;
  border-color: rgba(124,58,237,0.2);
}
.tg-btn-edit:hover {
  background: #f5f3ff;
  box-shadow: 0 2px 8px rgba(124,58,237,0.15);
}
.tg-btn-del {
  color: #dc2626;
  border-color: rgba(220,38,38,0.2);
}
.tg-btn-del:hover {
  background: #fef2f2;
  box-shadow: 0 2px 8px rgba(220,38,38,0.15);
}

.tg-shifts {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tg-shift-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tg-day-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #4c1d95;
  background: #ede9fe;
  padding: 2px 8px;
  border-radius: 5px;
  min-width: 62px;
  text-align: center;
  white-space: nowrap;
}

.tg-chip {
  font-size: 0.76rem;
  font-weight: 600;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 2px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .tg-subrow-top {
    gap: 6px;
  }
  .tg-dates {
    width: 100%;
    order: 3;
  }
  .tg-shift-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }
}

/* ========== Teacher Card v3 - Merged view ========== */
.tg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #fefce8, #fff7ed);
  border-bottom: 1px solid #f3f4f6;
  flex-wrap: wrap;
}

.tg-combined-range {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1f2937;
  padding: 2px 0 6px;
}

.tg-shifts-merged {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px dashed #e5e7eb;
  border-bottom: 1px dashed #e5e7eb;
}

/* ========== Hover actions on shift lines ========== */
.tg-shift-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 5px 6px;
  border-radius: 8px;
  transition: background 0.12s;
}
.tg-shift-line:hover {
  background: #faf5ff;
}

.tg-hover-actions {
  display: none;
  gap: 3px;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}
.tg-shift-line:hover .tg-hover-actions {
  display: flex;
}

.tg-no-shift-line {
  padding: 6px 8px;
}

.tg-noshift-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b7280;
}

/* Make buttons slightly smaller for inline use */
.tg-hover-actions .tg-btn {
  width: 28px;
  height: 28px;
  font-size: 11px;
  border-radius: 7px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

@media (max-width: 640px) {
  .tg-hover-actions {
    display: flex;
    position: static;
    transform: none;
    margin-left: auto;
  }
}

/* ========== Tạm Nghỉ Modal Redesign ========== */
.tn-modal-wide {
  width: min(96vw, 720px) !important;
  max-width: 720px !important;
}

.tn-split-body {
  display: flex;
  gap: 0;
  padding: 0;
}

.tn-split-left {
  flex: 1;
  padding: 16px;
  border-right: 1px solid #f3f4f6;
}

.tn-split-right {
  flex: 1;
  padding: 16px;
  background: #f0fdf4;
  min-height: 220px;
}

.tn-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  color: #1f2937;
  margin-bottom: 12px;
}
.tn-section-label i { color: #7c3aed; }

.tn-count-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
}
.tn-count-badge--green {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}
.tn-count-badge--done {
  background: linear-gradient(135deg, #16a34a, #22c55e) !important;
}

.tn-off-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e5e7eb;
}
.tn-off-tags:empty {
  display: none;
}

.tn-off-tag {
  font-size: 0.78rem;
  font-weight: 600;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 3px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

.tn-makeup-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.tn-makeup-list::-webkit-scrollbar { width: 5px; }
.tn-makeup-list::-webkit-scrollbar-thumb { background: #bbf7d0; border-radius: 10px; }

.tn-makeup-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 0;
  color: #9ca3af;
  font-size: 0.88rem;
  text-align: center;
}

.tn-makeup-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.tn-makeup-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tn-makeup-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tn-makeup-for {
  font-size: 0.78rem;
  color: #6b7280;
}
.tn-makeup-for strong {
  color: #991b1b;
  font-weight: 700;
}

.tn-makeup-date {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #f9fafb;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tn-makeup-date:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.15);
  background: #fff;
}

.tn-makeup-note {
  width: 100%;
  height: 32px;
  padding: 6px 10px;
  border: 1px solid #f3f4f6;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: inherit;
  color: #6b7280;
  background: #f9fafb;
  outline: none;
  margin-top: 6px;
}
.tn-makeup-note:focus {
  border-color: #86efac;
  background: #fff;
}

.tn-makeup-badge-in-card {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #16a34a;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 4px;
}

@media (max-width: 600px) {
  .tn-split-body {
    flex-direction: column;
  }
  .tn-split-left {
    border-right: none;
    border-bottom: 1px solid #f3f4f6;
  }
  .tn-modal-wide {
    width: min(96vw, 460px) !important;
  }
}

/* ========== Per-Day No-Makeup Toggle ========== */
.tn-skip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.tn-skip-toggle input[type="checkbox"] {
  display: none;
}
.tn-skip-slider {
  position: relative;
  width: 30px;
  height: 16px;
  background: #d1d5db;
  border-radius: 999px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.tn-skip-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.tn-skip-toggle input:checked + .tn-skip-slider {
  background: #f59e0b;
}
.tn-skip-toggle input:checked + .tn-skip-slider::after {
  transform: translateX(14px);
}
.tn-skip-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #9ca3af;
  white-space: nowrap;
}
.tn-skip-toggle input:checked ~ .tn-skip-label {
  color: #d97706;
}

.tn-makeup-card.skipped {
  background: #fffbeb;
  border-color: #fde68a;
}
.tn-makeup-card.skipped .tn-makeup-date,
.tn-makeup-card.skipped .tn-makeup-note {
  display: none;
}
.tn-skip-msg {
  font-size: 0.78rem;
  font-weight: 600;
  color: #d97706;
  padding: 6px 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Badge for "Không học bù" on the card list */
.tn-no-makeup-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #d97706;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 2px 8px;
  border-radius: 6px;
}