/* ============================================================
   sidebar.css — 後台側邊欄（圓角版，白色側欄）
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  background: #e8eaee !important;
  display: flex !important;
  min-height: 100vh;
  padding: 12px;
  gap: 12px;
  color: #111;
}

/* ════════════════════════
   SIDEBAR — 白色左欄，圓角
════════════════════════ */
#adminSidebar {
  width: 260px;
  min-width: 260px;
  height: calc(100vh - 24px);
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 16px;           /* ← 四角都圓 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  /* 未登入時隱藏 */
  display: none;
}
#adminSidebar.sb-visible { display: flex; }

/* Brand */
.sb-brand {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  flex-shrink: 0;
  border-bottom: 1px solid #f2f2f2;
}
.sb-brand-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #f0f4ff;
  font-size: 21px;
}
.sb-brand-name {
  font-size: 13px; font-weight: 900; color: #111;
  line-height: 1.35;
}
.sb-brand-sub {
  font-size: 9px; color: #bbb;
  letter-spacing: 1.2px; text-transform: uppercase; margin-top: 2px;
}

/* Nav */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: #ebebeb transparent;
}
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: #e8e8e8; border-radius: 2px; }

/* 不顯示分組標籤 */
.sb-group-label { display: none; }

.sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: #555;
  transition: background .12s, color .12s;
  margin-bottom: 2px;
}
.sb-item:hover  { background: #f5f7fb; color: #111; }
.sb-item.sb-active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 3px 10px rgba(37,99,235,.25);
}
.sb-item[aria-disabled="true"] { opacity: .35; pointer-events: none; }

.sb-item-icon {
  width: 34px; height: 34px;
  background: #f5f7fb;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
  transition: background .12s;
}
.sb-item:hover     .sb-item-icon { background: #eef2ff; }
.sb-item.sb-active .sb-item-icon { background: rgba(255,255,255,.22); }

.sb-item-label {
  font-size: 13px; font-weight: 700;
  color: inherit; line-height: 1.3;
}
.sb-item-desc {
  font-size: 11px; color: #aaa;
  line-height: 1.3; margin-top: 1px;
}
.sb-item.sb-active .sb-item-desc  { color: rgba(255,255,255,.65); }
.sb-item.sb-active .sb-item-label { color: #fff; }

/* Footer */
.sb-footer-info {
  padding: 8px 14px 6px;
  font-size: 11px; color: #bbb;
  border-top: 1px solid #f2f2f2;
  flex-shrink: 0;
  line-height: 1.6;
}

.sb-logout {
  display: flex; align-items: center; justify-content: center;
  width: calc(100% - 20px);
  margin: 6px 10px 12px;
  padding: 10px;
  border-radius: 10px;
  background: #2563eb;
  border: none; color: #fff;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  transition: background .13s;
  flex-shrink: 0;
}
.sb-logout:hover { background: #1d4ed8; }

/* Mobile toggle */
#sbToggle {
  display: none;
  position: fixed; top: 16px; left: 16px; z-index: 200;
  width: 38px; height: 38px; border-radius: 10px;
  background: #fff; border: 1px solid #e8eaed;
  color: #333; font-size: 16px; cursor: pointer;
  align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
#sbOverlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 49;
}

/* ════════════════════════
   MAIN — 白色右欄，圓角
════════════════════════ */
#adminMain {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 24px);
  background: #fff;
  border-radius: 16px;           /* ← 四角都圓 */
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  overflow: hidden;
  /* 未登入時佔滿寬度 */
}

/* Topbar */
#adminTopbar {
  height: 56px;
  padding: 0 26px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid #f2f2f2;
}
.tb-page-title {
  font-size: 15px; font-weight: 900; color: #111; flex: 1;
}
.tb-user  { display: flex; align-items: center; gap: 9px; }
.tb-info  { text-align: right; }
.tb-name  { font-size: 13px; font-weight: 800; color: #111; }
.tb-sub   { font-size: 11px; color: #aaa; margin-top: 1px; }
.tb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 900; flex-shrink: 0;
}
.tb-online {
  width: 8px; height: 8px;
  background: #22c55e; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(34,197,94,.2);
}

/* Content */
#adminContent {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px 26px;
  background: #fff;
}

/* 取消 .wrap 佈局限制 */
#adminContent .wrap,
#adminContent .wrap.page {
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  opacity: 1 !important;
  transform: none !important;
  display: block !important;
}

/* Modals 不受限 */
.modalBack, .modal-back { z-index: 9999 !important; }
.modal { border-radius: 16px !important; }

/* ════════════════════════
   GATE（登入畫面）— 仿圖片風格
════════════════════════ */
body.gate-mode {
  padding: 0;
  background: #e8ecf0 !important;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
}
body.gate-mode #adminSidebar  { display: none !important; }
body.gate-mode #adminTopbar   { display: none !important; }
body.gate-mode #adminMain {
  flex: none;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 48px;
}
body.gate-mode #adminContent {
  width: 100%;
  max-width: 480px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
}

/* ════════════════════════
   MOBILE
════════════════════════ */
@media (max-width: 820px) {
  body { padding: 0; gap: 0; }
  #adminSidebar {
    position: fixed;
    left: -280px;
    top: 0; height: 100vh;
    border-radius: 0 16px 16px 0;
    transition: left .22s ease;
    z-index: 100;
  }
  #adminSidebar.sb-open { left: 0; }
  #sbToggle.sb-show { display: flex; }
  #sbOverlay.sb-open { display: block; }
  #adminMain  { border-radius: 0; height: 100vh; }
  #adminTopbar { padding-left: 60px; }
  #adminContent { padding: 14px; }

  body.gate-mode { padding: 16px; }
  body.gate-mode #adminMain {
    max-width: 100%; border-radius: 16px;
  }
}
