/* =========================================================
 * 萃見室內設計平台 — style.css
 * 深色專業風（比照 b7-home-3d 配色語彙：深底 + 暖金強調）
 * ========================================================= */
:root {
  --bg: #14161c;
  --panel: #1b1f27;
  --card: #1e232d;
  --line: rgba(255,255,255,.09);
  --text: #e8e6e1;
  --muted: #9aa3ad;
  --gold: #f0c987;
  --gold-2: #e8956b;
  --danger: #e2726e;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}
/* 已知地雷：其他 display 規則會蓋過 [hidden]，必須用 !important 固定 */
[hidden] { display: none !important; }

button, select, input, textarea { font-family: inherit; }

/* ---------- 通用按鈕 ---------- */
button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: #d8d5cf;
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
button:hover { background: rgba(255,255,255,.12); }
button:disabled { opacity: .4; cursor: not-allowed; }
button:disabled:hover { background: rgba(255,255,255,.05); }
button.primary, button.on {
  background: linear-gradient(135deg, #c98f4e, #a9713a);
  border-color: #d9a86a;
  color: #fff;
}
button.danger:hover {
  background: rgba(226,114,110,.22);
  border-color: var(--danger);
  color: #ffb4b0;
}
a.linkbtn {
  display: inline-block;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: #d8d5cf;
  border-radius: 9px;
  padding: 5px 10px;
  font-size: 12px;
  text-decoration: none;
  transition: .15s;
}
a.linkbtn:hover { background: rgba(255,255,255,.12); color: var(--gold); }

/* ---------- Hub 專案大廳 ---------- */
#hub {
  min-height: 100%;
  padding: 28px clamp(14px, 4vw, 48px) 64px;
  overflow: auto;
}
#hub h1 {
  font-size: 26px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#hub .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.hub-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; }
.hub-note { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.6; }
.hub-note b { color: var(--gold); }
.section-title { font-size: 15px; color: var(--gold); margin: 26px 0 10px; }

#projectGrid, .ext-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: rgba(240,201,135,.4); }
.card-name { font-size: 15px; font-weight: bold; }
.card-meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.card-actions button { font-size: 12px; padding: 5px 10px; }
.hub-empty {
  color: var(--muted); font-size: 14px; padding: 28px;
  border: 1px dashed var(--line); border-radius: var(--radius);
  grid-column: 1 / -1; text-align: center; line-height: 1.7;
}

/* ---------- Studio 工作室 ---------- */
#studio {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
#topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
#projName {
  font-weight: bold; color: var(--gold); font-size: 14px;
  max-width: 26vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#viewTabs { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
#viewTabs button { border: 0; border-radius: 0; }
#toolbar {
  display: flex; gap: 6px; align-items: center;
  flex: 1; min-width: 0;
  overflow-x: auto; padding: 2px;
}
#toolbar button { font-size: 12.5px; }
#toolbar select {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 5px 8px; font-size: 12.5px; max-width: 190px;
}
#sunWrap { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
#sunWrap input[type=range] { width: 110px; accent-color: var(--gold); }

#pane2d, #pane3d { flex: 1; position: relative; overflow: hidden; min-height: 0; }
#pane2d canvas, #pane3d canvas { display: block; }

/* ---------- 匯入 JSON 對話框 ---------- */
#modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#modalBox {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  padding: 18px;
}
#modalBox h3 { color: var(--gold); font-size: 16px; margin-bottom: 10px; }
#modalText {
  width: 100%; height: 220px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 10px; font-size: 12.5px;
  font-family: Consolas, "Courier New", monospace;
  resize: vertical;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- 🎨 面漆對話框（沿用匯入對話框卡片語彙） ---------- */
#finModal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#finBox {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(420px, 100%);
  padding: 18px;
}
#finBox h3 { color: var(--gold); font-size: 16px; margin-bottom: 14px; }
.fin-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.fin-row label { font-size: 13px; min-width: 42px; color: var(--text); }
.fin-row select {
  flex: 1;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 10px; font-size: 13px;
}
.fin-row input[type=color] {
  width: 52px; height: 34px; padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px;
  cursor: pointer;
}
.fin-hint { font-size: 11.5px; color: var(--muted); }

/* ---------- 啟動錯誤 ---------- */
.boot-error {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  background: #5a2a28; color: #ffd7d4;
  border: 1px solid #a05450; border-radius: 10px;
  padding: 10px 16px; font-size: 13px;
  z-index: 999; max-width: 90vw; line-height: 1.6;
}

/* ---------- 手機 ---------- */
@media (max-width: 700px) {
  #hub h1 { font-size: 21px; }
  #topbar { gap: 6px; padding: 6px 8px; }
  #projName { max-width: 38vw; }
  #projectGrid, .ext-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* 觸控裝置：加大工具列按鈕觸控目標（避免誤觸） */
@media (pointer: coarse) {
  #toolbar button, #viewTabs button, .card-actions button {
    padding: 9px 14px;
    font-size: 13.5px;
  }
  #toolbar select { padding: 8px 10px; font-size: 13.5px; }
  /* 新功能按鈕與面漆面板的觸控目標一併加大 */
  #btnWalk, #btnBudget, #btnAIR, #btnFinish, #btnShot, #btnExport,
  .modal-actions button {
    padding: 9px 14px;
    font-size: 13.5px;
  }
  .fin-row select { padding: 10px 12px; font-size: 14px; }
  .fin-row input[type=color] { width: 60px; height: 40px; }
}
