/* ============================================================
   Thời khóa biểu — Trường PTDT Nội Trú Tỉnh Sơn La
   Design system: "Núi Sơn La" — mist green + mountain emerald
   ============================================================ */

:root {
  /* Palette */
  --bg: #F2F6F3;
  --bg-deep: #E9F0EB;
  --surface: #FFFFFF;
  --ink: #172923;
  --ink-soft: #47615A;
  --muted: #74908A;
  --line: #DCE7E1;
  --line-strong: #C4D5CC;

  --brand: #0B7A5E;
  --brand-deep: #075F49;
  --brand-ink: #0A5C47;
  --brand-soft: #E0F1E9;
  --brand-softer: #EFF7F2;

  --amber: #9A6400;      /* GDTC — môn được theo dõi trùng lịch */
  --amber-bg: #FCF1D4;
  --amber-border: #EBCE8E;

  --danger: #B3261E;
  --danger-bg: #FBEAE9;

  --today-tint: #E6F3EC;

  /* Shape & depth */
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow-card: 0 1px 2px rgba(23, 41, 35, .05), 0 10px 30px -18px rgba(23, 41, 35, .25);
  --shadow-pop: 0 2px 6px rgba(23, 41, 35, .08), 0 16px 40px -12px rgba(23, 41, 35, .22);

  --font: 'Be Vietnam Pro', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 85% -80px, #E2EEE7 0%, transparent 60%),
    radial-gradient(900px 480px at -10% 40px, #EAF2EC 0%, transparent 55%),
    var(--bg);
  font-size: 15.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Khung trang ---------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 72px;
}

/* ---------- Hero / header ---------- */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, #0B7A5E 0%, #0A6B54 46%, #085644 100%);
  color: #fff;
  padding: 30px 34px 28px;
  box-shadow: var(--shadow-pop);
}

.hero::after {
  /* vệt sáng mềm */
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 220px at 18% -40px, rgba(255, 255, 255, .16), transparent 65%);
  pointer-events: none;
}

.hero-mountains {
  position: absolute;
  right: -8px;
  bottom: -2px;
  width: min(46%, 480px);
  height: auto;
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #BFE6D6;
  margin: 0 0 8px;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(26px, 4.5vw, 38px);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.12;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

.badge svg { flex: none; }

.badge--date { background: rgba(255, 255, 255, .22); }

.hero-links {
  position: relative;
  margin-top: 18px;
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: #CDEBDD;
}

.hero-links a { color: #D9F1E4; text-decoration: none; font-weight: 600; }
.hero-links a:hover { text-decoration: underline; }

/* ---------- Trạng thái ---------- */

.state-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 48px 32px;
  text-align: center;
  margin-top: 26px;
}

.state-card .big-emoji { font-size: 44px; margin-bottom: 10px; }
.state-card h2 { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.state-card p { margin: 0 auto; color: var(--ink-soft); max-width: 460px; }

.error-text { color: var(--danger); }

/* ---------- Skeleton khi đang tải ---------- */

.skeleton {
  margin-top: 26px;
  display: grid;
  gap: 14px;
}

.sk {
  border-radius: var(--r-md);
  background: linear-gradient(100deg, #E8EFEA 40%, #F2F7F3 50%, #E8EFEA 60%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s ease infinite;
}

.sk-title { height: 130px; }
.sk-row { height: 64px; }

@keyframes sk-shimmer {
  to { background-position: -200% 0; }
}

/* ---------- Bộ chọn lớp ---------- */

.class-picker {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 20px 20px;
}

.class-picker__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.class-picker__title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink);
  margin: 0;
}

.class-picker__note { font-size: 12.5px; color: var(--muted); }

.grade-group {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 14px;
  align-items: start;
}

.grade-group + .grade-group { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }

.grade-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brand-ink);
  background: var(--brand-softer);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 8px;
  justify-self: start;
  margin-top: 2px;
  white-space: nowrap;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, color .16s ease, border-color .16s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chip:hover { transform: translateY(-1px); box-shadow: 0 4px 12px -6px rgba(23, 41, 35, .3); border-color: var(--brand); }

.chip:focus-visible { outline: 3px solid rgba(11, 122, 94, .35); outline-offset: 1px; }

.chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(11, 122, 94, .65);
}

.chip.is-active:hover { background: var(--brand-deep); }

.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  display: none;
}

.chip.is-active .dot { display: block; }

.class-gvcn {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.class-gvcn b { color: var(--ink); font-weight: 700; }

/* ---------- Thẻ buổi học ---------- */

.session-card {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.session-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #FBFDFC, #F5F9F7);
  flex-wrap: wrap;
}

.session-card__icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
}

.session-card__icon--am { background: var(--brand-soft); color: var(--brand-ink); }
.session-card__icon--pm { background: #E9E6F8; color: #4C3D8F; }

.session-card__name { font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; margin: 0; }

.session-card__meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  background: var(--brand-softer);
  border: 1px solid var(--line);
  color: var(--brand-ink);
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- Ngày chọn (mobile) ---------- */

.day-tabs {
  display: none;
  gap: 6px;
  padding: 12px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.day-tabs::-webkit-scrollbar { display: none; }

.day-tab {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}

.day-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Lưới thời khóa biểu ---------- */

.grid-wrap { padding: 16px 18px 20px; overflow-x: auto; }

.tk-grid {
  display: grid;
  grid-template-columns: 58px repeat(var(--n-days, 6), minmax(108px, 1fr));
  gap: 7px;
  min-width: 660px;
}

.tk-grid__corner,
.tk-grid__day {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  padding: 8px 4px 6px;
  border-radius: var(--r-sm);
  position: relative;
}

.tk-grid__day span { display: block; }

.tk-grid__day.is-today {
  color: var(--brand-ink);
  background: var(--brand-soft);
}

.tk-grid__day .today-tag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--brand-ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 1px 7px;
  margin-top: 3px;
}

.tk-grid__period {
  display: grid;
  place-items: center;
  align-self: stretch;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-ink);
}

