/* 磁鐵強工作室 會員管理系統 — 樣式表 */

:root {
  /* 品牌色（與磁鐵強工作室官網及練習系統一致） */
  --bg: #f7f7f7;
  --panel: #ffffff;
  --ink: #2f2b36;
  --ink-soft: #76747b;
  --line: #e6e5ea;
  --line-2: #d6d5dc;
  --side: #2f2b36;          /* 炭黑 */
  --brand: #c94001;         /* 磚橙 */
  --brand-dark: #a23400;
  --brand-soft: #fdf1ec;
  /* 語義色 */
  --ok: #1c8a4e;
  --ok-soft: #e9f7ef;
  --warn: #a86400;
  --warn-soft: #fdf1dc;
  --danger: #c0392b;
  --danger-soft: #fcedeb;
  --info: #2f6fa8;
  --info-soft: #e6f1fa;
  /* 形狀 */
  --radius: 16px;
  --shadow: 0 1px 2px rgba(47, 43, 54, 0.05), 0 6px 20px rgba(47, 43, 54, 0.06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Heiti TC", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app-loading { padding: 60px; color: var(--ink-soft); }

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 登入／首次設定（與練習系統一致的品牌版面） ---------- */

.auth-wrap { min-height: 100vh; background: var(--bg); padding: 0; }
/* 尺寸完全對齊練習系統登入頁：
   外層（＝練習系統的 main）padding 14px、最大 620px，
   內層 .login-wrap 在寬螢幕（≥700px）放大到 620px，
   所以桌面上的卡片寬度 = 592 − 32 = 560px，與練習系統一致。 */
.login-outer { padding: 14px; max-width: 620px; margin: 0 auto; }
.login-wrap { max-width: 480px; margin: 0 auto; padding: 0 16px 34px; }
@media (min-width: 700px) {
  .login-wrap { max-width: 620px; }
}
@media (max-width: 520px) {
  .login-card .brand-logo { width: 180px; }
}
.brand-hero {
  display: block;
  width: 100%;
  height: auto;
  margin: 16px 0 -26px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 0;
}
.login-wrap .login-card { position: relative; z-index: 1; padding: 18px 18px 24px; margin: 0; border-radius: var(--radius); }
.login-card .brand-logo { display: block; width: 210px; max-width: 74%; height: auto; margin: 0 auto 12px; }
.login-card h1 { text-align: center; font-size: 19px; line-height: 1.6; font-weight: 800; margin: 0 0 26px; letter-spacing: 0.4px; }

/* 欄位尺寸與練習系統登入頁完全一致（標籤、輸入框、按鈕） */
.login-card .field { margin-bottom: 0; }
/* 登入表單一律單欄（否則帳號與密碼會並排，與練習系統不同） */
.login-card .form-grid { grid-template-columns: 1fr; }
.login-card .field > label,
.login-card label.f {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 20px 0 6px;
  letter-spacing: 0.3px;
}
.login-card .field > label .req { display: none; }
.login-card input[type='text'],
.login-card input[type='password'] {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  line-height: normal;
  padding: 11px 13px;
  border: 1.5px solid var(--line-2);
  border-radius: 12px;
  background: #fff;
}
.login-card input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(201, 64, 1, 0.12); }
.login-card .field .help { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.login-card .btnrow { display: block; margin-top: 26px; }
.login-card .btn {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  padding: 12px 17px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.login-card ul.courses {
  list-style: none;
  margin: 0 auto 20px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 8px;
  align-items: center;
  max-width: 340px;
}
.login-card ul.courses li {
  background: #f1f0f3;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #4e4959;
  text-align: center;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-tagline { text-align: center; color: var(--brand-dark); font-size: 12.5px; font-weight: 700; letter-spacing: 1px; margin: 30px 0 0; }
.brand-foot { text-align: center; color: var(--ink-soft); font-size: 11px; line-height: 1.7; margin: 24px 0 0; }
.login-terms { text-align: center; color: var(--ink-soft); font-size: 12px; line-height: 1.7; margin: 24px 0 0; }
.login-terms a { color: var(--brand-dark); text-decoration: none; border-bottom: 1px solid #f2c4ac; }
/* 登入頁下方的「新學員報名」按鈕（放在卡片外，卡片尺寸才與練習系統一致） */
.login-extra { margin-top: 14px; }
.login-extra .btn { display: flex; justify-content: center; font-weight: 700; padding: 12px 17px; border-radius: 12px; }
/* 蜜罐欄位：真人看不到，但機器人會填 */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.auth-foot { margin-top: 14px; font-size: 12.5px; color: var(--ink-soft); }
.auth-card .sub { color: var(--ink-soft); margin-bottom: 18px; font-size: 14px; }

/* ---------- 版面 ---------- */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--side);
  color: #cfcbd6;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar .brand {
  color: #fff;
  font-weight: 700;
  font-size: 15.5px;
  padding: 6px 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar .brand .brand-mark { width: 32px; height: 32px; flex: 0 0 32px; }
.sidebar .brand .brand-text { min-width: 0; }
.sidebar .brand small { display: block; font-weight: 400; font-size: 12px; color: #a9a4b3; margin-top: 3px; }
.nav-group { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: #8b8695; padding: 12px 10px 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 9px;
  color: #cfcbd6;
  font-size: 14.5px;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav .ico { width: 18px; text-align: center; }
.sidebar .spacer { flex: 1; }
.sidebar .who { font-size: 12.5px; color: #a9a4b3; padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.12); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.topbar .title { font-size: 17px; font-weight: 700; }
.topbar .title small { font-weight: 400; color: var(--ink-soft); margin-left: 8px; font-size: 13px; }
.content { padding: 20px 22px 46px; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card > header h2 { margin: 0; font-size: 16px; }
.card .hint { color: var(--ink-soft); font-size: 13px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .k { color: var(--ink-soft); font-size: 13px; }
.stat .v { font-size: 25px; font-weight: 700; margin-top: 2px; }
.stat .u { font-size: 13px; color: var(--ink-soft); font-weight: 400; margin-left: 3px; }
.stat.accent { background: var(--brand-soft); border-color: #cfdaff; }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f7f9fd; color: var(--ink-soft); font-weight: 600; font-size: 13px; position: sticky; top: 0; }
tbody tr:hover { background: #f8faff; }
tbody tr.clickable { cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 26px; text-align: center; color: var(--ink-soft); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 10px; font-size: 13.5px; color: var(--ink-soft); }

/* ---------- 表單與按鈕 ---------- */

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 160px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], input[type="search"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cfd6e4;
  border-radius: 8px;
  font: inherit;
  color: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f6c9ae; border-color: var(--brand); }
textarea { min-height: 74px; resize: vertical; }
input[type="checkbox"] { width: 17px; height: 17px; }

.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #39435c; }
.field .req { color: var(--danger); margin-left: 2px; }
.field .help { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.field .err { font-size: 12.5px; color: var(--danger); margin-top: 3px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); background: #fffafa; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 4px; margin: 0 0 14px; }
legend { font-size: 13px; font-weight: 700; color: var(--brand-dark); padding: 0 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #cfd6e4;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f4f6fb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.wide { width: 100%; justify-content: center; }
.btn.danger { color: var(--danger); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; background: #eef1f7; color: #404a63; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.money { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.row-split { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- 分頁籤 ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button {
  border: none;
  background: transparent;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 600; }

/* ---------- 彈出視窗 ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 22, 40, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  box-shadow: 0 24px 60px rgba(10, 20, 50, 0.34);
}
.modal.narrow { max-width: 460px; }
.modal header { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; font-size: 17px; }
.modal .body { padding: 18px 20px; }
/* 表單很長時（例如新增會員有 18 個欄位），讓按鈕固定在畫面下方，不用滾動才找得到 */
.modal footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--panel);
  border-radius: 0 0 14px 14px;
  box-shadow: 0 -6px 14px rgba(20, 30, 60, 0.06);
}
.modal .x { border: none; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink-soft); }

/* ---------- 提示訊息 ---------- */

.toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  background: var(--side);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(10, 20, 40, 0.3);
  font-size: 14px;
  max-width: 380px;
  animation: toast-in 0.16s ease-out;
}
.toast.ok { background: #10884f; }
.toast.err { background: #c02b2b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 點名表 ---------- */

.roll { display: grid; gap: 8px; }
.roll-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  flex-wrap: wrap;
}
.roll-row .name { min-width: 150px; font-weight: 600; }
.roll-row .seg { display: flex; gap: 4px; margin-left: auto; }
.seg button { border: 1px solid #cfd6e4; background: #fff; padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.seg button.on.present { background: var(--ok); border-color: var(--ok); }
.seg button.on.late { background: var(--warn); border-color: var(--warn); }
.seg button.on.leave { background: var(--info); border-color: var(--info); }
.seg button.on.absent { background: var(--danger); border-color: var(--danger); }

.lesson-list { display: flex; gap: 8px; flex-wrap: wrap; }
.lesson-chip {
  border: 1px solid #cfd6e4;
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.lesson-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.lesson-chip .dot { color: var(--ok); }

.detail-list { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.detail-list dt { color: var(--ink-soft); }

@media (max-width: 860px) {
  /* 手機上不用格線版面：格線的最小內容寬度容易被內容撐開，改用區塊堆疊最穩 */
  .shell { display: block; min-height: 100vh; }
  .sidebar {
    flex-direction: row;
    overflow-x: auto;
    align-items: center;
    padding: 10px;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar .brand, .sidebar .who, .nav-group, .sidebar .spacer { display: none; }
  .nav { display: flex; gap: 6px; }
  .nav a { white-space: nowrap; }
  .main { min-width: 0; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
  /* 手機上改用兩欄，儀表板才不會太長 */
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat { padding: 12px 13px; }
  .stat .v { font-size: 21px; }
  .card { padding: 14px; }
  .modal-backdrop { padding: 12px 8px; }
}
