@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap");

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
  /* Typography */
  --font-body: "Montserrat", Arial, sans-serif;
  --font-display: "Montserrat", Arial, sans-serif;
  --type-display-lg: 2.25rem;
  --type-headline-lg: 1.5rem;
  --type-headline-md: 1.25rem;
  --type-headline-sm: 1.125rem;
  --type-title-lg: 1.125rem;
  --type-title-md: 1rem;
  --type-title-sm: 0.9375rem;
  --type-body-lg: 1rem;
  --type-body-md: 1rem;
  --type-body-sm: 0.875rem;
  --type-label-lg: 0.875rem;
  --type-label-md: 0.8125rem;
  --type-label-sm: 0.75rem;
  --line-display-lg: 1.16;
  --line-headline-lg: 1.25;
  --line-headline-md: 1.35;
  --line-body: 1.6;

  /* Core palette */
  --color-white: #ffffff;
  --color-black: #000000;
  --color-transparent: transparent;
  --hb-primary: #f15d22;
  --hb-primary-soft: #fff1ea;
  --hb-text: #212121;
  --hb-muted: #808080;
  --hb-border: #e0e0e0;
  --hb-surface: #ffffff;
  --hb-bg: #f8f8f8;
  --hb-success: #16a34a;
  --hb-warning: #d97706;
  --hb-danger: #dc2626;
  --primary: #f15d22;
  --primary-dark: #d94c16;
  --primary-darker: #b83b0e;
  --primary-light: #ff7842;
  --primary-soft: #ffe2d4;
  --primary-softer: var(--hb-primary-soft);
  --primary-contrast: #ffffff;
  --secondary: #2196f3;
  --secondary-dark: #1976d2;
  --secondary-soft: #eaf5ff;
  --secondary-contrast: #ffffff;
  --accent-gold: #ebd233;
  --accent-gold-soft: #fffbe6;
  --accent-terracotta: #f15d22;
  --accent-terracotta-soft: #fff1ea;
  --header-blue: var(--hb-primary);

  /* Backgrounds and surfaces */
  --bg-page: var(--hb-bg);
  --bg-page-soft: #fafafa;
  --bg-page-muted: #f0f0f0;
  --bg-page-subtle: #ffffff;
  --bg-card: var(--hb-surface);
  --bg-card-soft: #ffffff;
  --bg-card-muted: #f5f5f5;
  --bg-card-warm: var(--hb-surface);
  --surface-white: #ffffff;
  --surface-page: var(--bg-page);
  --surface-subtle: #fafafa;
  --surface-muted: #f0f0f0;
  --surface-raised: #ffffff;
  --surface-overlay: rgba(255, 255, 255, 0.9);
  --surface-card-translucent: rgba(255, 255, 255, 0.95);
  --surface-container-lowest: #ffffff;
  --surface-container-low: #ffffff;
  --surface-container: #f8f8f8;
  --surface-container-high: #f0f0f0;
  --surface-container-highest: #e5e5e5;

  /* Text */
  --text-main: var(--hb-text);
  --text-heading: #212121;
  --text-soft: #555555;
  --text-muted: var(--hb-muted);
  --text-subtle: #94a3b8;
  --text-disabled: #b1bbc8;
  --text-inverse: #ffffff;

  /* Borders */
  --border: var(--hb-border);
  --border-soft: #e0e0e0;
  --border-muted: #eeeeee;
  --border-strong: #bdbdbd;
  --border-primary: rgba(241, 93, 34, 0.34);
  --outline: #808080;
  --outline-variant: #d6d6d6;
  --hover-bg: var(--hb-primary-soft);

  /* Status */
  --success: #16834f;
  --success-bg: #ecfdf5;
  --success-bg-strong: #d1fae5;
  --success-text: #166534;
  --success-border: #bbf7d0;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-bg-strong: #fef3c7;
  --warning-text: #92400e;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-bg-strong: #fee2e2;
  --danger-text: #b91c1c;
  --danger-border: #fecaca;
  --info: #2196f3;
  --info-bg: #eaf5ff;
  --info-bg-strong: #d8edff;
  --info-text: #1565c0;
  --info-border: #90caf9;

  /* Radius */
  --radius-xs: 0.25rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.5rem;
  --radius-2xl: 0.5rem;
  --radius-full: 9999px;

  /* Spacing */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --layout-gutter: 24px;
  --layout-margin-mobile: 16px;
  --layout-margin-desktop: 48px;
  --layout-max-width: 1440px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 2px 7px rgba(0, 0, 0, 0.08);
  --shadow-card:
    0 8px 20px -12px rgba(0, 0, 0, 0.16), 0 2px 5px rgba(0, 0, 0, 0.05);
  --shadow-card-hover:
    0 18px 32px -16px rgba(0, 0, 0, 0.2),
    0 6px 12px -8px rgba(0, 0, 0, 0.12);
  --shadow-elevated: 0 18px 42px rgba(0, 0, 0, 0.14);
  --shadow-modal: 0 24px 70px rgba(0, 0, 0, 0.28);
  --shadow-primary: 0 5px 14px rgba(241, 93, 34, 0.24);
  --shadow-soft-sm: 0 10px 28px rgba(0, 0, 0, 0.08);
  --c-red: var(--hb-danger);
  --c-orange: var(--hb-warning);
  --c-yellow: #fbbf24;
  --c-green: var(--hb-success);
  --c-blue: #2196f3;
  --c-purple: #7c3aed;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.08);

  /* Focus and overlay */
  --focus-ring-primary: rgba(241, 93, 34, 0.2);
  --focus-ring-danger: rgba(220, 38, 38, 0.18);
  --overlay-scrim: rgba(15, 23, 42, 0.58);

  /* Gradients */
  --grad-blue: linear-gradient(135deg, #2196f3 0%, #64b5f6 100%);
  --grad-primary-action: linear-gradient(
    90deg,
    #f15d22 0%,
    #f15d22 55%,
    #d94c16 100%
  );
  --grad-surface-soft: linear-gradient(
    135deg,
    #ffffff 0%,
    #fffaf8 52%,
    #fff1ea 100%
  );
  --grad-page: linear-gradient(135deg, #ffffff 0%, #f8f8f8 58%, #f0f0f0 100%);
  --grad-orange: linear-gradient(135deg, #d97706 0%, #fbbf24 100%);
  --grad-green: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  --grad-purple: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
  --grad-red: linear-gradient(135deg, #dc2626 0%, #fb7185 100%);

  /* Component tokens */
  --button-radius: var(--radius-md);
  --button-height-sm: 2rem;
  --button-height-md: 2.5rem;
  --button-height-lg: 3rem;
  --input-radius: var(--radius-md);
  --input-height: 2.75rem;
  --input-bg: #ffffff;
  --input-border: var(--border-soft);
  --input-border-focus: var(--primary);
  --input-placeholder: var(--text-subtle);
  --card-radius: var(--radius-lg);
  --card-bg: var(--bg-card);
  --card-border: var(--border-soft);
  --card-shadow: var(--shadow-card);
  --table-header-bg: #f5f5f5;
  --table-row-hover: #fff8f4;
  --table-border: var(--border-soft);

  /* Compatibility aliases used by school modules */
  --kg-primary: var(--primary);
  --kg-primary-strong: var(--primary-dark);
  --kg-primary-soft: var(--primary-soft);
  --kg-secondary: var(--secondary);
  --kg-bg-page: var(--bg-page);
  --kg-bg-card: var(--bg-card);
  --kg-bg-soft: var(--bg-page-soft);
  --kg-bg-subtle: var(--bg-page-muted);
  --kg-text-main: var(--text-main);
  --kg-text-muted: var(--text-muted);
  --kg-border: var(--border-soft);
  --kg-success: var(--success);
  --kg-warning: var(--warning);
  --kg-danger: var(--danger);
  --kg-accent: var(--accent-gold);
  --kg-shadow: var(--shadow-soft);
}

* {
  box-sizing: border-box;
}

html,
body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  font-size: 14px;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#app {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
}

/* =========================================
   2. SHARED UTILITIES
   ========================================= */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 241, 233, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.app-loading.hide {
  opacity: 0;
  visibility: hidden;
}

.loading-card {
  min-width: 260px;
  padding: 28px 36px;
  text-align: center;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  animation: floatIn 0.6s ease;
}

.loading-text {
  margin-top: 14px;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: auto;
  border: 4px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease-out forwards;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.text-center {
  text-align: center;
}

.hidden {
  display: none;
}

.w-full {
  width: 100%;
}

.cursor-pointer {
  cursor: pointer !important;
}

.material-icons-round {
  user-select: none;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/*TOP NAVBAR*/
.header-level-area,
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.level-box {
  background: white;
  color: #333;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* =========================================
   3. COMPONENTS
   ========================================= */

/* Standard Card */
.std-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -1px rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  transition: box-shadow 0.2s;
}

.std-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-indicator {
  width: 4px;
  height: 24px;
  border-radius: 99px;
}

/* Stat Card */
.stat-card {
  border-radius: 16px;
  padding: 1.5rem;
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 10px 20px -5px rgba(0, 0, 0, 0.15),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  min-height: 120px;
  max-height: 150px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  flex: 0 0 auto;
}

.stat-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow:
    0 25px 30px -5px rgba(0, 0, 0, 0.25),
    0 10px 10px -5px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.stat-icon-box {
  background: rgba(255, 255, 255, 0.25);
  width: 60px;
  height: 60px;
  border-radius: 16px;
  margin-right: 1.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: transform 0.4s ease;
}

.stat-card:hover .stat-icon-box {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.35);
}

.stat-icon-box .material-icons-round {
  font-size: 32px;
  color: white;
}

.stat-info {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.95;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.blob-1,
.blob-2 {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.05) 70%
  );
  filter: blur(8px);
  pointer-events: none;
  transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  opacity: 0.7;
}

.blob-1 {
  width: 150px;
  height: 150px;
  top: -50px;
  right: -50px;
}

.blob-2 {
  width: 100px;
  height: 100px;
  bottom: -40px;
  right: 30px;
}

.stat-card:hover .blob-1 {
  transform: scale(1.3) translate(-20px, 20px);
  opacity: 0.9;
}

.stat-card:hover .blob-2 {
  transform: scale(1.5) translate(-30px, -20px);
  opacity: 0.9;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 4px rgba(241, 93, 34, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(241, 93, 34, 0.4);
}

.btn-outline {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  background: #f7f7f7;
  border-color: #cbd5e1;
  color: var(--text-main);
}

.btn-success {
  background: var(--c-green);
  color: white;
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
}

.btn-icon {
  background: none;
  border: none;
  padding: 6px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: var(--primary);
  transform: scale(1.1);
}

/* Forms */
.form-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  outline: none;
  font-size: 0.9rem;
  background: white;
  transition:
    border 0.2s,
    box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(241, 93, 34, 0.15);
}

.input-wrapper {
  position: relative;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
  font-size: 20px;
  display: flex;
  align-items: center;
}

.input-has-icon {
  padding-left: 38px !important;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: 0 0 12px 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  background: #f7f7f7;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  padding: 14px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  white-space: nowrap;
  vertical-align: middle;
  position: sticky;
  top: 0;
  z-index: 5;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
  white-space: nowrap;
  transition: background 0.1s;
}

.data-table tr:hover td {
  background-color: #f7f7f7;
}

/* Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.bg-green-light {
  background: #dcfce7;
  color: #166534;
}

.dot-green {
  background: #16a34a;
}

.bg-yellow-light {
  background: #fef9c3;
  color: #854d0e;
}

.dot-yellow {
  background: #eab308;
}

.bg-red-light {
  background: #fee2e2;
  color: #991b1b;
}

.dot-red {
  background: #dc2626;
}

.bg-purple-light {
  background: #f3e8ff;
  color: #6b21a8;
}

.dot-purple {
  background: #9333ea;
}

/* Status Badges for Attendance */
.att-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  transition: all 0.2s;
}

.status-present {
  background: #d1fae5;
  color: #065f46;
}

.status-present:hover {
  background: #a7f3d0;
  transform: translateY(-1px);
}

.status-late {
  background: #fef9c3;
  color: #854d0e;
}

.status-late:hover {
  background: #fef3c7;
  transform: translateY(-1px);
}

.status-absent {
  background: #fee2e2;
  color: #991b1b;
}

.status-absent:hover {
  background: #fecaca;
  transform: translateY(-1px);
}

.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: 0.2s ease;
  pointer-events: none;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 20px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  transform: scale(0.9) translateY(20px);
  transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal-content {
  transform: scale(1) translateY(0);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* =========================================
   4. LAYOUT (Header & Nav)
   ========================================= */
.layout-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.layout-header {
  background: #f15d22;
  color: white;
  flex-shrink: 0;
  z-index: 3000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: visible;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  height: 64px;
  overflow: visible;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-box {
  width: 40px;
  height: 40px;
  background: #f7f7f7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.logo-box .logo-img {
  max-width: 40px;
  max-height: 40px;
  border-radius: 50%;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  margin: 0;
  letter-spacing: 0.5px;
}

.user-area {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.user-info {
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  transition: background 0.2s;
  cursor: pointer;
}

.user-info:hover {
  background: rgba(0, 0, 0, 0.3);
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-weight: 800;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.logout-btn .material-icons-round {
  font-size: 18px;
}

.nav-icon-xs {
  font-size: 14px;
}

.nav-icon-sm {
  font-size: 15px;
}

.nav-menu-icon {
  font-size: 18px;
}

.nav-icon-warning {
  color: #fbbf24;
}

.nav-icon-user {
  color: #fde047;
}

.drawer-logo-mark {
  color: #333;
  background: #fff;
}

.drawer-logo-title {
  font-weight: 700;
  color: #fff;
}

.drawer-link-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-session-pill {
  cursor: default;
  background: rgba(251, 191, 36, 0.25);
}

.year-btn {
  background: white;
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Navigation */
.main-nav-container {
  background: rgba(0, 0, 0, 0.15) !important;
  height: 38px;
  position: relative;
  overflow: visible;
  z-index: 3100;
}

.main-nav {
  display: flex;
  align-items: center;
  height: 100%;
}

.nav-item-wrap {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 100%;
  color: var(--color-white);
  font-size: 1rem;
  font-weight: 650;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-link:hover,
.nav-item-wrap:hover .nav-link {
  background: rgba(255, 255, 255, 0.15) !important;
  color: white;
}

.nav-link.active {
  color: white;
  border-bottom-color: var(--c-yellow);
  font-weight: 650;
  background: rgba(255, 255, 255, 0.15) !important;
}

/* Navigation Dropdown */
.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 240px;
  background: white;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  border: 1px solid #e2e8f0;
  border-top: none;
  z-index: 3300;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.nav-dropdown.two-cols {
  min-width: 520px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 12px;
  gap: 6px;
}

.nav-item-wrap.is-open > .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: scaleY(1);
  pointer-events: auto;
  transform-origin: top left;
  animation: navDropdownOpen 180ms ease-out;
}

@keyframes navDropdownOpen {
  from {
    opacity: 0;
    transform: translateY(-6px) scaleY(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scaleY(1);
  }
}

.nav-item-wrap > .nav-dropdown {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 130px);
  overflow-y: auto;
}

.main-nav > .nav-item-wrap:last-child > .nav-dropdown {
  left: auto;
  right: 0;
  transform-origin: top right;
}

@media (prefers-reduced-motion: reduce) {
  .nav-item-wrap.is-open > .nav-dropdown {
    animation: none;
    transition: none;
  }
}

/* JS positions the menu before revealing it, preventing a visible post-render jump. */
.nav-item-wrap > .nav-dropdown[data-positioned="true"] {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.dropdown-item {
  padding: 10px 16px;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  border-radius: 6px;
  transition: 0.1s;
}

.dropdown-item:hover {
  background: #f1f5f9;
  color: var(--primary);
  padding-left: 20px;
}

.sub-icon {
  font-size: 18px;
  color: #94a3b8;
  width: 22px;
  text-align: center;
}

.dropdown-item:hover .sub-icon {
  color: var(--primary);
}

/* Content Area */
.layout-body {
  flex: 1;
  background: transparent;
  padding: 0.5rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.layout-content {
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.layout-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: visible;
  overflow-y: auto;
  position: relative;
}

/* Sub Tabs */
.sub-tabs-bar {
  background: white;
  padding: 4px;
  border-radius: 12px;
  display: flex;
  gap: 6px;
  margin-bottom: 0.5rem;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.sub-tab-link {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  color: #64748b;
  font-weight: 500;
  font-size: 0.95rem;
  transition: 0.2s;
  text-decoration: none;
}

.sub-tab-link:hover {
  background: #f7f7f7;
  color: var(--primary);
}

.sub-tab-link.active {
  background: #fff1ea;
  color: var(--primary);
  font-weight: 700;
  border-bottom: 2px solid var(--primary);
}

/* =========================================
   5. PAGE SPECIFIC
   ========================================= */

/* Home Dashboard */
.page-home-dashboard {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding-bottom: 0.5rem;
  overflow: hidden;
}

.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.home-header .home-title-area {
  display: flex;
  gap: 8px;
  align-items: center;
}

.home-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.home-main-grid {
  display: grid;
  grid-template-columns: 3.5fr 6.5fr;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
}

/* Add new 3-column grid for charts */
.home-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
}

.home-chart-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Smaller list card styles */
.home-list-card-small {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.home-list-scroll-small {
  overflow-y: auto;
  flex: 1;
  padding-right: 6px;
}

.progress-row-small {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.progress-row-small:hover {
  background: #f7f7f7;
}

.grade-icon-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.p-content-small {
  flex: 1;
  min-width: 0;
}

.p-name-small {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
}

.p-val-small {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
}

.p-bar-small {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 99px;
  margin-top: 6px;
  overflow: hidden;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.text-red {
  color: #ef4444;
}

.text-primary {
  color: var(--primary);
}

.cursor-default {
  cursor: default;
}

/* Add/Update the chart styles section */

.chart-wrapper {
  width: 180px;
  height: 180px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  max-width: 100%;
  display: block !important;
}

#studentAttendanceChart,
#teacherAttendanceChart {
  width: 180px !important;
  height: 180px !important;
  max-width: 100%;
  display: block !important;
}

.chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  line-height: 1;
  z-index: 10;
}

.c-main {
  font-size: 2.5rem;
  font-weight: 900;
  color: #1e293b;
}

.c-sub {
  font-size: 0.8rem;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 600;
}

.text-green {
  color: #22c55e;
}

/* Replace the old chart-legend section with this new compact version */
.session-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
  gap: 4px;
}

.session-tabs span {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #64748b;
  transition: all 0.2s;
}

.session-tabs span.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.session-tabs span:hover:not(.active) {
  background: #e2e8f0;
}

.chart-legend-compact {
  display: flex;
  gap: 20px;
  margin-top: 1rem;
  width: 100%;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-text {
  color: var(--text-main);
  font-weight: 500;
}

.legend-text b {
  font-weight: 700;
  margin-left: 4px;
  color: var(--text-main);
}

.chart-legend {
  display: none;
}

.l-item {
  display: none;
}

/* =========================================
   ADD THIS SECTION BACK - Home Chart Styles
   ========================================= */

.home-chart-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
}

/* =========================================
   ADD THIS SECTION BACK - Calendar Styles
   ========================================= */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  text-align: center;
}

.cal-head {
  font-weight: 700;
  font-size: 0.85rem;
  color: #64748b;
  padding: 10px 0;
}

.cal-cell {
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  transition: 0.2s;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-main);
}

.cal-cell:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.cal-cell.active {
  background: var(--primary);
  color: white;
  font-weight: bold;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* =========================================
   ADD THIS SECTION BACK - Tea & Att Styles
   ========================================= */

/* Tea (Teacher) Styles */
.tea-icon {
  padding: 10px;
  background: #ffe2d4;
  border-radius: 12px;
  color: #1e40af;
  display: flex;
}

.tea-filter-box,
.att-filter-box {
  flex-shrink: 0;
  height: auto !important;
  flex: 0 0 auto;
}

.tea-filters,
.att-filters-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-end;
}

.tea-f-wide,
.att-f-item-wide {
  flex: 2;
  min-width: 200px;
}

.tea-f-item,
.att-f-item {
  flex: 1;
  min-width: 140px;
}

.tea-table-box,
.att-table-box {
  padding: 0;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tea-table-header,
.att-header-row {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tea-scroll,
.att-table-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.tea-footer,
.att-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f7f7f7;
  flex-shrink: 0;
}

.att-badge {
  background: #f1f5f9;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-left: 8px;
  font-weight: bold;
}

.att-legend,
.tea-legend {
  display: flex;
  gap: 12px;
}

.att-paging {
  display: flex;
  gap: 6px;
}

.pg-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* =========================================
   ADD THIS SECTION BACK - Attendance Stats
   ========================================= */

.page-attendance-stats {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: 100%;
  overflow-y: auto;
  padding-right: 4px;
}

.stats-summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.bg-blue {
  background: #fff1ea;
  color: #1e40af;
  border: 1px solid #ffe2d4;
}

.bg-green {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #dcfce7;
}

.bg-orange {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #ffedd5;
}

.bg-red {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fee2e2;
}

/* =========================================
   ADD THIS SECTION BACK - Action Dropdown
   ========================================= */

.action-group {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  z-index: 3600;
  display: flex;
  flex-direction: column;
  padding: 4px;
  animation: fadeIn 0.2s ease-out;
  color: var(--text-main);
}

.layout-header .dropdown-menu,
.level-box > .dropdown-menu,
.drawer-context-pill .dropdown-menu {
  color: var(--text-main);
  z-index: 3700;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 2990;
  background: transparent;
}
.menu-item {
  padding: 10px 15px;
  border-bottom: 1px solid var(--border);
  transition: 0.2s;
  white-space: nowrap;
  color: var(--text-main);
  background: transparent;
}

.menu-item:hover {
  background: var(--hover-bg);
  color: var(--primary);
}

.dropdown-item-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-size: 0.9rem;
  color: var(--text-main);
  border-radius: 4px;
  cursor: pointer;
}

.dropdown-item-btn:hover {
  background: #f1f5f9;
  color: var(--primary);
}

/* =========================================
   KEEP EXISTING - Responsive
   ========================================= */

@media (max-width: 1440px) {
  .home-charts-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 1024px) {
  .home-charts-grid {
    grid-template-columns: 1fr;
  }

  .stats-summary-row {
    grid-template-columns: 1fr 1fr;
  }

  .filter-container,
  .att-filters-row,
  .tea-filters {
    flex-direction: column;
    align-items: stretch;
  }
}

/* =========================================
   MOBILE RESPONSIVE NAVIGATION (REMASTERED)
   Style: App Drawer / Mega Menu Style
   ========================================= */

/* --- Trạng thái mặc định trên Desktop --- */
.menu-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  color: white;
  padding: 8px;
  border-radius: 50%;
  margin-right: 12px;
  cursor: pointer;
}

.menu-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.mobile-wrapper {
  display: none;
}
/* --- Responsive Styles (Tablet & Mobile) --- */
@media (max-width: 1024px) {
  /* 1. Ẩn menu ngang cũ */
  .desktop-only {
    display: none !important;
  }

  /* 2. Hiện nút Hamburger */
  .menu-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* 3. Container Mobile Wrapper */
  .mobile-wrapper {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 5000;
    pointer-events: none;
  }

  .mobile-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-drawer {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    background: #ffffff;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 5001;
  }

  /* --- TRẠNG THÁI MỞ (OPEN STATE) --- */
  .mobile-wrapper.open {
    pointer-events: auto;
  }

  .mobile-wrapper.open .mobile-backdrop {
    opacity: 1;
  }

  .mobile-wrapper.open .mobile-drawer {
    transform: translateX(0);
  }

  /* --- Nội dung bên trong Drawer --- */

  /* Header của Drawer */
  .drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary);
  }

  .drawer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .drawer-close-btn {
    background: #f1f5f9;
    border: none;
    color: #64748b;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Body cuộn */
  .drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: var(--primary);
  }

  .drawer-body .drawer-text {
    color: #f7f7f7;
  }

  /* Item Cha */
  .drawer-link-parent {
    padding: 14px 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
  }

  .drawer-link-parent:hover {
    background: #f7f7f7;
  }

  .drawer-link-parent:hover .drawer-text {
    color: var(--primary);
  }

  .drawer-item-group.expanded .drawer-link-parent {
    background: #fff1ea;
  }

  .drawer-item-group.expanded .drawer-link-parent .drawer-text {
    color: var(--primary);
  }

  .chevron {
    transition: transform 0.2s;
    color: #94a3b8;
    font-size: 20px;
  }

  .drawer-item-group.expanded .chevron {
    transform: rotate(180deg);
    color: var(--primary);
  }

  /* --- SUB MENU FRAME (KHUNG MENU CON) --- */
  .drawer-sub-panel {
    background: #f7f7f7;
    margin: 5px 10px 15px 10px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* Item con */
  .drawer-sub-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 8px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all 0.2s;
    text-decoration: none;
    color: #475569;
  }

  .drawer-sub-item:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  }

  .sub-icon-box {
    margin-bottom: 6px;
    color: #94a3b8;
  }

  .drawer-sub-item:hover .sub-icon-box {
    color: var(--primary);
  }

  .sub-text {
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.2;
  }

  .animate-slide-down {
    animation: slideDown 0.2s ease-out forwards;
    transform-origin: top;
  }

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: scaleY(0.9);
      height: 0;
    }

    to {
      opacity: 1;
      transform: scaleY(1);
      height: auto;
    }
  }
}
/* ======================================================
   MOBILE SCROLL FIX
   Chỉ kích hoạt khi màn hình < 1024px
   ====================================================== */
