/* shell.css — 歲玥靜好 康復之家 交班系統
 * 殼框架：topbar、tab bar（手機）、sidebar（桌機）
 */

/* ═══════════════════════════════════
   基礎重設
   ═══════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 查詢頁按鈕位移修復：直向捲軸出現/消失時版寬 1280↔1265 造成等寬 flex tabs（.seg-tabs）全部重算位置。
 * 固定保留捲軸溝槽寬度，四維切換 tab 位置零位移（全域 base 層，非單頁修）。 */
html {
  scrollbar-gutter: stable;
}

html, body {
  height: 100%;
  font-family: var(--font-primary);
  background: var(--bg-sidebar);
  color: var(--text-primary);
  line-height: var(--line-normal);
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font-primary); }

/* ═══════════════════════════════════
   TOPBAR（手機/桌機共用頂條）
   iOS safe-area：頂部劉海/狀態列避讓
   ═══════════════════════════════════ */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  background: #0c2a3b;            /* 極光暗底（青藍）*/
  overflow: hidden;
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top);
  padding-left: max(var(--space-md), env(safe-area-inset-left));
  padding-right: max(var(--space-md), env(safe-area-inset-right));
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-md);
}
/* 極光（青藍）：淡淡流動的彩色光暈，16s 慢速、不刺眼、不耗電；尊重減少動態偏好 */
#topbar::before {
  content: '';
  position: absolute;
  inset: -60%;
  z-index: 0;
  filter: blur(26px);
  opacity: 0.9;
  background:
    radial-gradient(38% 60% at 16% 30%, #22a8b0 0, transparent 60%),
    radial-gradient(40% 64% at 72% 22%, #3a86c0 0, transparent 60%),
    radial-gradient(46% 70% at 46% 88%, #5fd0c9 0, transparent 60%),
    radial-gradient(40% 60% at 88% 70%, #2f6f9c 0, transparent 60%);
  animation: hvAurora 16s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes hvAurora {
  0%   { transform: translate(-4%, -3%) scale(1.05) rotate(-1.5deg); }
  100% { transform: translate(4%, 4%) scale(1.16) rotate(1.5deg); }
}
@media (prefers-reduced-motion: reduce) { #topbar::before { animation: none; } }
#topbar > * { position: relative; z-index: 1; }

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
}

.topbar-user {
  font-size: var(--font-caption);
  opacity: 0.92;
}

.topbar-bell {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-on-accent);
  font-size: 20px;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-bell:hover {
  background: rgba(255, 255, 255, 0.15);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* 桌機模式隱藏 topbar title，改顯示 sidebar logo */
@media (min-width: 1024px) {
  #topbar {
    left: calc(var(--sidebar-w) + env(safe-area-inset-left));
  }
}

/* ═══════════════════════════════════
   TAB BADGE（鈴鐺紅點）
   ═══════════════════════════════════ */
.tab-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  background: var(--bad);
  color: white;
  border-radius: var(--radius-pill);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

/* ═══════════════════════════════════
   手機 TAB BAR（< 1024px）
   iOS safe-area：底部 home indicator 避讓
   ═══════════════════════════════════ */
#tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-bar-h) + env(safe-area-inset-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  padding-top: 6px;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  z-index: var(--z-tab);
  box-shadow: 0 -2px 8px rgba(15, 20, 22, 0.06);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 2px;
  position: relative;
  border: none;
  background: none;
  font-family: var(--font-primary);
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.tab-icon {
  font-size: 20px;
  line-height: 1;
  display: block;
}

.tab-label {
  font-size: 10px;
  line-height: 1;
}

/* Active 狀態 */
.tab-item.active {
  color: var(--brand-primary);
}

.tab-item.active .tab-icon {
  font-weight: 700;
}

.tab-item.active .tab-label {
  font-weight: 700;
}

/* Active 上方漸層線 */
.tab-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 0 0 2px 2px;
}

/* ── 中央「主頁」大圓（W1-06；2026-07-12 codex 拍板：58px 圓、欄高約 70px）──
   圓形底座上浮突出 bar 頂緣，label 貼圓下方；active 線不套用中央鈕。
   W2-05：-14px 時 label 底緣落在 bar 內容盒外（62px bar − border 1 − padding-top 6 ＝ 55px
   內容高；圓 58 + gap 2 + label 10 自 -14 起算底緣達 56）→ 貼底被 viewport 裁半。
   上移至 -18px：label 42..52 完整入盒（3px 餘裕），圓頂多突出 4px 仍符上浮造型。 */
.tab-item.tab-center {
  padding-top: 0;
  padding-bottom: 0;          /* 底 padding 歸零，避免內容高再被推擠 */
  margin-top: -18px;          /* 58px 圓 + label ≈ 70px 欄高，上浮突出 bar */
  gap: 2px;
}

.tab-center-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(14, 155, 142, 0.35);
  border: 3px solid var(--bg-card);
  box-sizing: border-box;
}

.tab-center-circle .tab-icon svg {
  width: 26px;
  height: 26px;
  display: block;
}

.tab-item.tab-center .tab-label {
  color: var(--text-secondary);
}

.tab-item.tab-center.active .tab-label {
  color: var(--brand-primary);
  font-weight: 700;
}

.tab-item.tab-center.active::before {
  display: none;              /* 中央鈕不畫頂緣 active 線，圓本身即高亮 */
}

.tab-item.tab-center.active .tab-center-circle {
  box-shadow: 0 3px 14px rgba(14, 155, 142, 0.55);
}

/* 桌機隱藏 tab bar */
@media (min-width: 1024px) {
  #tab-bar {
    display: none;
  }
}

/* ═══════════════════════════════════
   桌機 SIDEBAR（>= 1024px）
   ═══════════════════════════════════ */
#sidebar {
  display: none;
}

