/* ================================================================
   Mouse Click Tester — styles
   配色主軸：深藍底 (#0a0a1a / #12122a)，各按鍵有自己的辨識色
   ================================================================ */

:root {
  --bg:              #0a0a1a;
  --panel:           #12122a;
  --panel-2:         #0e0e20;
  --border:          #2a2a4a;
  --border-soft:     #1e1e3a;
  --text:            #e0e0e0;
  --text-muted:      #888;
  --text-dim:        #666;
  --text-faint:      #444;

  --accent-left:     #3b82f6;  /* 左鍵 藍 */
  --accent-right:    #a855f7;  /* 右鍵 紫 */
  --accent-middle:   #06b6d4;  /* 中鍵 青 */
  --accent-forward:  #f59e0b;  /* 前進 橘 */
  --accent-back:     #eab308;  /* 後退 黃 */
  --accent-scroll:   #22c55e;  /* 滾輪 綠 */

  --ok:              #22c55e;
  --warn:            #f59e0b;
  --danger:          #ef4444;
  --info:            #3b82f6;

  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       16px;

  --shadow-panel:    0 1px 0 rgba(255,255,255,0.02) inset;
}

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

html, body {
  min-height: 100vh;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC',
               'Microsoft JhengHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 版面骨架 ---------- */

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  color: var(--accent-left);
}

.brand h1 {
  font-size: 1.6rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  margin-bottom: 20px;
}

/* ---------- 通用元件 ---------- */

.panel,
.test-panel,
.analytic-card,
.verdict {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}

.panel-title,
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e8e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-icon,
.section-icon {
  color: var(--accent-left);
  font-size: 1.1rem;
}

.section-title {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.muted  { color: var(--text-muted); font-size: 0.85rem; }
.hint   { color: var(--text-dim); font-size: 0.75rem; margin-top: 8px; text-align: center; }
.hidden { display: none !important; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-ghost:hover {
  background: var(--border-soft);
  color: #fff;
  border-color: var(--border);
}

.btn-link {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 6px;
  font-family: inherit;
  transition: color 0.15s;
}

.btn-link:hover { color: var(--accent-left); }

/* ---------- 主測試區 ---------- */

.test-panel {
  padding: 24px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 560px;
}

.mouse-diagram {
  display: flex;
  justify-content: center;
  padding: 8px 0 12px;
}

.mouse-svg {
  width: 300px;
  height: auto;
  max-height: 380px;
}

.mouse-body {
  fill: #1c1e3a;
  stroke: #3a3f6a;
  stroke-width: 2;
}

.mouse-divider {
  stroke: #3a3f6a;
  stroke-width: 1;
  stroke-linecap: round;
}

.mouse-btn {
  fill: #262b50;
  stroke: #3a3f6a;
  stroke-width: 1.2;
  transition: fill 0.15s, stroke 0.15s, filter 0.2s;
}

.svg-label {
  fill: #a8acc8;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  pointer-events: none;
  dominant-baseline: middle;
}

/* 按下時發光（透過 data-active 切換） */
.mouse-btn[data-active="true"] { filter: brightness(1.8); }

.mouse-btn[data-button="left"][data-active="true"]    { fill: var(--accent-left);    stroke: var(--accent-left); }
.mouse-btn[data-button="right"][data-active="true"]   { fill: var(--accent-right);   stroke: var(--accent-right); }
.mouse-btn[data-button="middle"][data-active="true"]  { fill: var(--accent-middle);  stroke: var(--accent-middle); }
.mouse-btn[data-button="forward"][data-active="true"] { fill: var(--accent-forward); stroke: var(--accent-forward); }
.mouse-btn[data-button="back"][data-active="true"]    { fill: var(--accent-back);    stroke: var(--accent-back); }
.mouse-btn[data-button="scroll"][data-active="true"]  { fill: var(--accent-scroll);  stroke: var(--accent-scroll); }

/* ---------- 進度條 ---------- */

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ok), #86efac);
  transition: width 0.3s ease;
}

/* ---------- 點擊歷史 chip ---------- */

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.history-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
}

.chip {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  font-family: 'SF Mono', 'Fira Code', Menlo, monospace;
  animation: chip-in 0.2s ease-out;
}

@keyframes chip-in {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.chip.left    { background: var(--accent-left); }
.chip.right   { background: var(--accent-right); }
.chip.middle  { background: var(--accent-middle); }
.chip.forward { background: var(--accent-forward); }
.chip.back    { background: var(--accent-back); }
.chip.scroll  { background: var(--accent-scroll); }
.chip.double  { outline: 2px solid var(--danger); outline-offset: 1px; }

/* ---------- 側欄 ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  padding: 20px 22px;
}

.button-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.button-list li {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  transition: all 0.15s;
  font-size: 0.9rem;
}

.button-list li[data-tested="true"] {
  border-color: transparent;
  background: rgba(34, 197, 94, 0.08);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.3);
}

.button-list .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
}

.button-list li[data-tested="true"] .dot { background: var(--ok); }

.button-list .label { color: var(--text); }

.button-list .count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.button-list li[data-tested="true"] .count { color: #fff; }

.badge {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 6px;
}

/* 設定面板 */
.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.setting-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-left);
  cursor: pointer;
}

/* ---------- 進階分析 ---------- */

.analytics {
  margin-bottom: 20px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.analytic-card {
  padding: 18px 20px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #d0d0e0;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.88rem;
}

.metric-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.unit {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.accent-green { color: var(--ok); }
.accent-blue  { color: var(--info); }
.accent-warn  { color: var(--warn); }
.accent-danger{ color: var(--danger); }

.slider-row {
  flex-wrap: wrap;
  gap: 8px;
}

.slider-row input[type="range"] {
  flex: 1;
  min-width: 60px;
  accent-color: var(--accent-left);
}

/* ---------- Verdict 大卡 ---------- */

.verdict-section {
  margin-bottom: 20px;
}

.verdict {
  padding: 22px 26px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.verdict h3 {
  font-size: 1.15rem;
  margin-bottom: 6px;
  font-weight: 600;
}

.verdict p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.verdict.clean {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(10, 40, 20, 0.4);
}
.verdict.clean h3 { color: var(--ok); }

.verdict.suspect {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(40, 30, 10, 0.4);
}
.verdict.suspect h3 { color: var(--warn); }

.verdict.busted {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(40, 10, 10, 0.4);
}
.verdict.busted h3 { color: var(--danger); }

/* ---------- Footer（含 rig 紅點）---------- */

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 4px 4px;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.secret-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
}

.secret-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a1a2e;
  border: 1px solid #222;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.secret-dot.on {
  background: var(--danger);
  border-color: #b91c1c;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}

/* ---------- 響應式 ---------- */

@media (max-width: 1024px) {
  .main-grid { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .app { padding: 18px 14px 30px; }
  .brand h1 { font-size: 1.3rem; }
  .subtitle { font-size: 0.78rem; }
  .analytics-grid { grid-template-columns: 1fr; }
  .test-panel { padding: 18px; min-height: 0; }
  .mouse-svg { width: 220px; }
}