@media (max-width: 1024px) {
  html,
  body,
  #app,
  .layout-wrapper {
    height: auto !important;
    min-height: 100vh;
    overflow-y: auto !important;
    overflow-x: hidden;
  }

  .layout-body {
    height: auto;
    min-height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    /* Bỏ padding để các page full-screen dùng hết không gian */
    padding: 0;
  }

  .layout-viewport {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    flex: 1;
  }

  .layout-header {
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  .layout-content {
    min-height: 0;
    height: auto;
    flex: 1;
  }
}

/* ======================================================
   HEADER INNER — RESPONSIVE (v2 — mobile-hardened)
   ====================================================== */

/* ── Base styles: header-inner không wrap, ngăn tràn ── */
.header-inner {
  flex-wrap: nowrap !important;
  overflow: hidden;
}

/* brand-area: không co, không tràn */
.brand-area {
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}

/* brand-name: 1 dòng, ellipsis */
.brand-name {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: clamp(80px, 20vw, 300px);
}

/* header-left: flex, giữa, không tràn */
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 0;
  margin-right: 1rem;
  min-width: 0;
  justify-content: flex-end;
  overflow: hidden;
}

/* Pill styles cho level-box, static-box, session-timer */
.static-box {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.15);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  color: #fff;
}

.level-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.15);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
  transition: background 0.2s;
  color: #fff;
}
.level-box:hover {
  background: rgba(255, 255, 255, 0.28);
}