@media (min-width: 1024px) {
  #sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--brand-gradient);
    color: var(--text-on-accent);
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
  /* 極光特效 — 桌機 sidebar 專屬，慢速旋轉的多色 gradient + blur */
  #sidebar::before {
    content: '';
    position: absolute;
    top: -30%; left: -30%; right: -30%; bottom: -30%;
    background:
      radial-gradient(ellipse 60% 40% at 20% 20%, rgba(46,182,165,0.55), transparent 60%),
      radial-gradient(ellipse 55% 35% at 80% 30%, rgba(201,168,90,0.35), transparent 65%),
      radial-gradient(ellipse 70% 45% at 30% 80%, rgba(47,111,156,0.50), transparent 70%),
      radial-gradient(ellipse 50% 40% at 70% 70%, rgba(0,180,150,0.45), transparent 60%);
    filter: blur(40px);
    animation: aurora-drift 18s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
  }
  #sidebar > * { position: relative; z-index: 1; }
  #sidebar .sidebar-nav { overflow-y: auto; }
}

@keyframes aurora-drift {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1); }
  33%  { transform: translate(8%, -6%) rotate(40deg) scale(1.1); }
  66%  { transform: translate(-6%, 8%) rotate(-30deg) scale(1.05); }
  100% { transform: translate(4%, 4%) rotate(20deg) scale(1.08); }
}

.sidebar-logo {
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.sidebar-logo-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin-bottom: 8px;
  display: block;
}

.sidebar-logo-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.4;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.85);
  border: none;
  background: none;
  font-family: var(--font-primary);
  width: 100%;
  text-align: left;
  position: relative;
  transition: background var(--dur-fast);
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-nav-item.active {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-weight: 700;
}

.sidebar-nav-item.locked {
  opacity: 0.55;
  font-size: 12px;
}

/* 佔位項（如專案追蹤）：頁面未建，灰階不可互動，區別於一般 hover/active 態 */
.sidebar-nav-item.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.sidebar-nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav-item .lock-icon {
  margin-left: auto;
  font-size: 12px;
  opacity: 0.65;
}

/* 專案追蹤等 nav 項的逾期數量紅點（TRACK-PROJECTS-SPEC；sidebar.js flagGate 項專用）*/
.sidebar-nav-item .sidebar-nav-badge {
  margin-left: auto;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 6px 8px;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 11px;
  opacity: 0.88;
  line-height: 1.5;
}

/* ═══════════════════════════════════
   MAIN CONTENT AREA
   iOS safe-area：頂部/底部對齊 topbar/tab-bar 高度
   ═══════════════════════════════════ */
#main {
  padding-top: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--tab-bar-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
  background: var(--bg-sidebar);
}

@media (min-width: 1024px) {
  #main {
    margin-left: var(--sidebar-w);
    padding-bottom: var(--space-xl);
  }
}

.page-content {
  padding: var(--space-md);
  max-width: 1200px;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .page-content {
    padding: var(--space-lg);
  }
}

/* ═══════════════════════════════════
   ADD-TO-HOME 橫幅引導
   ═══════════════════════════════════ */
#add-home-banner {
  background: linear-gradient(135deg, rgba(31, 127, 159, 0.08), rgba(47, 111, 156, 0.08));
  border: 1px solid var(--brand-primary);
  border-radius: var(--radius-md);
  padding: 12px var(--space-md);
  margin: var(--space-md);
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  font-size: var(--font-caption);
}

.add-home-text {
  flex: 1;
  color: var(--text-primary);
}

.add-home-link {
  color: var(--brand-primary);
  font-weight: 600;
  font-size: var(--font-micro);
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid var(--brand-primary);
  border-radius: var(--radius-sm);
}

.add-home-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
  flex-shrink: 0;
}
