/* ============================================================
   優瑪設計 YOMA DESIGN — 後台樣式
   ============================================================ */
:root {
  --navy-900: #141542;
  --navy-800: #1b1d55;
  --navy-700: #242663;
  --gold: #b99a5b;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1b2233;
  --ink-soft: #6b7488;
  --line: #e4e7ee;
  --danger: #c0392b;
  --ok: #2e7d5b;
  --sans: 'Noto Sans TC', system-ui, sans-serif;
  --en: 'Cormorant Garamond', serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── 登入頁 ───────────────────────────────── */
.admin-blank { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); }
.login-card { background: #fff; width: min(400px, 92vw); padding: 3rem 2.6rem; box-shadow: 0 30px 80px rgba(0,0,0,0.3); }
.login-logo { width: 150px; display: block; margin: 0 auto 1.8rem; border-radius: 14px; box-shadow: 0 12px 30px rgba(20,21,66,0.28); }
.login-card h2 { font-size: 1.1rem; margin-bottom: 1.4rem; font-weight: 500; }
.login-error { background: #fdecea; color: var(--danger); padding: 0.8rem 1rem; font-size: 0.9rem; margin-bottom: 1.2rem; border-radius: 4px; }

/* ── Layout ───────────────────────────────── */
.admin { display: flex; min-height: 100vh; }
.admin-sidebar { width: 240px; background: var(--navy-900); color: #fff; flex-shrink: 0; padding: 2rem 0; position: sticky; top: 0; height: 100vh; }
.admin-brand { display: block; text-align: center; padding: 0 1.8rem 2rem; border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 1.5rem; }
.ab-logo { width: 72px; height: 72px; border-radius: 50%; display: block; margin: 0 auto 0.7rem; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.ab-sub { font-size: 0.72rem; letter-spacing: 0.14em; color: rgba(255,255,255,0.55); display: block; }
.admin-nav a { display: flex; align-items: center; gap: 0.9rem; padding: 0.9rem 1.8rem; color: rgba(255,255,255,0.7); font-size: 0.95rem; transition: 0.25s; border-left: 2px solid transparent; }
.admin-nav a span { width: 20px; text-align: center; color: var(--gold); }
.admin-nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.admin-nav a.active { background: rgba(185,154,91,0.12); color: #fff; border-left-color: var(--gold); }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar { background: #fff; height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.admin-topbar h1 { font-size: 1.2rem; font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 1.4rem; font-size: 0.9rem; }
.ghost-link { color: var(--ink-soft); transition: color 0.2s; }
.ghost-link:hover { color: var(--navy-800); }
.admin-user { color: var(--navy-800); font-weight: 500; }
.admin-content { padding: 2rem; max-width: 1100px; }

/* ── 卡片與元件 ───────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1.8rem; margin-bottom: 1.6rem; }
.card h2 { font-size: 1.05rem; margin-bottom: 1.2rem; font-weight: 500; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2rem; margin-bottom: 2rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1.6rem; }
.stat .num { font-family: var(--en); font-size: 2.6rem; color: var(--navy-800); line-height: 1; }
.stat .lbl { color: var(--ink-soft); font-size: 0.9rem; margin-top: 0.5rem; }
.stat.alert .num { color: var(--gold); }

/* 表格 */
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { padding: 0.9rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: 0.92rem; vertical-align: middle; }
.table th { color: var(--ink-soft); font-weight: 500; font-size: 0.82rem; letter-spacing: 0.03em; background: #fafbfc; }
.table tr:hover td { background: #fafbfc; }
.thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 4px; background: var(--navy-800); }
.thumb-pair { display: flex; gap: 4px; }
.thumb-pair .thumb { width: 44px; }

/* 標籤 */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.75rem; }
.badge.on { background: #e6f4ec; color: var(--ok); }
.badge.off { background: #eef0f4; color: var(--ink-soft); }
.badge.new { background: #fdf3e3; color: var(--gold); }

/* 按鈕 */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.65rem 1.3rem; border: 1px solid var(--navy-800); background: var(--navy-800); color: #fff; border-radius: 6px; cursor: pointer; font-family: var(--sans); font-size: 0.9rem; transition: 0.2s; }
.btn:hover { background: var(--navy-700); }
.btn-ghost { background: #fff; color: var(--navy-800); }
.btn-ghost:hover { background: #f0f2f6; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; }
.btn-danger { background: #fff; color: var(--danger); border-color: #e9c9c4; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.actions { display: flex; gap: 0.5rem; }

/* 表單 */
.form-row { margin-bottom: 1.4rem; }
.form-row label { display: block; font-size: 0.88rem; margin-bottom: 0.5rem; color: var(--ink); font-weight: 500; }
.form-row .hint { color: var(--ink-soft); font-weight: 400; font-size: 0.8rem; }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=password], .form-row input[type=number], .form-row textarea, .form-row select {
  width: 100%; padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: 6px; font-family: var(--sans); font-size: 0.95rem; color: var(--ink); background: #fff;
}
.form-row textarea { resize: vertical; min-height: 120px; line-height: 1.8; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { outline: none; border-color: var(--navy-500, #33436e); box-shadow: 0 0 0 3px rgba(31,44,77,0.08); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.check-row { display: flex; align-items: center; gap: 0.5rem; }
.check-row input { width: 18px; height: 18px; }
.form-actions { display: flex; gap: 0.8rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

/* 上傳圖片預覽 */
.upload-field { display: grid; grid-template-columns: 120px 1fr; gap: 1rem; align-items: start; }
.upload-preview { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; background: #eef0f4; border: 1px solid var(--line); }
.upload-controls input[type=file] { font-size: 0.85rem; margin-bottom: 0.6rem; }

/* 作品相本管理 */
.admin-album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.8rem; margin-top: 1rem; }
.admin-album-item { position: relative; aspect-ratio: 3/2; border-radius: 6px; overflow: hidden; background: #eef0f4; border: 1px solid var(--line); }
.admin-album-item img { width: 100%; height: 100%; object-fit: cover; }
.album-del { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(192,57,43,0.92); color: #fff; cursor: pointer; font-size: 1.1rem; line-height: 1; display: grid; place-items: center; }
.album-del:hover { background: #c0392b; }

/* 文章編輯器 */
.rt-toolbar { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; padding: 0.6rem; border: 1px solid var(--line); border-bottom: none; border-radius: 6px 6px 0 0; background: #fafbfc; }
.rt-toolbar select, .rt-toolbar button { font-size: 0.85rem; font-family: var(--sans); }
.rt-toolbar select { padding: 0.35rem 0.4rem; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.rt-toolbar button { padding: 0.4rem 0.7rem; border: 1px solid var(--line); background: #fff; border-radius: 4px; cursor: pointer; }
.rt-toolbar button:hover { background: #eef1f6; }
.rt-toolbar .rt-colorlbl { display: flex; align-items: center; gap: 4px; font-size: 0.85rem; color: var(--ink-soft); }
.rt-toolbar input[type=color] { width: 30px; height: 28px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; padding: 2px; }
.rt-toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 0.3rem; }
.rt-editor { min-height: 340px; max-height: 640px; border: 1px solid var(--line); border-radius: 0 0 6px 6px; padding: 1.1rem 1.2rem; background: #fff; line-height: 1.9; overflow-y: auto; }
.rt-editor:focus { outline: none; border-color: var(--navy-700); }
.rt-editor img, .rt-editor video, .rt-editor iframe { max-width: 100%; border-radius: 4px; margin: 0.6rem 0; }
.rt-editor iframe { width: 100%; aspect-ratio: 16/9; }
.rt-editor:empty::before { content: '在此輸入內文，可選取文字後套用字型 / 大小 / 顏色，或插入圖片、影片…'; color: #aab; }

.toast { background: #e6f4ec; color: var(--ok); padding: 0.9rem 1.2rem; border-radius: 6px; margin-bottom: 1.5rem; font-size: 0.92rem; }
.toast.warn { background: #fdecea; color: var(--danger); }
.empty { text-align: center; color: var(--ink-soft); padding: 3rem; }
.muted { color: var(--ink-soft); }
.section-title { font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); margin: 2rem 0 1rem; font-weight: 500; }

@media (max-width: 800px) {
  .admin-sidebar { position: fixed; z-index: 50; transform: translateX(-100%); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}