.session-timer {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(251, 191, 36, 0.2);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  color: #fef3c7;
}

/* dropdown trong level-box */
.level-box > .dropdown-menu {
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  min-width: 160px;
  z-index: 3800;
}

/* user-area không co */
.user-area {
  flex-shrink: 0;
}

/* ── ≤ 1200px: thu gọn các pill ── */
@media (max-width: 1200px) {
  .brand-name {
    max-width: clamp(60px, 16vw, 200px);
    font-size: 0.9rem;
  }
  .level-box,
  .static-box,
  .session-timer {
    padding: 4px 8px;
    font-size: 0.76rem;
    gap: 3px;
  }
  .header-left {
    gap: 5px;
  }
}

/* ── ≤ 1024px: ẩn header-left (đã có mobile drawer) ── */
@media (max-width: 1024px) {
  .header-inner {
    padding: 0 1rem !important;
    height: 56px !important;
    gap: 8px;
  }
  .header-left {
    display: none !important;
  }
  .brand-name {
    max-width: 180px;
    font-size: 0.88rem;
  }
  .user-info {
    padding: 5px 10px;
    font-size: 0.82rem;
  }
}

/* ── ≤ 768px: ẩn tên trường ── */
@media (max-width: 768px) {
  .header-inner {
    padding: 0 0.75rem !important;
    height: 52px !important;
  }
  .brand-name {
    display: none !important;
  }
  .brand-area {
    gap: 4px;
  }
  .user-info {
    padding: 4px 8px;
    font-size: 0.8rem;
    gap: 4px;
  }
  /* Ẩn text username, chỉ giữ icon person */
  .user-info span:last-child {
    display: none !important;
  }
}

