/* ============================================================
   Trick Lab Studio — 管理後台
   ============================================================ */

:root {
  --bg: #0a0a0c;
  --ink: #f5f3f0;
  --ink-dim: rgba(245, 243, 240, 0.62);
  --ink-faint: rgba(245, 243, 240, 0.38);
  --orange: #ff6a00;
  --orange-hi: #ff8b2e;
  --orange-soft: rgba(255, 106, 0, 0.14);
  --glass: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.1);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Noto Sans TC", "Space Grotesk", sans-serif;
  background:
    radial-gradient(ellipse 60% 40% at 85% -10%, rgba(255, 106, 0, 0.1), transparent),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-weight: 700; font-size: 14px;
  padding: 10px 20px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn--primary {
  background: linear-gradient(135deg, var(--orange-hi), var(--orange));
  color: #120a04; box-shadow: 0 8px 22px rgba(255, 106, 0, 0.35);
}
.btn--primary:hover { transform: translateY(-1px); }
.btn--ghost { background: rgba(255,255,255,0.06); border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: rgba(255,255,255,0.11); }
.btn--sm { padding: 6px 13px; font-size: 12.5px; }
.btn--danger { background: transparent; border-color: rgba(255,90,60,0.4); color: #ff7a5c; }
.btn--danger:hover { background: rgba(255,90,60,0.12); }

/* ---------- 登入 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login__card {
  width: min(360px, 100%); text-align: center;
  background: var(--glass); border: 1px solid var(--line); border-radius: 20px;
  backdrop-filter: blur(20px); padding: 40px 32px;
  display: flex; flex-direction: column; gap: 12px;
}
.login__mark {
  display: grid; place-items: center; margin: 0 auto;
  width: 52px; height: 52px; border-radius: 15px;
  font-family: "Space Grotesk"; font-weight: 700; font-size: 20px; color: #120a04;
  background: linear-gradient(135deg, var(--orange-hi), var(--orange));
  box-shadow: 0 8px 24px rgba(255, 106, 0, 0.4);
}
.login__mark--sm { width: 34px; height: 34px; font-size: 14px; border-radius: 10px; margin: 0; }
.login__card h1 { font-size: 21px; font-weight: 900; }
.login__hint { color: var(--ink-faint); font-size: 12.5px; margin-bottom: 8px; }
.login__card input {
  font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: rgba(255,255,255,0.05); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; outline: none;
}
.login__card input:focus { border-color: var(--orange); }
.login__err { color: #ff7a5c; font-size: 13px; min-height: 18px; }

/* ---------- 主介面 ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: 220px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.02); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-size: 15px; }
.side__nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.side__group {
  font-size: 11px; font-weight: 700; letter-spacing: 2px; color: var(--orange);
  padding: 14px 10px 6px;
}
.side__link {
  text-align: left; font-family: inherit; font-size: 13.5px; color: var(--ink-dim);
  background: none; border: none; border-radius: 9px; padding: 8px 10px; cursor: pointer;
}
.side__link:hover { background: rgba(255,255,255,0.06); color: var(--ink); }
.side__link.is-active { background: var(--orange-soft); color: var(--orange-hi); font-weight: 700; }
.side__logout {
  font-family: inherit; font-size: 13px; color: var(--ink-faint);
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px; cursor: pointer; margin-top: 12px;
}
.side__logout:hover { color: var(--ink); }

.main { flex: 1; padding: 26px 30px; min-width: 0; }
.main__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.main__head h2 { font-size: 22px; font-weight: 900; }
.main__body { overflow-x: auto; }
.empty { color: var(--ink-faint); padding: 40px 0; text-align: center; }

/* ---------- 總覽儀表板 ---------- */
.dash-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 26px;
}
.dash-card {
  font-family: inherit; text-align: left; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; color: var(--ink);
  transition: all 0.2s ease;
}
.dash-card:hover { border-color: rgba(255, 106, 0, 0.4); transform: translateY(-2px); }
.dash-card strong {
  display: block; font-family: "Space Grotesk"; font-size: 28px; font-weight: 700;
}
.dash-card span { font-size: 12px; color: var(--ink-faint); }
.dash-card.is-hot { border-color: rgba(255, 106, 0, 0.5); background: var(--orange-soft); }
.dash-card.is-hot strong { color: var(--orange-hi); }
.dash-sub { font-size: 15px; font-weight: 700; margin: 6px 0 12px; }
.grid-count { color: var(--ink-faint); font-size: 12px; margin-bottom: 8px; }

