/* Olit Neubrex V4 共用樣式：極簡灰階（版面、按鈕、表單、表格）＋清爽藍（通知、狀態標籤）
   覆蓋 Bootstrap 3 的元件外觀，頁面沿用原本的 Bootstrap class 即可套上。 */
:root {
  --bg: #fafafa; --surface: #fff; --text: #18181b; --muted: #71717a; --faint: #a1a1aa;
  --line: #f0f0f2; --border: #e4e4e7; --border-strong: #d4d4d8; --hover: #f4f4f5;
  --accent: #18181b; --accent-hover: #3f3f46; --ring: rgba(24, 24, 27, .10);
  --accent-fg: #fff; --link: #2563eb; --link-hover: #1d4ed8;
  --ok: #10b981; --warn: #f59e0b; --fail: #ef4444; --info: #3b82f6;
  /* 淡色底的通知 / 標籤：-bg 底色、-fg 文字 */
  --ok-bg: #ecfdf5; --ok-fg: #065f46; --warn-bg: #fffbeb; --warn-fg: #92400e;
  --fail-bg: #fef2f2; --fail-fg: #991b1b; --info-bg: #eff6ff; --info-fg: #1e40af;
  --neutral-bg: #f4f4f5; --neutral-fg: #52525b;
  --danger-text: #dc2626; --success-text: #059669;
  --shadow: rgba(16, 24, 40, .12);
  --r: 8px; --r-sm: 6px;
  --nav-h: 56px;
  color-scheme: light;
}
/* 深色模式（theme.js 設定 <html data-theme="dark">） */
:root[data-theme="dark"] {
  --bg: #09090b; --surface: #18181b; --text: #f4f4f5; --muted: #a1a1aa; --faint: #71717a;
  --line: #232327; --border: #2e2e33; --border-strong: #3f3f46; --hover: #27272a;
  --accent: #fafafa; --accent-hover: #d4d4d8; --ring: rgba(250, 250, 250, .16);
  --accent-fg: #18181b; --link: #60a5fa; --link-hover: #93c5fd;
  --ok-bg: rgba(16, 185, 129, .14); --ok-fg: #6ee7b7; --warn-bg: rgba(245, 158, 11, .14); --warn-fg: #fcd34d;
  --fail-bg: rgba(239, 68, 68, .15); --fail-fg: #fca5a5; --info-bg: rgba(59, 130, 246, .16); --info-fg: #93c5fd;
  --neutral-bg: #27272a; --neutral-fg: #d4d4d8;
  --danger-text: #f87171; --success-text: #34d399;
  --shadow: rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- 基礎 ---------- */
html, body, button, input, select, textarea {
  font-family: 'Segoe UI', 'Microsoft JhengHei', '微軟正黑體', sans-serif;
}
body { background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--link); }
a:hover, a:focus { color: var(--link-hover); }
h3, h4 { font-weight: 600; color: var(--text); }
h4 { font-size: 15px; }
h3 small, h4 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
hr { border-top-color: var(--line); }
code { color: var(--text); background: var(--hover); border-radius: 4px; padding: 1px 5px; }
pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text); }
.text-muted, .muted, .hint { color: var(--muted) !important; }
.hint { font-size: 12px; }
.text-danger { color: var(--danger-text); }
.text-success { color: var(--success-text); }
.text-primary { color: var(--text); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* ---------- 頂部導覽 ---------- */
.olit-nav {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  min-height: var(--nav-h); padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.olit-nav .brand {
  display: flex; align-items: center; gap: 8px; margin-right: 24px;
  font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap;
}
.olit-nav .item {
  position: relative; display: flex; align-items: center; gap: 8px; height: var(--nav-h); padding: 0 14px;
  color: var(--muted); text-decoration: none; white-space: nowrap; transition: color .15s, background .15s;
}
.olit-nav .item:hover { color: var(--text); text-decoration: none; }
.olit-nav .item.on { color: var(--text); font-weight: 600; }

/* 目前頁面 / 分頁的底線：從中間往兩邊展開 */
.olit-nav .item::after, .nav-tabs > li > a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform .25s ease-out;
}
.olit-nav .item.on::after, .nav-tabs > li.active > a::after { transform: scaleX(1); animation: olit-underline .3s ease-out; }
@keyframes olit-underline { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* 點擊後不留框；鍵盤切換焦點時以底色提示 */
.olit-nav .item:focus, .nav-tabs > li > a:focus { outline: none; color: var(--text); }
.olit-nav .item:focus-visible, .nav-tabs > li > a:focus-visible { background: var(--hover) !important; }
.olit-nav .right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
@media (max-width: 760px) {
  .olit-nav { padding: 8px 16px; }
  .olit-nav .brand { width: 100%; margin: 0 0 4px; }
  .olit-nav .item { height: 36px; padding: 0 10px; }
  .olit-nav .right { width: 100%; margin: 4px 0; }
}

/* ---------- 版面 ---------- */
.olit-page { max-width: 1300px; margin: 0 auto; padding: 24px 24px 60px; }
.olit-page.narrow { max-width: 1100px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .right { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 10px; }
@media (max-width: 760px) { .olit-page { padding: 16px 16px 40px; } }

/* 卡片與區塊 */
.card, .box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.card { padding: 16px 18px; }
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-top: 8px; word-break: break-all; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.box { margin-bottom: 16px; overflow: hidden; }
.box > h4 {
  margin: 0; padding: 12px 18px; font-size: 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.box > h4 .right { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted); }
.box > .body { padding: 16px 18px; }
.box > .table, .box > .table-responsive > .table, .box > table { margin-bottom: 0; }

/* ---------- 按鈕 ---------- */
.btn {
  border-radius: var(--r-sm); font-weight: 500; box-shadow: none !important;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:focus, .btn:active:focus, .btn.active:focus { outline: none; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--ring) !important; }
.btn-xs { border-radius: 5px; padding: 2px 8px; }
.btn-default { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open > .dropdown-toggle.btn-default {
  background: var(--hover); border-color: var(--border-strong); color: var(--text);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover, .btn-success:focus, .btn-success:active { background: #059669; border-color: #059669; color: #fff; }
.btn-danger { background: var(--surface); border-color: #fecaca; color: #dc2626; }
.btn-danger:hover, .btn-danger:focus, .btn-danger:active { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.btn-warning { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-warning:hover, .btn-warning:focus, .btn-warning:active { background: #d97706; border-color: #d97706; color: #fff; }
.btn-info { background: var(--info); border-color: var(--info); color: #fff; }
.btn[disabled], .btn.disabled { opacity: .45; }
.btn-default[disabled], .btn-default.disabled, .btn-default[disabled]:hover, .btn-default.disabled:hover {
  background: var(--surface); border-color: var(--border-strong);
}
.btn-primary[disabled], .btn-primary.disabled, .btn-primary[disabled]:hover, .btn-primary.disabled:hover {
  background: var(--accent); border-color: var(--accent);
}

/* ---------- 表單 ---------- */
.form-control {
  border-radius: var(--r-sm); border-color: var(--border-strong); box-shadow: none; color: var(--text);
  background-color: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.form-control[readonly] { background: var(--bg); }
.form-control[disabled] { background: var(--hover); }
.form-horizontal .control-label { font-weight: 500; color: var(--muted); font-size: 13px; }
label { font-weight: 500; }
.checkbox label, .checkbox-inline, .radio label, .radio-inline { font-weight: 400; color: var(--text); }
.input-sm { border-radius: 5px; }

/* 開關 */
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; margin: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border-strong); border-radius: 999px; transition: .2s; }
.toggle-slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle-switch input:checked + .toggle-slider { background: var(--ok); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ---------- 分頁 ---------- */
.nav-tabs { border-bottom: 1px solid var(--border); }
.nav-tabs > li { margin-bottom: -1px; }
.nav-tabs > li > a {
  position: relative; border: 0 !important; border-radius: 0; margin-right: 0; padding: 10px 16px;
  color: var(--muted); background: transparent !important; transition: color .15s, background .15s;
}
.nav-tabs > li > a:hover { color: var(--text); }
.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
  color: var(--text); font-weight: 600;
}

/* ---------- 表格 ---------- */
.table { color: var(--text); }
.table > thead > tr > th {
  border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap;
}
.table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > thead > tr > td { border-top-color: var(--line); }
.table > thead:first-child > tr:first-child > th { border-top: 0; }
.box .table > thead > tr > th:first-child, .box .table > tbody > tr > td:first-child { padding-left: 18px; }
.box .table > thead > tr > th:last-child, .box .table > tbody > tr > td:last-child { padding-right: 18px; }
.table-condensed > thead > tr > th, .table-condensed > tbody > tr > td { padding: 8px 10px; }
.table-hover > tbody > tr:hover > td { background: var(--bg); }
.table > tbody > tr.info > td { background: var(--info-bg); }

/* ---------- 面板 / 對話框 ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: none; }
.panel-default > .panel-heading {
  background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border);
  border-radius: var(--r) var(--r) 0 0; font-weight: 600;
}
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.15); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-weight: 600; }
.modal-backdrop.in { opacity: .35; }

/* ---------- 通知（清爽藍風格：淡色底） ---------- */
.alert {
  border: 0; border-radius: 12px; padding: 12px 16px;
}
.alert ul { padding-left: 20px; }
.alert-warning { background: var(--warn-bg); color: var(--warn-fg); }
.alert-danger  { background: var(--fail-bg); color: var(--fail-fg); }
.alert-success { background: var(--ok-bg); color: var(--ok-fg); }
.alert-info    { background: var(--info-bg); color: var(--info-fg); }
.alert .btn { margin-left: 6px; }
.toast-msg {
  position: fixed; right: 20px; bottom: 20px; z-index: 99999; min-width: 260px; max-width: 520px;
  white-space: pre-wrap; box-shadow: 0 8px 24px var(--shadow); margin: 0;
}

/* 狀態標籤（清爽藍風格：淡色膠囊） */
.label, .badge {
  display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; line-height: 1.4;
}
.label-default, .badge { background: var(--hover); color: #52525b; }
.label-primary { background: #e4e4e7; color: var(--text); }
.label-success, .badge-ok   { background: #dcfce7; color: #15803d; }
.label-warning, .badge-warn { background: #fef3c7; color: #b45309; }
.label-danger,  .badge-fail { background: #fee2e2; color: #b91c1c; }
.label-info { background: #dbeafe; color: #1d4ed8; }

/* 狀態圓點 */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--faint); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.fail { background: var(--fail); }

/* ---------- 深色模式：Bootstrap 3 寫死淺色的元件 ---------- */
[data-theme="dark"] .btn-danger { border-color: rgba(239, 68, 68, .45); color: #f87171; }
[data-theme="dark"] .btn-danger:hover, [data-theme="dark"] .btn-danger:focus, [data-theme="dark"] .btn-danger:active {
  background: rgba(239, 68, 68, .14); border-color: rgba(239, 68, 68, .7); color: #fca5a5;
}
[data-theme="dark"] .label-default, [data-theme="dark"] .badge { background: var(--neutral-bg); color: var(--neutral-fg); }
[data-theme="dark"] .label-primary { background: #3f3f46; color: var(--text); }
[data-theme="dark"] .label-success, [data-theme="dark"] .badge-ok   { background: var(--ok-bg); color: var(--ok-fg); }
[data-theme="dark"] .label-warning, [data-theme="dark"] .badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
[data-theme="dark"] .label-danger,  [data-theme="dark"] .badge-fail { background: var(--fail-bg); color: var(--fail-fg); }
[data-theme="dark"] .label-info { background: var(--info-bg); color: var(--info-fg); }
[data-theme="dark"] .close { color: var(--text); text-shadow: none; }
[data-theme="dark"] .modal-backdrop.in { opacity: .6; }
[data-theme="dark"] .modal-content { box-shadow: 0 20px 50px rgba(0, 0, 0, .6); }
[data-theme="dark"] .dropdown-menu { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .dropdown-menu > li > a { color: var(--text); }
[data-theme="dark"] .dropdown-menu > li > a:hover { background: var(--hover); color: var(--text); }
[data-theme="dark"] .input-group-addon { background: var(--hover); border-color: var(--border-strong); color: var(--muted); }
[data-theme="dark"] .table-bordered, [data-theme="dark"] .table-bordered > thead > tr > th,
[data-theme="dark"] .table-bordered > tbody > tr > td { border-color: var(--border); }
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) { background: rgba(255, 255, 255, .02); }
[data-theme="dark"] .pager li > a, [data-theme="dark"] .pager li > span { background: var(--surface); border-color: var(--border); }

/* ---------- 深色模式切換按鈕：太陽 ⇄ 月亮 ---------- */
.theme-toggle {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--text); cursor: pointer; outline: none;
  transition: background .2s, border-color .2s, color .2s, transform .15s;
}
.theme-toggle:hover { background: var(--hover); border-color: var(--border-strong); }
.theme-toggle:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.theme-toggle:active { transform: scale(.88); }
.theme-toggle svg { overflow: visible; transition: transform .6s cubic-bezier(.34, 1.56, .64, 1); }
.theme-toggle .sun-core { transition: r .5s cubic-bezier(.34, 1.56, .64, 1); }
.theme-toggle .moon-cut { transition: transform .5s cubic-bezier(.65, 0, .35, 1); }
.theme-toggle .sun-rays { transform-origin: 12px 12px; transition: transform .5s cubic-bezier(.34, 1.56, .64, 1), opacity .3s; }
/* 切換時整個圖示轉一圈，最後月亮保持直立（開口朝右） */
[data-theme="dark"] .theme-toggle svg { transform: rotate(360deg); }
[data-theme="dark"] .theme-toggle .sun-core { r: 9px; }
[data-theme="dark"] .theme-toggle .moon-cut { transform: translate(-7px, 7px); }
[data-theme="dark"] .theme-toggle .sun-rays { transform: rotate(-90deg) scale(.4); opacity: 0; }
/* 按下時往外擴散的光圈 */
.theme-toggle::after {
  content: ""; position: absolute; inset: -1px; border-radius: 50%; pointer-events: none;
  border: 2px solid var(--text); opacity: 0;
}
.theme-toggle.pop::after { animation: olit-theme-ring .6s ease-out; }
@keyframes olit-theme-ring { from { transform: scale(1); opacity: .45; } to { transform: scale(1.9); opacity: 0; } }

/* 整頁切換：theme.js 用 View Transitions 從按鈕以圓形擴散，這裡關掉預設的交叉淡化 */
.theme-vt::view-transition-old(root), .theme-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.theme-vt::view-transition-old(root) { z-index: 1; }
.theme-vt::view-transition-new(root) { z-index: 2; }
/* 不支援 View Transitions 的瀏覽器：新底色的圓從按鈕擴散到全螢幕後再換主題 */
.theme-reveal { position: fixed; inset: 0; z-index: 100000; pointer-events: none; }
