/* ============================================================
   跨客戶售價查詢系統 — 深色模式 × 商務藍
   ============================================================ */
:root {
  /* 基底 */
  --bg: #0b1220;
  --surface: #151e31;
  --surface-2: #1b2740;
  --border: #243049;
  --border-strong: #31405f;

  /* 主色（商務藍） */
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, .15);

  /* 文字 */
  --text: #e2e8f0;
  --muted: #8fa0ba;

  /* 圓角與陰影 */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 4px 18px rgba(0, 0, 0, .35);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .45);

  /* 客戶識別色 */
  --c-a: #3b82f6;
  --c-b: #10b981;
  --c-c: #f59e0b;
  --c-d: #8b5cf6;
  --c-e: #64748b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Helvetica Neue", "Noto Sans TC", "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(59, 130, 246, .12), transparent 55%),
    radial-gradient(800px 500px at -10% 100%, rgba(59, 130, 246, .07), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

::selection { background: rgba(59, 130, 246, .35); }

/* 捲軸 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3d4f75; }

/* ===== 登入頁 ===== */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: rgba(21, 30, 49, .88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px 30px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .04);
}
.login-logo {
  width: 68px; height: 68px; margin: 0 auto 18px;
  border-radius: 19px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 10px 28px rgba(59, 130, 246, .35);
}
.login-title {
  text-align: center; font-size: 21px; font-weight: 700;
  letter-spacing: .5px; margin-bottom: 6px;
}
.login-subtitle {
  text-align: center; color: var(--muted);
  font-size: 13px; margin-bottom: 26px;
}

/* 登入表單（Bootstrap 深色化） */
.login-card .form-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.login-card .form-control {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  transition: border-color .2s, box-shadow .2s;
}
.login-card .form-control:focus {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .22);
}
.login-card .input-group > .form-control { border-radius: 10px 0 0 10px; }
.login-card .btn-outline-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 0 10px 10px 0;
  padding: 0 14px;
}
.login-card .btn-outline-secondary:hover {
  background: var(--surface-2); color: var(--text); border-color: var(--border-strong);
}
.btn-login {
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border: none; color: #fff;
  font-size: 15px; font-weight: 600;
  border-radius: 10px; padding: 11px;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn-login:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 8px 24px rgba(59, 130, 246, .38);
}
.btn-login:disabled { opacity: .6; cursor: not-allowed; }