/* 搜尋框 */
.search {
  flex: 1; max-width: 280px;
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 16px; outline: none;
}
.search:focus { border-color: var(--orange); }

.btn--ok {
  background: rgba(87, 227, 155, 0.12); border-color: rgba(87, 227, 155, 0.4); color: #57e39b;
}
.btn--ok:hover { background: rgba(87, 227, 155, 0.22); }

/* ---------- 資料表 ---------- */
.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th {
  text-align: left; font-size: 12px; color: var(--ink-faint); font-weight: 500;
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.grid td {
  padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.grid tr:hover td { background: rgba(255,255,255,0.03); }
.grid .num { font-family: "Space Grotesk"; }
.grid img.thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 8px; display: block; }
.grid .muted { color: var(--ink-faint); }
.grid .actions { white-space: nowrap; text-align: right; }
.tag {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  color: var(--orange-hi); background: var(--orange-soft);
  border-radius: 999px; padding: 2px 10px;
}
.tag--dim { color: var(--ink-faint); background: rgba(255,255,255,0.06); }
.tag--green { color: #57e39b; background: rgba(87,227,155,0.1); }

/* ---------- 編輯彈窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(5,5,7,0.7); backdrop-filter: blur(6px); }
.modal__card {
  position: relative; width: min(520px, 100%); max-height: 86vh; overflow-y: auto;
  background: #141418; border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 26px 22px;
}
.modal__card h3 { font-size: 18px; font-weight: 900; margin-bottom: 18px; }
.modal__fields { display: flex; flex-direction: column; gap: 13px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; color: var(--ink-dim); }
.field input, .field select, .field textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  background: rgba(255,255,255,0.05); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--orange); }
.field select option { background: #141418; }
.field--check { display: flex; align-items: center; gap: 8px; }
.field--check input { width: 18px; height: 18px; accent-color: var(--orange); }
.field--check label { margin: 0; }
.field__img { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.field__img img { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.field__img input[type="file"] { font-size: 12px; color: var(--ink-faint); }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- 圖片剪裁 ---------- */
.modal__card--crop { width: min(560px, 100%); }
.crop-box {
  width: 100%; max-height: 55vh; overflow: hidden;
  background: rgba(255,255,255,0.03); border-radius: 12px;
}
.crop-box img { display: block; max-width: 100%; }
.crop-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.crop-actions .is-on { border-color: var(--orange); color: var(--orange-hi); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translate(-50%, 70px); opacity: 0;
  background: rgba(20,20,24,0.9); backdrop-filter: blur(14px);
  border: 1px solid rgba(255,138,46,0.4); border-radius: 999px;
  font-size: 13.5px; padding: 11px 24px; z-index: 200; pointer-events: none;
  transition: transform 0.3s, opacity 0.3s;
}
.toast.is-show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .side {
    position: relative; width: 100%; height: auto;
    flex-direction: column; overflow: visible;
    padding: 12px 14px 6px;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .side__brand { padding: 0 0 10px; font-size: 14px; }
  /* 區塊選單改為橫向滑動一行 */
  .side__nav {
    flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    gap: 6px; padding-bottom: 10px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .side__nav::-webkit-scrollbar { display: none; }
  .side__group {
    width: auto; flex: none; align-self: center; white-space: nowrap;
    padding: 0 4px 0 10px; letter-spacing: 1px;
  }
  .side__link {
    flex: none; white-space: nowrap;
    border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  }
  .side__link.is-active { border-color: rgba(255, 106, 0, 0.5); }
  .side__logout {
    position: absolute; top: 10px; right: 14px;
    margin: 0; padding: 6px 14px; width: auto; font-size: 12px;
  }
  .main { padding: 16px 12px 30px; }
  .main__head { margin-bottom: 14px; }
  .main__head h2 { font-size: 17px; }
  .main__head .btn { padding: 8px 16px; font-size: 13px; }
  .grid { font-size: 12.5px; }
  .grid th { padding: 6px 8px; }
  .grid td { padding: 8px; max-width: 150px; }
  .grid .actions .btn { padding: 5px 10px; font-size: 11.5px; }
  .modal { padding: 10px; }
  .modal__card { padding: 20px 16px 16px; max-height: 92vh; }
}