/* ── ≤ 480px: header nhỏ nhất ── */
@media (max-width: 480px) {
  .header-inner {
    padding: 0 0.5rem !important;
    height: 48px !important;
  }
  .logo-box {
    width: 34px;
    height: 34px;
  }
  .logo-box .logo-img {
    max-width: 34px;
    max-height: 34px;
  }
  .menu-toggle-btn {
    margin-right: 4px;
    padding: 6px;
  }
  .level-box > .dropdown-menu {
    left: auto;
    right: 0;
  }
}

/* ─────────────────────────────────────────────────────
   DRAWER MOBILE: context row (cấp học / năm học / học kỳ)
   Hiện trong mobile-drawer khi header-left bị ẩn
   ───────────────────────────────────────────────────── */
/* Mặc định: ẩn trên desktop (drawer không render) */
.drawer-context-row {
  display: none;
}

@media (max-width: 1024px) {
  .drawer-context-row {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: var(--primary);
  }

  .drawer-context-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    user-select: none;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.15);
  }

  .drawer-context-pill:hover {
    background: rgba(255, 255, 255, 0.32);
  }
  .drawer-context-pill .material-icons-round {
    font-size: 15px;
  }

  .drawer-context-pill .dropdown-menu {
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    z-index: 5100;
    background: var(--bg-card);
    border-color: var(--border);
    box-shadow: 0 18px 42px rgba(52, 54, 48, 0.18);
    color: var(--text-main);
    max-height: 260px;
    overflow-y: auto;
  }

  .drawer-context-pill .dropdown-menu .menu-item {
    color: var(--text-main) !important;
    background: transparent;
  }

  .drawer-context-pill .dropdown-menu .menu-item:hover {
    color: var(--primary) !important;
    background: var(--hover-bg);
  }

  .drawer-context-pill:last-child .dropdown-menu {
    left: auto;
    right: 0;
  }
}

