/* ============================================================
   StorHub 主控台 免登入展示 (console demo)
   設計 token 取自真實主控台 minIO/frontend/app/globals.css，
   以求外觀與實際產品一致。命名空間 sh- 避免與 style.css 衝突。
   ============================================================ */

.sh-demo {
  /* 真實主控台色票 */
  --sh-surface-0: #121211;
  --sh-surface-1: #1a1a19;
  --sh-surface-2: #242422;
  --sh-surface-3: #2e2e2b;
  --sh-border: #34342f;
  --sh-border-soft: #2a2a27;
  --sh-text: #f4f3ee;
  --sh-text-2: #c3c2b7;
  --sh-muted: #8a897e;
  --sh-accent: #3987e5;
  --sh-accent-soft: rgba(57, 135, 229, 0.14);
  --sh-good: #199e70;
  --sh-warn: #c98500;
  --sh-crit: #e66767;
  --sh-r-lg: 14px;
  --sh-r-md: 9px;
  --sh-r-sm: 7px;
  /* 環境識別色，由 data-zone 覆寫 */
  --sh-zone: #e0a23e;
  --sh-zone-soft: rgba(224, 162, 62, 0.13);

  margin-top: 1.75rem;
}

.sh-demo[data-zone="hot"]    { --sh-zone: #e0a23e; --sh-zone-soft: rgba(224, 162, 62, 0.13); }
.sh-demo[data-zone="cold"]   { --sh-zone: #7db7e8; --sh-zone-soft: rgba(125, 183, 232, 0.13); }
.sh-demo[data-zone="backup"] { --sh-zone: #3fc394; --sh-zone-soft: rgba(63, 195, 148, 0.12); }

/* ---------- 區域切換器 ---------- */
.sh-zonebar {
  display: flex;
  flex-wrap: wrap;
  /* 說明文字與膠囊「底部切齊」 */
  align-items: flex-end;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.sh-zonetabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
}

.sh-zonetab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.95rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.sh-zonetab .sh-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--swatch);
  flex: 0 0 auto;
}

.sh-zonetab:hover { color: var(--color-text); }

.sh-zonetab[aria-selected="true"] {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.sh-fineprint {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.sh-demo-note {
  /* 清掉 <p> 的瀏覽器預設 margin，否則 flex 的 align-items:center
     是以「含 margin 的邊界框」置中，文字會與膠囊對不齊 */
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

/* ---------- 裝置外框：讓它讀起來是「內嵌的 App」 ---------- */
.sh-frame {
  border-radius: var(--sh-r-lg);
  overflow: hidden;
  background: var(--sh-surface-0);
  border: 1px solid var(--sh-border);
  box-shadow: 0 18px 44px rgba(8, 12, 20, 0.28);
}

.sh-chrome {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--sh-surface-1);
  border-bottom: 1px solid var(--sh-border-soft);
}

.sh-chrome-dots { display: flex; gap: 6px; }
.sh-chrome-dots i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--sh-surface-3);
  display: block;
}

.sh-chrome-url {
  flex: 1;
  min-width: 0;
  padding: 0.25rem 0.7rem;
  background: var(--sh-surface-0);
  border: 1px solid var(--sh-border-soft);
  border-radius: var(--sh-r-sm);
  color: var(--sh-muted);
  font-size: 0.78rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sh-chrome-tag {
  flex: 0 0 auto;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--sh-zone-soft);
  color: var(--sh-zone);
  border: 1px solid color-mix(in srgb, var(--sh-zone) 35%, transparent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------- 主體版面 ---------- */
.sh-app {
  display: grid;
  position: relative;
  grid-template-columns: 208px 1fr;
  /* 固定高度 + 可壓縮列軌：grid 容器只給 max-height 時，列軌仍會依內容撐開，
     子項的 overflow 就失效。必須是確定高度，子項才會真的捲動。 */
  grid-template-rows: minmax(0, 1fr);
  height: 620px;
  color: var(--sh-text);
  font-size: 0.875rem;
}

/* ---------- 側欄 ---------- */
.sh-side {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 0.85rem;
  background: var(--sh-surface-1);
  border-right: 1px solid var(--sh-border-soft);
  min-height: 0;
  overflow-y: auto;
}

.sh-logo b { display: block; font-size: 1.05rem; letter-spacing: -0.01em; }
.sh-logo small { display: block; color: var(--sh-muted); font-size: 0.72rem; margin-top: 2px; }

.sh-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--sh-r-sm);
  background: var(--sh-zone-soft);
  border: 1px solid color-mix(in srgb, var(--sh-zone) 32%, transparent);
  color: var(--sh-zone);
  font-size: 0.78rem;
  font-weight: 600;
}
.sh-chip .sh-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sh-zone);
}

