/* ============================================================
   Tiện ích tạo thời khóa biểu — giao diện
   Phong cách: sáng, tông tím (violet), mỗi ngày một sắc nhẹ
   ============================================================ */
:root {
  --bg:        #f4f2fd;
  --surface:   #ffffff;
  --line:      #e7e3f5;
  --ink:       #241f36;
  --ink-2:     #5f5878;
  --ink-3:     #928bab;

  --primary:   #7c5cf6;
  --primary-d: #6440e0;
  --primary-l: #efeafe;
  --danger:    #e5484d;

  /* Màu 7 ngày (nền ô + header) */
  --mon: #eef4ff; --mon-h: #6d8fe8;
  --tue: #e9fbf5; --tue-h: #23a892;
  --wed: #fdeef7; --wed-h: #d15ba0;
  --thu: #f2edfe; --thu-h: #8b64e6;
  --fri: #fff0ea; --fri-h: #e9743f;
  --sat: #e9f5ff; --sat-h: #3f8fd0;
  --sun: #ffecec; --sun-h: #e05656;

  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(36,31,54,.06), 0 4px 16px rgba(36,31,54,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 84% -12%, #ece2ff 0%, transparent 58%),
    radial-gradient(900px 440px at -6% 0%, #e6ecff 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page { max-width: 1000px; margin: 0 auto; padding: 16px 18px 56px; }

/* ---------- Nút quay lại ---------- */
.topbar { display: flex; margin-bottom: 14px; }
.back {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font); font-size: 14.5px; font-weight: 700;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 15px 8px 12px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: color .15s, transform .05s;
}
.back:hover { color: var(--primary-d); }
.back:active { transform: scale(.97); }
.back:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(124,92,246,.3); }

/* ---------- Tiêu đề ---------- */
.hero { text-align: center; margin: 6px 0 22px; }
.hero__title {
  font-size: clamp(1.7rem, 4.4vw, 2.5rem);
  font-weight: 900; letter-spacing: -.02em; line-height: 1.12;
  background: linear-gradient(120deg, #6440e0, #9b5cf0 55%, #d15ba0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__desc {
  max-width: 620px; margin: 10px auto 0;
  font-size: clamp(.95rem, 2.3vw, 1.05rem);
  font-weight: 500; color: var(--ink-2); line-height: 1.55;
}

/* ---------- Thẻ thông tin ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 18px 20px; margin-bottom: 18px; }
.panel__row { display: flex; gap: 14px; flex-wrap: wrap; }
.panel__row + .panel__row { margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 160px; }
.field--sm { flex: 0 1 160px; }
.field label { font-size: 13px; font-weight: 800; color: var(--ink-2); }
.field input {
  font-family: var(--font); font-size: 14.5px; font-weight: 600;
  color: var(--ink); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}
.field input:focus-visible { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(124,92,246,.14); }

.select { position: relative; }
.select select {
  width: 100%; appearance: none;
  font-family: var(--font); font-size: 14.5px; font-weight: 700;
  color: var(--ink); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 34px 10px 12px; cursor: pointer;
}
.select select:focus-visible { outline: none; border-color: var(--primary); background: #fff; }
.select__caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }

/* ---------- Vùng chụp ảnh ---------- */
.capture {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 18px;
}
.sheet-head { text-align: center; margin-bottom: 16px; }
.sheet-head__title {
  font-size: clamp(1.3rem, 4vw, 1.7rem); font-weight: 900;
  letter-spacing: .04em; color: var(--primary-d);
}
.sheet-head__sub { margin-top: 4px; font-size: .95rem; font-weight: 700; color: var(--ink-2); }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; }
.tt {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 640px;
}
.tt th, .tt td {
  border: 1px solid var(--line);
  padding: 0;
  text-align: center;
}
.tt thead th {
  color: #fff;
  font-weight: 800;
  font-size: .92rem;
  padding: 10px 4px;
  white-space: nowrap;
}
.tt th.col-session, .tt th.col-period { background: var(--primary); }
.th-mon { background: var(--mon-h); } .th-tue { background: var(--tue-h); }
.th-wed { background: var(--wed-h); } .th-thu { background: var(--thu-h); }
.th-fri { background: var(--fri-h); } .th-sat { background: var(--sat-h); }
.th-sun { background: var(--sun-h); }

.cell-session {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-weight: 900; font-size: .95rem; letter-spacing: .12em;
  color: var(--primary-d); background: var(--primary-l);
  width: 34px;
}
.cell-period { font-weight: 800; color: var(--ink-2); background: #faf9ff; width: 42px; font-size: .9rem; }

.bg-mon { background: var(--mon); } .bg-tue { background: var(--tue); }
.bg-wed { background: var(--wed); } .bg-thu { background: var(--thu); }
.bg-fri { background: var(--fri); } .bg-sat { background: var(--sat); }
.bg-sun { background: var(--sun); }

.cell-input {
  width: 100%; height: 40px;
  border: none; background: transparent;
  text-align: center; font-family: var(--font);
  font-size: .86rem; font-weight: 700; color: var(--ink);
  padding: 2px 3px;
}
.cell-input::placeholder { color: transparent; }
.cell-input:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: rgba(255,255,255,.75); border-radius: 4px; }

.tt tbody td.is-today, .col-today { box-shadow: inset 0 0 0 2px var(--primary); }
.th-today { position: relative; }
.th-today::after { content: "Hôm nay"; display: block; font-size: .62rem; font-weight: 800; opacity: .95; margin-top: 1px; }

/* Khi xuất ảnh: ẩn đánh dấu "hôm nay" để ảnh sạch, đều màu */
.exporting .th-today::after { display: none !important; }
.exporting .is-today, .exporting .col-today { box-shadow: none !important; }

/* Bản sao khi chụp: hiển thị chữ thay ô nhập */
.cell-text {
  height: 40px; display: flex; align-items: center; justify-content: center;
  font-size: .86rem; font-weight: 700; color: var(--ink); padding: 2px 3px; text-align: center;
}

/* ---------- Nút ---------- */
.controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.btn {
  font-family: var(--font); font-weight: 800; font-size: 14.5px;
  border: none; border-radius: 10px; cursor: pointer; padding: 12px 22px;
  transition: background .15s, transform .05s, color .15s;
}
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(124,92,246,.35); }
.btn--primary:hover { background: var(--primary-d); }
.btn--primary:active { transform: translateY(1px); }
.btn--ghost { background: var(--surface); color: var(--ink-2); border: 1.5px solid var(--line); }
.btn--ghost:hover { color: var(--ink); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(124,92,246,.32); }

.tip { text-align: center; font-size: 13.5px; font-weight: 500; color: var(--ink-3); line-height: 1.5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -140%);
  background: var(--ink); color: #fff;
  font-weight: 700; font-size: 14px;
  padding: 12px 20px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(36,31,54,.24);
  z-index: 100; transition: transform .3s cubic-bezier(.4,0,.2,1); max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast.ok { background: #17915a; }
.toast.err { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .page { padding: 12px 12px 40px; }
  .panel, .capture { padding: 16px 14px; }
  .field--sm { flex: 1 1 130px; }
  .btn { flex: 1; min-width: 120px; padding: 11px 14px; }
  .cell-input { font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) { .toast, .back, .btn { transition: none; } }