/* =========================================
   Dropdown Safety Overrides
   Keep this block at the end so full-width pages and scoped CSS cannot hide menus.
   ========================================= */
.layout-header,
.header-inner,
.header-left,
.main-nav-container,
.main-nav,
.nav-item-wrap,
.level-box,
.drawer-context-row,
.drawer-context-pill {
  overflow: visible !important;
}

.layout-header {
  position: relative !important;
  z-index: 6000 !important;
}

.main-nav-container {
  position: relative !important;
  z-index: 6100 !important;
}

.main-nav,
.nav-item-wrap {
  position: relative !important;
  z-index: 6110 !important;
}

.nav-item-wrap > .nav-dropdown {
  z-index: 6120 !important;
}

.layout-body {
  position: relative;
  z-index: 1;
}

.header-inner,
.header-left {
  position: relative !important;
  z-index: 6010 !important;
}

.level-box {
  position: relative !important;
  z-index: 6020 !important;
}

.level-box > .dropdown-menu,
.header-left .level-box > .dropdown-menu {
  position: absolute !important;
  top: calc(100% + 8px) !important;
  left: 0 !important;
  right: auto !important;
  display: flex !important;
  flex-direction: column !important;
  min-width: 180px !important;
  width: max-content !important;
  max-width: min(320px, 90vw) !important;
  padding: 8px !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important;
  background: var(--bg-card) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  box-shadow: 0 18px 42px rgba(52, 54, 48, 0.18) !important;
  z-index: 6030 !important;
}

