/* =======================================================================
 *  MQ 報名系統 — 管理後台樣式
 * ======================================================================= */

body.admin { background: #f6f1ed; }

/* 確保 hidden 屬性永遠生效（修正 .login-view 等 display 規則蓋過 [hidden] 的問題）*/
[hidden] { display: none !important; }

.btn-sm { padding: 7px 14px; font-size: .88rem; }

/* 登入 */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--line);
  border-radius: 18px; padding: 32px; box-shadow: var(--shadow); text-align: center;
}
.login-card h2 { font-size: 1.3rem; margin-bottom: 4px; }
.back-home { display: inline-block; margin-top: 16px; font-size: .88rem; color: var(--muted); }
.back-home:hover { color: var(--coral-dark); }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 1rem; margin: 14px 0; font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }

/* Header */
.admin-header {
  display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 60px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.tabs { display: flex; gap: 6px; margin-left: 12px; flex: 1; }
.tab {
  background: transparent; border: none; padding: 8px 16px; border-radius: 999px;
  font-family: inherit; font-size: .95rem; font-weight: 700; color: var(--muted); cursor: pointer;
}
.tab:hover { background: #f6f1ed; }
.tab.is-active { background: var(--coral); color: #fff; }

.admin-main { padding: 22px 24px; }

/* 工具列 */
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input, .filters select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-family: inherit; font-size: .92rem; background: #fff;
}
.filters input[type="search"] { min-width: 240px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--coral); }

.stats { display: flex; gap: 18px; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 18px; }
.stat b { font-size: 1.4rem; color: var(--coral-dark); display: block; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }

/* 表格 */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #fbf4ef; font-weight: 700; position: sticky; top: 0; }
tbody tr { cursor: pointer; transition: .12s; }
tbody tr:hover { background: #fffaf8; }
td.wrap-cell { white-space: normal; max-width: 220px; }

.badge-status {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700;
  background: #eee; color: #555;
}
.s-待匯款 { background: #fde8e3; color: #c95a44; }
.s-已匯款待核對 { background: #fff3d6; color: #b8860b; }
.s-已核對, .s-已寄送測驗 { background: #e1f0ff; color: #2f6fb0; }
.s-已預約諮詢 { background: #e6e1ff; color: #5b4ec9; }
.s-已完成 { background: #e2f5ea; color: #2f8f5b; }
.s-取消／無效 { background: #eee; color: #888; }

.empty { text-align: center; padding: 40px; color: var(--muted); }
.amount { font-weight: 700; color: var(--coral-dark); }

/* 抽屜 */
.drawer-overlay { position: fixed; inset: 0; background: rgba(40,30,25,.4); z-index: 40; }
.drawer-overlay[hidden] { display: none; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 92vw;
  background: #fff; z-index: 50; box-shadow: -10px 0 40px rgba(0,0,0,.15);
  display: flex; flex-direction: column; animation: slideIn .22s ease;
}
.drawer[hidden] { display: none; }
@keyframes slideIn { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; }
.x { background: none; border: none; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); }
.drawer-body { padding: 22px; overflow: auto; }

.detail-row { display: flex; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.detail-row .k { width: 110px; flex-shrink: 0; color: var(--muted); font-weight: 700; }
.detail-row .v { flex: 1; white-space: pre-wrap; }
.drawer-body label { display: block; font-weight: 700; font-size: .9rem; margin: 18px 0 6px; }
.drawer-body select, .drawer-body textarea, .drawer-body input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-family: inherit; font-size: .95rem;
}
.drawer-body select:focus, .drawer-body textarea:focus, .drawer-body input:focus { outline: none; border-color: var(--coral); }

/* 折扣碼編輯 */
.code-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.code-edit-grid .full { grid-column: 1 / -1; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: .85rem; }
.icon-btn:hover { border-color: var(--coral); color: var(--coral-dark); }
.icon-btn.danger:hover { border-color: #d9534f; color: #d9534f; }

@media (max-width: 640px) {
  .filters input[type="search"] { min-width: 100%; }
  .admin-header { padding: 0 14px; gap: 10px; }
  .admin-main { padding: 16px 12px; }
}