.sh-nav { display: flex; flex-direction: column; gap: 2px; }

.sh-nav button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: var(--sh-r-sm);
  background: transparent;
  color: var(--sh-text-2);
  font: inherit;
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.sh-nav button:hover { background: var(--sh-surface-2); color: var(--sh-text); }
.sh-nav button[aria-current="true"] {
  background: var(--sh-accent-soft);
  color: var(--sh-text);
  box-shadow: inset 2px 0 0 var(--sh-accent);
}
.sh-nav .sh-ico {
  width: 1.15rem;
  text-align: center;
  color: var(--sh-muted);
  font-size: 0.95rem;
}
.sh-nav button[aria-current="true"] .sh-ico { color: var(--sh-accent); }

.sh-side-foot {
  margin-top: auto;
  padding-top: 0.7rem;
  border-top: 1px solid var(--sh-border-soft);
  color: var(--sh-muted);
  font-size: 0.72rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  word-break: break-all;
}

/* ---------- 內容區 ---------- */
.sh-main {
  padding: 1.1rem 1.25rem 1.35rem;
  background: var(--sh-surface-0);
  min-width: 0;
  /* grid item 預設 min-height:auto 會撐滿內容、令 overflow-y 失效，必須歸零才會真的捲動 */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #4a4a44 var(--sh-surface-1);
}
.sh-main::-webkit-scrollbar { width: 10px; }
.sh-main::-webkit-scrollbar-track { background: var(--sh-surface-1); }
.sh-main::-webkit-scrollbar-thumb {
  background: #4a4a44;
  border: 2px solid var(--sh-surface-1);
  border-radius: 8px;
}
.sh-main::-webkit-scrollbar-thumb:hover { background: #5c5c54; }

/* 底部漸層：讓「下面還有內容」一眼看得出來，不會誤以為被切掉 */
.sh-app::after {
  content: "";
  position: absolute;
  left: 208px;
  right: 10px;
  bottom: 0;
  height: 30px;
  background: linear-gradient(to top, var(--sh-surface-0) 12%, transparent);
  pointer-events: none;
}

.sh-head { margin-bottom: 0.9rem; }
.sh-head h4 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
  color: var(--sh-text);
}
.sh-head p {
  margin: 0.25rem 0 0;
  color: var(--sh-muted);
  font-size: 0.8rem;
  line-height: 1.55;
  max-width: 62ch;
}

.sh-panel { display: none; }
.sh-panel[data-active="true"] { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .sh-panel[data-active="true"] { animation: sh-fade 0.22s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes sh-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
  }
}

/* 版本歷史：返回鍵 / 說明 / 儲存桶資訊列 */
.sh-back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.6rem;
  padding: 0.25rem 0.6rem 0.25rem 0.45rem;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-r-sm);
  background: var(--sh-surface-2);
  color: var(--sh-text-2);
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.sh-back:hover { background: var(--sh-surface-3); color: var(--sh-text); }
.sh-back:focus-visible { outline: 2px solid var(--sh-accent); outline-offset: 2px; }

.sh-hint {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.7rem;
  border-left: 2px solid var(--sh-accent);
  background: var(--sh-accent-soft);
  border-radius: 0 var(--sh-r-sm) var(--sh-r-sm) 0;
  color: var(--sh-text-2);
  font-size: 0.76rem;
  line-height: 1.6;
}