.tk-grid__period b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--brand-softer);
  border: 1px solid var(--line);
  border-radius: 50%;
}

.tk-cell {
  border-radius: var(--r-sm);
  padding: 8px 10px 7px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  position: relative;
  transition: transform .16s ease, box-shadow .16s ease;
  background: #F7FAF8;
}

.tk-cell--empty { background: transparent; border: 1.5px dashed var(--line); min-height: 52px; }

.tk-cell:not(.tk-cell--empty):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -10px rgba(23, 41, 35, .35);
  z-index: 2;
}

.tk-cell__subject { font-size: 13px; font-weight: 700; line-height: 1.25; }

.tk-cell__teacher { font-size: 11.5px; font-weight: 500; color: var(--ink-soft); opacity: .92; }

.tk-cell.is-today-col { box-shadow: inset 0 0 0 1.5px rgba(11, 122, 94, .16); }

.tk-cell--empty.is-today-col { background: var(--today-tint); border-color: var(--line-strong); }

/* Ô GDTC: viền hổ phách + số lớp trùng cùng tiết */
.tk-cell.is-pe { box-shadow: inset 0 0 0 1.5px var(--amber-border); }

.tk-cell.is-pe.is-today-col { box-shadow: inset 0 0 0 1.5px var(--amber-border), inset 0 0 0 3px rgba(11,122,94,.16); }

.tk-cell__pe-flag {
  position: absolute;
  top: -7px;
  right: -5px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: 999px;
  padding: 1px 7px;
  box-shadow: 0 2px 6px -2px rgba(154, 100, 0, .4);
}

/* ---------- Panel trùng GDTC ---------- */

.pe-panel {
  margin-top: 22px;
  background: linear-gradient(180deg, #FFFDF5, #FFF9EC);
  border: 1px solid var(--amber-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
}

.pe-panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.pe-panel__icon {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.pe-panel__title { margin: 0; font-size: 16.5px; font-weight: 800; letter-spacing: -.01em; }

.pe-panel__sub { margin: 2px 0 16px; font-size: 13px; color: #7A6B45; }

.pe-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.pe-item {
  background: #fff;
  border: 1px solid var(--amber-border);
  border-radius: var(--r-md);
  padding: 14px 16px;
}

.pe-item__slot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  font-size: 14px;
}

.pe-item__slot .pill { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber); }

.pe-item__teacher { font-size: 12.5px; color: var(--ink-soft); margin: 4px 0 10px; }

.pe-item__overlap-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #8A7440;
  margin-bottom: 7px;
}

.pe-item__classes { display: flex; flex-wrap: wrap; gap: 6px; }

.pe-class {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 11px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  transition: transform .16s ease;
}

.pe-class:hover { transform: translateY(-1px); }

.pe-class b { font-size: 13px; font-weight: 700; color: var(--ink); }

.pe-class span { font-size: 11px; color: var(--muted); }

.pe-empty {
  padding: 18px;
  text-align: center;
  color: #7A6B45;
  font-size: 13.5px;
  background: rgba(255, 255, 255, .6);
  border: 1.5px dashed var(--amber-border);
  border-radius: var(--r-md);
}

/* ---------- Chú giải màu môn học ---------- */

.legend {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  flex: none;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

.site-footer a { color: var(--brand-ink); font-weight: 600; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ---------- Toast ---------- */

.toast-zone {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  background: #172923;
  color: #F0F7F3;
  border-radius: var(--r-md);
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  display: flex;
  gap: 9px;
  align-items: flex-start;
  animation: toast-in .3s cubic-bezier(.2, .9, .3, 1.2);
}

.toast--error { background: #6B1F1B; }
.toast--ok { background: #0A5C47; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to { opacity: 1; transform: none; }
}

/* ---------- Vào trang: hiệu ứng dần ---------- */

.reveal {
  animation: reveal-up .45s cubic-bezier(.2, .8, .25, 1) both;
}

.reveal-1 { animation-delay: .05s; }
.reveal-2 { animation-delay: .12s; }
.reveal-3 { animation-delay: .19s; }
.reveal-4 { animation-delay: .26s; }

@keyframes reveal-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .grade-group { grid-template-columns: 1fr; }
  .grade-label { margin: 0; }
  .tk-grid { min-width: 560px; grid-template-columns: 48px repeat(var(--n-days, 6), minmax(90px, 1fr)); }
}

@media (max-width: 760px) {
  .page { padding: 16px 12px 56px; }
  .hero { padding: 24px 22px 22px; }
  .hero-mountains { width: 62%; opacity: .55; }
  .grid-wrap { padding: 12px 12px 16px; }

  /* Chế độ 1 ngày trên mobile */
  .day-tabs { display: flex; }
  .tk-grid { min-width: 0; grid-template-columns: 44px 1fr; }
  .tk-grid [data-day-cell]:not(.is-day-shown):not(.tk-grid__period):not(.tk-grid__corner) { display: none; }
  .tk-cell { min-height: 54px; }
}