.dropdown-menu > .menu-item,
.level-box > .dropdown-menu > .menu-item,
.drawer-context-pill > .dropdown-menu > .menu-item {
  display: block !important;
  width: 100% !important;
  min-height: 36px !important;
  padding: 10px 14px !important;
  color: var(--text-main) !important;
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  line-height: 1.35 !important;
  font-weight: 700 !important;
  text-align: left !important;
  white-space: nowrap !important;
}

.dropdown-menu > .menu-item:last-child,
.level-box > .dropdown-menu > .menu-item:last-child,
.drawer-context-pill > .dropdown-menu > .menu-item:last-child {
  border-bottom: 0 !important;
}

.dropdown-menu > .menu-item:hover,
.level-box > .dropdown-menu > .menu-item:hover,
.drawer-context-pill > .dropdown-menu > .menu-item:hover {
  color: var(--primary) !important;
  background: var(--hover-bg) !important;
}

@media (max-width: 1024px) {
  .mobile-wrapper {
    z-index: 7000 !important;
  }

  .mobile-drawer {
    overflow: visible !important;
    z-index: 7010 !important;
  }

  .drawer-context-pill {
    position: relative !important;
    z-index: 7020 !important;
  }

  .drawer-context-pill > .dropdown-menu {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    left: 0 !important;
    right: auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-width: 210px !important;
    padding: 8px !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    background: var(--bg-card) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    box-shadow: 0 18px 42px rgba(52, 54, 48, 0.24) !important;
    z-index: 7030 !important;
  }
}
