/* ============================================================
   Trang Quản trị viên — CLB STEM-AI KDC
   Theme sáng trắng - cam, đồng bộ với trang đăng ký.
   ============================================================ */
:root {
  --orange: #ff8a1e;
  --flame: #f9690e;
  --star: #ffd23f;
  --bg: #faf6f0;
  --card: #ffffff;
  --line: #ead9c4;
  --text: #38302a;
  --muted: #8a7c6c;
  --sky: #2f7fe0;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --display: "Baloo 2", sans-serif;
  --body: "Be Vietnam Pro", system-ui, sans-serif;
}

/* SỬA LỖI QUAN TRỌNG: bảo đảm thuộc tính hidden luôn ẩn phần tử.
   Trước đây hộp thoại "Liên hệ phụ huynh" có display: flex trong CSS
   nên thuộc tính hidden bị vô hiệu → hộp thoại hiện đè lên và không
   đóng được sau khi đăng nhập. Dòng dưới đây sửa triệt để lỗi đó. */
[hidden] { display: none !important; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--body); background: var(--bg); color: var(--text); font-size: 14.5px; }
button { font-family: var(--body); cursor: pointer; }
input, textarea, select { font-family: var(--body); font-size: 14px; color: var(--text); }

/* ---------- Đăng nhập ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(720px 420px at 88% -4%, rgba(255, 138, 30, 0.16), transparent 60%),
    radial-gradient(720px 520px at -6% 72%, rgba(255, 210, 63, 0.20), transparent 60%),
    #fffdfa;
}
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 28px;
  box-shadow: 0 22px 60px rgba(150, 84, 20, 0.16);
  display: flex; flex-direction: column; gap: 14px;
}
.login-logo { font-size: 44px; }
.login-card h1 { font-family: var(--display); font-size: 23px; color: var(--flame); }
.login-sub { color: var(--muted); font-size: 13.5px; margin-top: -8px; }
.login-card input {
  background: #fffdf9; border: 1.5px solid #e9d9c5;
  border-radius: 12px; padding: 12px 14px; color: var(--text); font-size: 16px; text-align: center;
}
.login-card input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 138, 30, 0.18); }
.login-err { color: var(--danger); font-weight: 600; font-size: 14px; }
.login-back { color: #b3a48e; font-size: 13px; text-decoration: none; }
.login-back:hover { color: var(--flame); }

/* ---------- Nút ---------- */
.btn-primary {
  font-family: var(--display); font-weight: 700; font-size: 15px;
  color: #2b1200; border: none; border-radius: 999px; padding: 10px 20px;
  background: linear-gradient(180deg, var(--star), var(--orange) 45%, var(--flame));
  box-shadow: 0 4px 14px rgba(249, 105, 14, 0.35);
  transition: transform 0.12s ease;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1.5px solid var(--line);
  border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 13.5px;
  text-decoration: none; display: inline-block;
}
.btn-ghost:hover { border-color: var(--flame); color: var(--flame); }
.btn-close {
  background: transparent; border: none; font-size: 18px; color: var(--muted);
  padding: 4px 8px; border-radius: 8px;
}
.btn-close:hover { background: #fdeeee; color: var(--danger); }

/* ---------- Khung app ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(92deg, var(--flame), var(--orange));
  color: #fff; padding: 12px 20px;
  box-shadow: 0 4px 16px rgba(249, 105, 14, 0.25);
}
.topbar-brand { font-family: var(--display); font-weight: 800; font-size: 18px; color: #fff; }
.topbar-brand span { color: rgba(255, 255, 255, 0.88); font-family: var(--body); font-weight: 500; font-size: 13.5px; }
.topbar-actions { display: flex; gap: 10px; }
.topbar .btn-ghost { border-color: rgba(255, 255, 255, 0.55); color: #fff; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.16); border-color: #fff; color: #fff; }

.tabs { display: flex; gap: 8px; padding: 14px 20px 0; }
.tab {
  border: 1.5px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 9px 18px; font-weight: 600; font-size: 14px;
}
.tab.active {
  background: linear-gradient(180deg, var(--star), var(--orange) 50%, var(--flame));
  color: #2b1200; border-color: transparent; font-weight: 700;
  box-shadow: 0 4px 12px rgba(249, 105, 14, 0.3);
}

.wrap { padding: 16px 20px 60px; max-width: 1500px; margin: 0 auto; }

/* ---------- Toolbar + thống kê ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.stats { font-weight: 600; color: var(--muted); }
.stats b { color: var(--text); }
.stats .ok { color: var(--ok); }
.stats .warn { color: var(--warn); }
.toolbar-right { display: flex; gap: 10px; flex-wrap: wrap; }
#searchBox {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 16px;
  min-width: 280px; background: var(--card);
}
#searchBox:focus { outline: none; border-color: var(--orange); }

/* ---------- Bảng đăng ký ---------- */
.tablewrap {
  overflow-x: auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 6px 20px rgba(150, 84, 20, 0.07);
}
.data-table { border-collapse: collapse; width: 100%; min-width: 1750px; }
.data-table th {
  position: sticky; top: 0; z-index: 2;
  background: #fdf3e6; color: #8a5a1e; text-align: left;
  font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.data-table th.th-new { background: #ffe8cf; color: #a04e00; }
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid #f4ece1;
  vertical-align: top; font-size: 13.8px;
}
.data-table tr:hover td { background: #fdf9f3; }
.td-empty { text-align: center; color: var(--muted); padding: 30px !important; }
.td-num { color: var(--muted); }
.td-date { white-space: nowrap; color: var(--muted); font-size: 12.8px; }
.td-name { font-weight: 700; min-width: 150px; }
.td-sub { color: var(--muted); font-size: 12.5px; }
.td-phone a { color: var(--sky); text-decoration: none; white-space: nowrap; }
.td-notes, .td-addr { min-width: 170px; max-width: 260px; }

.chip {
  display: inline-block; background: #ffedd5; color: #b45309;
  border-radius: 999px; padding: 2px 10px; font-size: 12.3px; font-weight: 600;
  margin: 2px 4px 2px 0;
}
.chip-time { background: #fff7d6; color: #8a6d00; }

/* 3 cột theo dõi */
.sel-trial {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 7px 8px;
  font-size: 13px; font-weight: 600; max-width: 190px; background: var(--card);
}
.sel-trial.is-ok { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.sel-trial.is-no { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }

.btn-contact {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 7px 12px; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.btn-contact:hover { border-color: var(--flame); color: var(--flame); }
.contact-preview { display: block; color: var(--muted); font-size: 12.3px; margin-top: 5px; max-width: 220px; }

.inp-test {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 7px 10px;
  font-size: 13px; width: 170px; background: var(--card);
}
.inp-test:focus { outline: none; border-color: var(--orange); }
.inp-test.saved { border-color: var(--ok); background: var(--ok-bg); }

.btn-del {
  border: none; background: transparent; color: #d9cbb7; font-size: 15px;
  padding: 4px 6px; border-radius: 8px;
}
.btn-del:hover { color: var(--danger); background: #fee2e2; }

/* ---------- Quản lý khoá học ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; box-shadow: 0 6px 20px rgba(150, 84, 20, 0.07);
}
.add-card h3 { font-family: var(--display); font-size: 17px; margin-bottom: 12px; color: var(--flame); }
.add-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.add-grid input {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  flex: 1 1 200px; background: #fffdf9;
}
.add-grid input:focus { outline: none; border-color: var(--orange); }
.hint { color: var(--muted); font-size: 13px; margin: 14px 2px; }

.course-list { display: flex; flex-direction: column; gap: 10px; }
.course-row {
  display: grid; gap: 10px; align-items: center;
  grid-template-columns: 64px 1.6fr 1.3fr 1.2fr 76px auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.course-row.inactive { opacity: 0.6; background: #f7f1e8; }
.course-row input[type="text"], .course-row input[type="number"] {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%;
  background: #fffdf9;
}
.course-row input:focus { outline: none; border-color: var(--orange); }
.course-active { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.course-active input { width: 17px; height: 17px; accent-color: var(--flame); }
.course-actions { display: flex; gap: 8px; }
.btn-save {
  border: none; border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 13px;
  background: #e8f7ef; color: var(--ok);
}
.btn-save:hover { background: #d1fae5; }
.btn-remove {
  border: none; border-radius: 10px; padding: 9px 12px; font-weight: 700; font-size: 13px;
  background: #fdeeee; color: var(--danger);
}
.btn-remove:hover { background: #fee2e2; }
@media (max-width: 980px) {
  .course-row { grid-template-columns: 1fr 1fr; }
  .course-row .course-actions { grid-column: 1 / -1; }
}

/* ---------- Modal liên hệ phụ huynh ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(60, 36, 8, 0.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 16px; padding: 20px;
  box-shadow: 0 30px 80px rgba(60, 36, 8, 0.35);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { font-family: var(--display); font-size: 18px; color: var(--flame); }
.contact-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.contact-item {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fdf7ee; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.contact-item .c-date { font-weight: 700; color: var(--flame); white-space: nowrap; font-size: 13px; }
.contact-item .c-text { flex: 1; font-size: 13.8px; }
.contact-empty { color: var(--muted); font-size: 13.5px; padding: 8px 2px; }
.contact-add { border-top: 1px dashed var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.contact-add label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13.5px; }
.contact-add input, .contact-add textarea {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; font-weight: 400;
  background: #fffdf9; resize: vertical;
}
.contact-add input:focus, .contact-add textarea:focus { outline: none; border-color: var(--orange); }
.contact-add .btn-primary { align-self: flex-start; }