/* ===== 導覽列（毛玻璃固定） ===== */
.app-nav {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(11, 18, 32, .82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.app-nav .container { display: flex; justify-content: space-between; align-items: center; }
.app-nav-title {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--text); font-size: 17px; font-weight: 700; letter-spacing: .3px;
}
.app-nav-title svg { color: var(--primary-hover); }
.app-nav-btn {
  border: 1px solid var(--border);
  background: transparent; color: var(--muted);
  font-size: 13.5px; padding: 7px 18px; border-radius: 999px;
  cursor: pointer;
  transition: all .2s;
}
.app-nav-btn:hover { color: #fff; border-color: var(--primary); background: var(--primary-soft); }

/* ===== 搜尋列 ===== */
.search-bar {
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 8px; height: 54px; margin: 20px 0;
  transition: border-color .25s, box-shadow .25s, transform .25s;
}
.search-bar:focus-within {
  border-color: rgba(96, 165, 250, .65);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .16);
  transform: translateY(-1px);
}
.search-icon { flex-shrink: 0; color: var(--muted); }
.search-input {
  flex: 1; min-width: 0; border: none; background: none;
  font-size: 16px; padding: 0 10px; outline: none; color: var(--text);
  caret-color: var(--primary-hover);
}
.search-input::placeholder { color: #5a6b88; }
.search-bar-icon {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  border: none; background: none; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer;
  transition: color .2s, background .2s;
}
.search-bar-icon:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.search-bar-icon--blue:hover { color: var(--primary-hover); }
.search-bar-btn {
  display: flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 22px; flex-shrink: 0;
  border: none;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff; font-size: 14.5px; font-weight: 600;
  border-radius: 10px; cursor: pointer;
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.search-bar-btn:hover:not(:disabled) {
  transform: translateY(-1px); filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(59, 130, 246, .35);
}
.search-bar-btn:disabled { background: var(--surface-2); color: #5a6b88; cursor: not-allowed; }

/* ===== 結果標頭 ===== */
.result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.result-count { font-size: 13px; color: var(--muted); }
.view-toggle {
  display: flex; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px;
}
.toggle-btn {
  font-size: 13px; color: var(--muted);
  border: none; background: none;
  padding: 5px 16px; cursor: pointer;
  border-radius: 999px;
  transition: all .2s;
}
.toggle-btn.active { background: var(--primary); color: #fff; font-weight: 600; }
.toggle-btn:not(.active):hover { color: var(--text); }

/* ===== 結果動畫 ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.results-enter { animation: fadeUp .35s ease both; }

/* ===== 卡片模式 ===== */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: transform .2s, border-color .2s, box-shadow .25s;
}
.result-card:hover {
  transform: translateY(-3px);
  border-color: rgba(96, 165, 250, .45);
  box-shadow: var(--shadow-pop);
}
.result-card .card-body { padding: 16px 18px; }
.result-card .card-title { font-size: 15.5px; font-weight: 600; margin-bottom: 10px; line-height: 1.45; }
.result-card hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.price-big { font-size: 23px; font-weight: 700; color: var(--primary-hover); letter-spacing: .2px; }
.price-small { font-size: 13px; color: var(--muted); }
.meta-line { font-size: 13px; color: var(--muted); }
.detail-line { font-size: 12.5px; color: #6d7d99; }

/* 客戶識別左色條 */
.accent-a { border-left-color: var(--c-a) !important; }
.accent-b { border-left-color: var(--c-b) !important; }
.accent-c { border-left-color: var(--c-c) !important; }
.accent-d { border-left-color: var(--c-d) !important; }
.accent-e { border-left-color: var(--c-e) !important; }

/* ===== 條列模式 ===== */
.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-md);
  padding: 14px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow-card);
  transition: transform .2s, border-color .2s;
}
.list-item:hover { transform: translateX(3px); border-color: rgba(96, 165, 250, .45); }

/* ===== 徽章（半透明藥丸） ===== */
.badge {
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; letter-spacing: .3px;
  border: 1px solid transparent;
}
.badge-a {
  background: rgba(59, 130, 246, .16) !important;
  color: #7cb0fb !important; border-color: rgba(59, 130, 246, .38) !important;
}
.badge-b {
  background: rgba(16, 185, 129, .14) !important;
  color: #4ade80 !important; border-color: rgba(16, 185, 129, .36) !important;
}
.badge-c {
  background: rgba(245, 158, 11, .14) !important;
  color: #fbbf24 !important; border-color: rgba(245, 158, 11, .36) !important;
}
.badge-d {
  background: rgba(139, 92, 246, .16) !important;
  color: #a78bfa !important; border-color: rgba(139, 92, 246, .38) !important;
}
.badge-e {
  background: rgba(100, 116, 139, .18) !important;
  color: #aab8cc !important; border-color: rgba(100, 116, 139, .4) !important;
}

/* ===== 骨架載入動畫 ===== */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.sk-line {
  height: 12px; border-radius: 6px; margin-bottom: 12px;
  background: linear-gradient(90deg, #1e2a44 25%, #293a5e 50%, #1e2a44 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
.sk-line:last-child { margin-bottom: 0; }
@keyframes sk-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ===== 空狀態 ===== */
.empty-state { text-align: center; padding: 56px 16px 48px; }
.empty-state svg { color: #33436a; margin-bottom: 16px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: #5a6b88; }

/* ===== 掃描器覆蓋層 ===== */
.scanner-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 2400; padding: 1rem;
}
.scanner-card {
  width: 100%; max-width: 450px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 1.5rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
  color: var(--text); position: relative;
  animation: fadeUp .25s ease both;
}
.scanner-header {
  display: flex; justify-content: center; align-items: center;
  margin-bottom: 1rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.scanner-header h3 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.scanner-close-abs {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 10;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--muted); font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong);
  transition: all 0.2s ease;
}
.scanner-close-abs:hover { color: #fca5a5; border-color: rgba(239, 68, 68, .5); transform: scale(1.08); }
.scanner-camera-row { display: flex; justify-content: center; margin-bottom: 0.75rem; }
.scanner-camera-select {
  font-size: 0.85rem; padding: 0.4rem 0.7rem; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  outline: none; cursor: pointer; max-width: 100%;
}
.scanner-video-wrapper {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 12px; overflow: hidden; background: #000;
  border: 2px solid var(--border-strong);
}
#scanner-container {
  width: 100% !important; height: 100% !important;
  object-fit: cover !important; border-radius: 10px;
}
.scanner-laser {
  position: absolute; top: 15%; left: 5%; width: 90%; height: 3px;
  background: #ef4444; box-shadow: 0 0 10px #ef4444, 0 0 24px rgba(239, 68, 68, .5);
  z-index: 10; border-radius: 2px;
  animation: scan-laser 2.2s infinite ease-in-out;
}
@keyframes scan-laser {
  0% { top: 20%; }
  50% { top: 80%; }
  100% { top: 20%; }
}
.scanner-instructions {
  text-align: center; margin-top: 1rem; color: var(--muted); font-size: 0.9rem;
}
.scanner-error {
  text-align: center; margin-top: 0.75rem;
  color: #f87171; font-size: 0.85rem;
}
.scanner-close-bottom {
  display: block; width: 100%; margin-top: 1.25rem;
  padding: 0.8rem; border-radius: 12px; border: none;
  background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s ease;
}
.scanner-close-bottom:hover { filter: brightness(1.12); transform: scale(1.02); box-shadow: 0 6px 20px rgba(59, 130, 246, .4); }

/* ===== 提醒訊息（深色化） ===== */
.alert { border-radius: var(--radius-md); font-size: 14px; padding: 11px 15px; border: 1px solid; }
.alert-danger {
  background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .35); color: #fca5a5;
}
.alert-warning {
  background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .35); color: #fcd34d;
}
.alert-info {
  background: rgba(59, 130, 246, .1); border-color: rgba(59, 130, 246, .35); color: #93c5fd;
}