.sh-bucketbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.7rem;
  background: var(--sh-surface-1);
  border: 1px solid var(--sh-border-soft);
  border-radius: var(--sh-r-md);
}
.sh-bucket-name {
  margin-right: 0.2rem;
  color: var(--sh-muted);
  font-size: 0.78rem;
}
.sh-bucket-name b {
  color: var(--sh-text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* 區域限制說明 */
.sh-zonenote {
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.85rem;
  border-radius: var(--sh-r-md);
  background: var(--sh-zone-soft);
  border: 1px solid color-mix(in srgb, var(--sh-zone) 28%, transparent);
  color: var(--sh-text-2);
  font-size: 0.78rem;
  line-height: 1.6;
}

/* ---------- 區塊標題 ---------- */
.sh-sect { margin-bottom: 1.05rem; }
.sh-sect h5 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--sh-text-2);
  letter-spacing: 0.01em;
}
.sh-tip {
  cursor: help;
  text-decoration: underline dotted var(--sh-muted);
  text-underline-offset: 3px;
}
.sh-cardnote {
  margin: 0 0 0.5rem;
  color: var(--sh-muted);
  font-size: 0.74rem;
  line-height: 1.55;
}

/* ---------- 表格（對應真實主控台的資料表） ---------- */
.sh-tablewrap {
  border: 1px solid var(--sh-border-soft);
  border-radius: var(--sh-r-md);
  overflow-x: auto;
}
.sh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.79rem;
  background: var(--sh-surface-1);
}
.sh-table th {
  padding: 0.5rem 0.7rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.74rem;
  color: var(--sh-muted);
  background: var(--sh-surface-2);
  white-space: nowrap;
}
.sh-table td {
  padding: 0.52rem 0.7rem;
  border-top: 1px solid var(--sh-border-soft);
  color: var(--sh-text-2);
  vertical-align: middle;
  white-space: nowrap;
}
.sh-table td.sh-mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--sh-text);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 告警橫幅 ---------- */
.sh-alert {
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.9rem;
  border-radius: var(--sh-r-md);
  font-size: 0.78rem;
  line-height: 1.6;
  border: 1px solid transparent;
}
.sh-alert b { display: block; margin-bottom: 2px; }
.sh-alert.is-ok {
  background: rgba(25, 158, 112, 0.1);
  border-color: rgba(25, 158, 112, 0.32);
  color: var(--sh-text-2);
}
.sh-alert.is-ok b { color: #3fc394; }

/* ---------- 上傳區 ---------- */
.sh-drop {
  padding: 1.1rem;
  text-align: center;
  border: 1px dashed var(--sh-border);
  border-radius: var(--sh-r-md);
  background: var(--sh-surface-1);
  color: var(--sh-muted);
  font-size: 0.78rem;
}

/* ---------- 統計列 ---------- */
.sh-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.sh-stat {
  padding: 0.6rem 0.7rem;
  background: var(--sh-surface-1);
  border: 1px solid var(--sh-border-soft);
  border-radius: var(--sh-r-md);
}
.sh-stat span {
  display: block;
  color: var(--sh-muted);
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}
.sh-stat b {
  font-size: 1.15rem;
  font-weight: 650;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: -0.01em;
}
.sh-stat b.is-good { color: var(--sh-good); }
.sh-stat b.is-warn { color: var(--sh-warn); }
.sh-stat b.is-crit { color: var(--sh-crit); }

/* ---------- 資料列 ---------- */
.sh-rows {
  border: 1px solid var(--sh-border-soft);
  border-radius: var(--sh-r-md);
  overflow: hidden;
}
.sh-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 0.8rem;
  background: var(--sh-surface-1);
}
.sh-row + .sh-row { border-top: 1px solid var(--sh-border-soft); }

