/* ============================================================
   common.css — 全域共用樣式
   保險即時問答平台
   ============================================================ */

/* ── CSS 變數（全域主題色彩） ── */
:root {
  --bg-primary:    #1a1a2e;
  --bg-card:       #16213e;
  --bg-card-hover: #1a2a4a;
  --accent:        #e94560;
  --accent-hover:  #c73652;
  --text-primary:  #ffffff;
  --text-secondary:#a0a0b0;
  --border:        #0f3460;
  --border-hover:  #1a4080;
  --success:       #4caf50;
  --warning:       #ff9800;
  --error:         #f44336;
  --gold:          #ffd700;
}

/* ── 基礎重置 ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── 捲軸美化（深色細滾輪） ── */
::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: #0f3460; border-radius: 3px; }
::-webkit-scrollbar-thumb        { background: #1a3a6c; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: var(--accent); }

/* ── 基礎字型 ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'PingFang TC', 'Noto Sans TC', sans-serif;
  background-color: var(--bg-primary);
  color: #eaeaea;
}

/* ── 共用按鈕（可搭配 .btn-primary / .btn-secondary / .btn-danger） ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  font-family: inherit;
  text-decoration: none;
}
.btn:active:not(:disabled)  { transform: scale(0.96); }
.btn:disabled               { opacity: 0.38; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(233,69,96,0.22);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px rgba(233,69,96,0.35);
}

.btn-secondary {
  background: transparent;
  color: #888;
  border: 1px solid #333;
}
.btn-secondary:hover:not(:disabled) { color: #eaeaea; border-color: #555; }

.btn-danger {
  background: transparent;
  color: #f87171;
  border: 1px solid #f87171;
}
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,0.12); }

/* ── 共用卡片 ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: var(--border-hover); }

/* ── 共用 Modal 遮罩 ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ── 共用表單 ── */
.form-group  { margin-bottom: 14px; }
.form-label  { display: block; font-size: 0.82rem; color: #aaa; margin-bottom: 6px; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: #eaeaea;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(233,69,96,0.14);
}
.form-select option { background: var(--bg-card); }
.form-textarea      { resize: vertical; min-height: 72px; }

/* ── 空狀態 ── */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: #555;
}
.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-text { font-size: 0.875rem; line-height: 1.65; }
.empty-hint { font-size: 0.78rem; color: #444; margin-top: 6px; }

/* ── 共用動畫關鍵幀 ── */

/* 入場：從下滑入 */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 縮放彈出 */
@keyframes popIn {
  0%   { transform: scale(0.6); opacity: 0; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1);   opacity: 1; }
}

/* 答對爆炸入場 */
@keyframes correctBurst {
  0%   { transform: scale(0.5); opacity: 0; }
  55%  { transform: scale(1.1); }
  100% { transform: scale(1);   opacity: 1; }
}

/* 答錯震動 */
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-10px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(4px); }
}

/* 旋轉（載入用） */
@keyframes spin { to { transform: rotate(360deg); } }

/* 加分浮動 */
@keyframes scoreFloat {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-80px); }
}

/* ── 全頁載入遮罩（utils.js 注入，此處僅補充更好看的旋轉器樣式） ── */
#loading-overlay {
  backdrop-filter: blur(2px);
}

/* ── Toast 通知（utils.js 注入） ── */
#toast-container {
  pointer-events: none;
}
