/* ============================================================
   ui-polish.css — 狐の交易機器人平台 UI/UX 打磨層（2026-07-05）
   疊在 styles.css 之後載入，只覆蓋、不取代；拿掉此檔即回復原樣。
   依 ui-ux-pro-max / web-design-guidelines 優先序：
   無障礙 → 觸控 → 一致性 → 排版 → 微互動
   ============================================================ */

/* ---------- 1. 主題一致性：清除舊藍色主題殘留，統一金色語彙 ---------- */
input:focus, select:focus, textarea:focus {
  border-color: rgba(94, 106, 210, .75) !important;
  box-shadow: 0 0 0 4px rgba(94, 106, 210, .14) !important;
  outline: none;
}
.toast {
  border-color: rgba(94, 106, 210, .45);
  background: linear-gradient(180deg, rgba(22, 24, 32, .97), rgba(14, 15, 20, .97));
}
th, td { color: var(--text); }
th {
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ---------- 2. 無障礙：鍵盤 focus 可見環（滑鼠點擊不干擾） ---------- */
:focus-visible {
  outline: 2px solid var(--gold, #5E6AD2) !important;
  outline-offset: 2px;
  border-radius: 6px;
}
button:focus:not(:focus-visible) { outline: none; }

/* 文字選取與捲軸配色跟主題走 */
::selection { background: rgba(94, 106, 210, .30); }
* { scrollbar-width: thin; scrollbar-color: rgba(94,106,210,.35) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: rgba(94, 106, 210, .28);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: rgba(94, 106, 210, .5); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- 3. 觸控目標：至少 44px 高（Apple HIG / MD） ---------- */
.nav button { min-height: 44px; padding: 12px 16px; }
button, .btn { min-height: 40px; }
.modal-actions button { min-height: 44px; padding-inline: 18px; }
input, select { min-height: 42px; }

/* ---------- 4. 微互動：150–260ms、有意義的回饋 ---------- */
button {
  transition: transform .16s ease, box-shadow .2s ease,
              background .2s ease, border-color .2s ease, opacity .2s ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0) scale(.985); }
button:disabled { opacity: .45; cursor: not-allowed; }

.nav button { position: relative; }
.nav button.active::before {
  content: "";
  position: absolute; left: 0; top: 22%;
  height: 56%; width: 3px; border-radius: 3px;
  background: linear-gradient(180deg, var(--gold, #5E6AD2), rgba(94,106,210,.35));
}

/* 表格列 hover：掃視大量單子時的視覺定位 */
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(94, 106, 210, .055); }

/* 表頭黏住，長表捲動不迷路 */
.table-wrap { max-height: 62vh; overflow: auto; }
.table-wrap thead th {
  position: sticky; top: 0; z-index: 2;
  background: rgba(15, 17, 23, .92);
  backdrop-filter: blur(6px);
}

/* 數字欄位等寬數字：金額/價格對齊 */
td { font-variant-numeric: tabular-nums; }

/* ---------- 5. 排版節奏 ---------- */
body { line-height: 1.55; }
.panel h3 { letter-spacing: .01em; }
.muted { color: var(--muted); }

/* modal 聚焦感：背景更暗一點 + 模糊 */
.modal-backdrop.open {
  background: rgba(4, 5, 8, .66);
  backdrop-filter: blur(7px);
}

/* 入場動畫略收斂（原 .6s 偏拖） */
.panel { animation-duration: .38s; }
.sidebar { animation-duration: .32s; }

/* ---------- 6. 尊重使用者動效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 7. 小螢幕基本可用性（側欄改為頂欄） ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: static; width: 100%; height: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 14px 16px;
  }
  .nav { display: flex; flex-wrap: wrap; gap: 6px; }
  .nav button { flex: 1 1 auto; text-align: center; min-height: 44px; }
  .table-wrap { max-height: none; }
  .modal { border-radius: 18px; padding: 16px; }
}