.sh-row .sh-key {
  min-width: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--sh-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sh-row .sh-meta {
  display: block;
  margin-top: 3px;
  color: var(--sh-muted);
  font-size: 0.72rem;
  font-family: system-ui, sans-serif;
}
.sh-row-actions { display: flex; align-items: center; gap: 0.4rem; flex: 0 0 auto; }

/* 標籤 */
.sh-tag {
  display: inline-block;
  padding: 0.13rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 650;
  border: 1px solid transparent;
  white-space: nowrap;
}
.sh-tag.is-cold { background: rgba(125, 183, 232, 0.14); color: #7db7e8; border-color: rgba(125, 183, 232, 0.34); }
.sh-tag.is-hot  { background: rgba(224, 162, 62, 0.13); color: #e0a23e; border-color: rgba(224, 162, 62, 0.32); }
.sh-tag.is-good { background: rgba(25, 158, 112, 0.14); color: #3fc394; border-color: rgba(25, 158, 112, 0.36); }
.sh-tag.is-crit { background: rgba(230, 103, 103, 0.13); color: #e66767; border-color: rgba(230, 103, 103, 0.32); }
.sh-tag.is-warnish { background: rgba(201, 133, 0, 0.14); color: #d79a2b; border-color: rgba(201, 133, 0, 0.36); }
.sh-tag.is-lock { background: var(--sh-surface-3); color: var(--sh-text-2); border-color: var(--sh-border); }

/* 動作按鈕 */
.sh-btn {
  padding: 0.32rem 0.7rem;
  border-radius: var(--sh-r-sm);
  border: 1px solid var(--sh-border);
  background: var(--sh-surface-2);
  color: var(--sh-text);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
  white-space: nowrap;
}
.sh-btn:hover { background: var(--sh-surface-3); border-color: var(--sh-accent); }
.sh-btn:active { transform: translateY(1px); }
.sh-btn.is-primary {
  background: var(--sh-accent);
  border-color: var(--sh-accent);
  color: #fff;
}
.sh-btn.is-primary:hover { background: #2f76cd; border-color: #2f76cd; }
.sh-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.sh-btn:focus-visible { outline: 2px solid var(--sh-accent); outline-offset: 2px; }

/* ---------- 監控：手刻 SVG 圖表(與真實主控台一致，不引入圖表函式庫) ---------- */
.sh-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.sh-card {
  padding: 0.75rem 0.85rem;
  background: var(--sh-surface-1);
  border: 1px solid var(--sh-border-soft);
  border-radius: var(--sh-r-md);
}
.sh-card h5 {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sh-text-2);
}
.sh-card svg {
  display: block;
  width: 100%;
  /* viewBox 為 260 寬，放任撐滿寬容器會把字級一起放大近 3 倍 */
  max-width: 460px;
  height: auto;
}

.sh-meter { margin-top: 0.55rem; }
.sh-meter-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--sh-muted);
  margin-bottom: 4px;
}
.sh-meter-track {
  height: 6px;
  border-radius: 999px;
  background: var(--sh-surface-3);
  overflow: hidden;
}
.sh-meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--sh-zone);
}

/* ---------- 操作回饋 toast ---------- */
.sh-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translate(-50%, 8px);
  max-width: min(88%, 460px);
  padding: 0.55rem 0.9rem;
  border-radius: var(--sh-r-md);
  background: var(--sh-surface-3);
  border: 1px solid var(--sh-border);
  color: var(--sh-text);
  font-size: 0.78rem;
  line-height: 1.5;
  box-shadow: 0 10px 26px rgba(8, 12, 20, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.sh-toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }
.sh-toast b { color: var(--sh-good); }

.sh-frame { position: relative; }

/* ---------- 手機版：側欄轉為水平捲動列 ---------- */
@media (max-width: 780px) {
  .sh-app { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  .sh-app::after { display: none; }
  .sh-side {
    border-right: 0;
    border-bottom: 1px solid var(--sh-border-soft);
    gap: 0.65rem;
  }
  .sh-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    scrollbar-width: none;
  }
  .sh-nav::-webkit-scrollbar { display: none; }
  .sh-nav button { width: auto; white-space: nowrap; }
  .sh-nav button[aria-current="true"] { box-shadow: inset 0 -2px 0 var(--sh-accent); }
  .sh-side-foot { display: none; }
  .sh-charts { grid-template-columns: 1fr; }
  .sh-main { padding: 0.9rem 0.85rem 1.1rem; }
  .sh-row { grid-template-columns: 1fr; align-items: start; }
  .sh-row-actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .sh-toast, .sh-btn, .sh-nav button, .sh-zonetab { transition: none; }
}

/* ---------- 表格內元件密度（避免寬表格右欄被裁切） ---------- */
.sh-table .sh-btn {
  padding: 0.24rem 0.5rem;
  font-size: 0.72rem;
}
.sh-table .sh-tag {
  font-size: 0.67rem;
  padding: 0.1rem 0.42rem;
}
.sh-table th,
.sh-table td { padding: 0.48rem 0.55rem; }
.sh-table td.sh-mono { max-width: 205px; }
