/* 技能檢定報名系統 — 共用樣式 */
:root {
  --brand-900: #274b70;
  --brand-800: #2f5a85;
  --brand-700: #3a6d9f;
  --brand-600: #5b8cc0;
  --brand-100: #dbe9f7;
  --brand-50: #f0f6fc;
  --accent: #3f82d0;
  --accent-hover: #336fb6;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #6b7280;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --bg: #f5f8fb;
  --card: #ffffff;
  --danger: #c0392b;
  --danger-bg: #fdf0ee;
  --ok: #1f7a4d;
  --ok-bg: #edf7f1;
  --warn-bg: #fff8e6;
  --z: 1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 39, 68, .06), 0 4px 16px rgba(15, 39, 68, .06);
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Heiti TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 頁首 ---------- */
.topbar { background: linear-gradient(90deg, #e3eefa, #f3f8fd); color: var(--brand-900); border-bottom: 1px solid var(--brand-100); }
.topbar-inner { max-width: 1600px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 15px; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; }
.who-chip { background: #fff; border: 1px solid var(--brand-100); padding: 4px 12px; border-radius: 999px; }
.btn-logout { color: var(--brand-800); background: #fff; border: 1px solid var(--line-2); padding: 5px 14px; border-radius: 8px; font-size: 14px; }
.btn-logout:hover { background: var(--brand-50); text-decoration: none; }

.mainnav { background: var(--card); border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(0,0,0,.02); }
.mainnav ul { max-width: 1600px; margin: 0 auto; padding: 0 24px; list-style: none; display: flex; gap: 4px; }
.mainnav a { display: block; padding: 14px 22px; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; }
.mainnav a:hover { color: var(--brand-700); text-decoration: none; background: var(--brand-50); }
.mainnav a.current { color: var(--brand-700); border-bottom-color: var(--accent); }

/* ---------- 版面 ---------- */
.layout { max-width: 1600px; margin: 24px auto; padding: 0 24px; display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.sidebar { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 12px; position: sticky; top: 16px; }
.sidebar h2 { font-size: 17px; margin: 0 8px 12px; color: var(--brand-800); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink-2); font-size: 15.5px; }
.sidebar a:hover { background: var(--brand-50); color: var(--brand-700); text-decoration: none; }
.sidebar a.current { background: var(--brand-100); color: var(--brand-900); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }

.content { min-width: 0; }
.breadcrumb { font-size: 14px; color: var(--ink-3); margin-bottom: 4px; }
.breadcrumb span + span::before { content: "›"; margin: 0 8px; color: var(--line-2); }
.page-title { font-size: 26px; margin: 0 0 18px; color: var(--brand-900); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 20px; }
.card h3 { font-size: 17.5px; margin: 0 0 14px; color: var(--brand-800); display: flex; align-items: center; gap: 8px; }
.card h3::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }

/* ---------- 表單元件 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 18px; font: inherit; font-size: 15.5px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-danger { background: #fff; color: var(--danger); border-color: #e7b7b0; }
input[type=text], input[type=password], select, textarea { font: inherit; font-size: 16px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,209,.15); }

.file-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.file-drop { flex: 1; min-width: 280px; border: 1.5px dashed var(--line-2); border-radius: 8px; padding: 10px 14px; background: #fafbfc; }
.check-danger { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--danger); font-weight: 600; font-size: 14px; }

.notes { margin: 0; padding-left: 22px; color: var(--ink-2); }
.notes li { margin: 3px 0; }
.notes .em { color: var(--danger); }

.alert { border-radius: 8px; padding: 12px 16px; font-size: 14.5px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.muted { color: var(--ink-3); font-size: 15px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th { background: #f7f8fa; color: var(--ink-2); font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.data tbody tr:nth-child(even) { background: #fbfcfd; }
table.data tbody tr:hover { background: var(--brand-50); }
table.data tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .center { text-align: center; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-active { background: var(--brand-700); color: #fff; }

/* ---------- 頁尾 ---------- */
.footer { text-align: center; color: var(--ink-3); font-size: 14px; padding: 24px 16px 32px; }

/* ---------- 登入頁 ---------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(1200px 600px at 20% 0%, #e6f0fa 0%, transparent 60%), var(--bg); }
.login-wrap { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 900px; display: grid; grid-template-columns: 1fr 1.15fr; background: var(--card); border-radius: 16px; box-shadow: 0 20px 50px rgba(39,75,112,.12); overflow: hidden; }
.login-hero { background: linear-gradient(160deg, #e1edf9, #c3daf2); color: var(--brand-900); padding: 40px 36px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero .region { font-size: 40px; font-weight: 800; letter-spacing: 2px; line-height: 1.2; }
.login-hero .system { font-size: 19px; margin-top: 8px; color: var(--brand-800); }
.login-hero .illus { margin-top: 28px; opacity: .9; }
.login-form { padding: 40px 40px 36px; }
.login-form h1 { font-size: 22px; margin: 0 0 4px; color: var(--brand-900); }
.login-form .sub { margin: 0 0 24px; color: var(--ink-3); font-size: 15px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 15px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field input { width: 100%; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { width: 120px; text-transform: uppercase; letter-spacing: 3px; }
.captcha-row img { border-radius: 6px; border: 1px solid var(--line); cursor: pointer; height: 40px; }
.login-form .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 16px; margin-top: 8px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .login-card { grid-template-columns: 1fr; }
  .login-hero { padding: 28px; }
  .mainnav ul { overflow-x: auto; }
}

/* ---------- 大螢幕等比放大（避免 2K/4K 螢幕字太小） ---------- */
@media screen and (min-width: 1700px) { :root { --z: 1.12; } }
@media screen and (min-width: 2000px) { :root { --z: 1.25; } }
@media screen and (min-width: 2400px) { :root { --z: 1.4; } }
@media screen and (min-width: 3000px) { :root { --z: 1.7; } }

.topbar, .mainnav, .layout, .footer, .login-card, body.popup { zoom: var(--z); }

/* ---------- 列印 ---------- */
@media print {
  .topbar, .mainnav, .sidebar, .footer, .breadcrumb, .page-title, .no-print { display: none !important; }
  body { background: #fff; }
  .topbar, .mainnav, .layout, .footer, .login-card, body.popup { zoom: 1 !important; }
  .layout { display: block; margin: 0; padding: 0; }
  .card { box-shadow: none; padding: 0; }
}

/* 上傳訊息：沿用舊站配色（失敗標題紅、列號綠、欄位紅） */
.alert-error { background: var(--danger-bg); color: var(--ink); line-height: 1.8; }
.msg-fail, .msg-cell { color: var(--danger); font-weight: 600; }
.msg-row { color: var(--ok); font-weight: 600; }
.msg-ok { color: var(--accent); font-weight: 600; }

/* 錯誤紀錄彈出視窗 */
.log-dialog { width: min(820px, calc(92vw / var(--z))); height: min(640px, calc(86vh / var(--z))); padding: 12px; border: 0; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(15, 30, 60, .35); }
.log-dialog::backdrop { background: rgba(15, 30, 60, .45); }
.log-dialog form { text-align: right; margin-bottom: 8px; }
.log-dialog iframe { width: 100%; height: calc(100% - 48px); border: 1px solid var(--line); border-radius: 8px; }
body.popup { background: #fff; padding: 12px 16px; }
.log-view { font-size: 14px; line-height: 1.7; word-break: break-all; }

/* 照片批次上傳 */
.drop-zone { display: flex; align-items: center; gap: 14px; padding: 28px; border: 2px dashed var(--line-2);
  border-radius: var(--radius); background: var(--brand-50); }
.drop-zone.over { border-color: var(--accent); background: #e3edfa; }
.drop-hint { color: var(--ink-3); }
.upload-total { height: 6px; margin-top: 14px; background: var(--line); border-radius: 3px; overflow: hidden; }
.upload-total-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.gallery { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
  margin: 18px 0 0; padding: 0; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--card); font-size: 13px; }
.tile-thumb { height: 140px; display: flex; align-items: center; justify-content: center; background: var(--bg);
  border-radius: 6px; overflow: hidden; }
.tile-thumb img { max-width: 100%; max-height: 100%; }
.tile-name { margin-top: 8px; word-break: break-all; color: var(--ink-2); }
.tile-progress { height: 4px; margin-top: 6px; background: var(--line); border-radius: 2px; overflow: hidden; }
.tile-progress div { height: 100%; width: 0; background: var(--accent); }
.tile.ok .tile-progress div { width: 100%; background: var(--ok); }
.tile.failed .tile-progress div { background: var(--danger); }
.tile-status { margin-top: 4px; font-weight: 600; }
.tile.ok .tile-status { color: var(--ok); }
.tile.failed .tile-status { color: var(--danger); }
.tile-retry { margin-top: 6px; }
.notes-plain { margin-top: 16px; color: var(--ink-2); }
.btn-small { padding: 4px 10px; font-size: 13px; }
[hidden] { display: none !important; }

/* 編輯學生資料 */
.class-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.class-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line-2);
  border-radius: 999px; color: var(--ink-2); font-size: 15px; background: var(--card); }
.class-chip .count { font-size: 12.5px; color: var(--ink-3); }
.class-chip:hover { border-color: var(--accent); color: var(--accent); }
.class-chip.current { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.search-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-row input { width: 12em; }
table.data.compact td, table.data.compact th { padding: 8px 7px; font-size: 14px; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); }
.thumb { border-radius: 4px; display: block; margin: 0 auto; }
mark { background: #ffff66; color: #000; padding: 0; }
form.inline { display: inline; }
.link-button { background: none; border: 0; padding: 0 0 0 6px; color: var(--accent); cursor: pointer; font: inherit; }
.link-button.danger { color: var(--danger); }
.stu-dialog { width: min(920px, calc(94vw / var(--z))); height: calc(90vh / var(--z)); }
.popup-title { font-size: 20px; text-align: center; margin: 4px 0 12px; color: var(--brand-800); }
.popup-actions { margin-bottom: 10px; }
.form-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.form-table th, .form-table td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: middle; }
.form-table th { width: 26%; background: var(--brand-50); text-align: left; font-weight: 600; color: var(--ink-2); }
.form-table input[type=text], .form-table input:not([type]), .form-table select { padding: 5px 8px; border: 1px solid var(--line-2);
  border-radius: 6px; background: #fffde6; font: inherit; }
.w-3 { width: 4em; } .w-4 { width: 5em; } .w-10 { width: 11em; } .w-20 { width: 20em; } .w-30 { width: 30em; max-width: 100%; }
.test-type { display: flex; gap: 24px; align-items: flex-start; }
.test-type .radios label { display: block; }
.inline-check { margin-right: 16px; }
.col-wide { min-width: 15em; }
.col-wide { min-width: 12em; }
table.data.sticky-actions th:last-child, table.data.sticky-actions td:last-child { position: sticky; right: 0;
  background: var(--card); box-shadow: -6px 0 8px -6px rgba(15, 39, 68, .18); }
table.data.sticky-actions thead th:last-child { background: #f7f8fa; }
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.fee-check { white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.help-options label { display: block; margin: 2px 0; }
.help-text { width: 250px; max-width: 100%; padding: 3px 6px; border: 1px solid var(--line-2); border-radius: 4px; }
.help-table td { vertical-align: top; }
.help-table .btn { white-space: nowrap; } .help-options .help-text { display: inline-block; height: 30px; padding: 3px 8px; margin-left: 4px; vertical-align: middle; }
table.data tfoot .total-row td { background: var(--brand-50); font-weight: 600; border-top: 2px solid var(--line-2); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input[type=text], .inline-form input[type=password] { width: 14em; }
form.inline { display: inline; }
.inline-form .num-input { width: 5em; }
.inline-form .wide-input { width: 16em; }
.toolbar.center { justify-content: center; }
th.right { text-align: right; }
