/* ===== Unified Navigation System for _WWW_dynamic ===== */
:root {
  --nav-h: 52px;
  --nav-footer-h: 56px;
  --nav-sidebar-w: 240px;
  --nav-primary: #4f46e5;
  --nav-primary-light: #6366f1;
  --nav-bg: #ffffff;
  --nav-border: #e2e8f0;
  --nav-text: #334155;
  --nav-text-light: #64748b;
  --nav-hover: #f1f5f9;
  --nav-active: #eef2ff;
  --nav-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Reset body padding for nav */
body.has-unified-nav {
  padding-top: var(--nav-h) !important;
  padding-bottom: var(--nav-footer-h) !important;
}
/* Compatibility: full-height layouts should account for header+footer */
body.has-unified-nav .h-screen,
body.has-unified-nav [style*="height:100vh"],
body.has-unified-nav [style*="height: 100vh"] {
  height: calc(100vh - 108px) !important;
}
body.has-unified-nav .min-h-screen {
  min-height: calc(100vh - 108px) !important;
}

/* ===== Header ===== */
.unified-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
  background: #0a0a0a !important;
  background-image: none !important;
  border-bottom: 1px solid #2a2a2a;
  box-shadow: var(--nav-shadow); z-index: 9998;
  display: flex; align-items: center; padding: 0 12px; gap: 8px;
  color: #e2e8f0 !important;
}
.unified-header * {
  background-image: none !important;
}
.unified-header .nav-menu-btn {
  width: 36px; height: 36px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; color: #cbd5e1 !important;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.unified-header .nav-menu-btn:hover { background: rgba(255,255,255,.1); color: #ffffff !important; }
.unified-header .nav-logo {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  color: #ffffff !important; flex-shrink: 0;
}
.unified-header .nav-logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--nav-primary), #7c3aed) !important;
  display: flex; align-items: center; justify-content: center;
  color: #fff !important; font-weight: 900; font-size: 14px;
}
.unified-header .nav-logo-text {
  font-weight: 700; font-size: 14px; color: #ffffff !important;
  line-height: 1.2;
}
.unified-header .nav-logo-text small {
  display: block; font-size: 10px; font-weight: 400; color: #94a3b8 !important;
}

/* Breadcrumb */
.unified-breadcrumb {
  display: flex; align-items: center; gap: 6px; font-size: 13px;
  color: #cbd5e1 !important;
  background: transparent !important;
  background-image: none !important;
  overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; flex: 1; min-width: 0;
}
.unified-breadcrumb a {
  color: #cbd5e1 !important; text-decoration: none;
  transition: color .15s;
}
.unified-breadcrumb a:hover { color: #818cf8 !important; }
.unified-breadcrumb .bc-sep { color: #64748b !important; font-size: 11px; }
.unified-breadcrumb .bc-current {
  color: #ffffff !important; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis;
}

/* Header right actions */
.unified-header-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.nav-dropdown { position: relative; }
.nav-dropdown-btn {
  height: 36px; padding: 0 10px; border: none; background: transparent !important;
  background-image: none !important;
  border-radius: 8px; cursor: pointer; color: #cbd5e1 !important;
  display: flex; align-items: center; gap: 6px; font-size: 13px;
  font-weight: 500; transition: all .15s;
}
.nav-dropdown-btn:hover { background: rgba(255,255,255,.1) !important; color: #ffffff !important; }
.nav-dropdown-btn i { font-size: 12px; }
.nav-dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: #fff; border: 1px solid var(--nav-border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
  min-width: 220px; max-height: 400px; overflow-y: auto;
  z-index: 9999; display: none; padding: 6px;
}
.nav-dropdown-menu.show { display: block; animation: navFadeIn .15s ease; }
.nav-dropdown-menu .dd-group-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: #94a3b8; padding: 6px 10px 4px; letter-spacing: .05em;
}
.nav-dropdown-menu a, .nav-dropdown-menu .dd-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: 6px; font-size: 13px; color: var(--nav-text);
  text-decoration: none; cursor: pointer; transition: background .12s;
}
.nav-dropdown-menu a:hover, .nav-dropdown-menu .dd-item:hover {
  background: var(--nav-hover);
}
.nav-dropdown-menu a i, .nav-dropdown-menu .dd-item i {
  width: 16px; text-align: center; font-size: 12px; color: var(--nav-text-light);
}
.nav-dropdown-menu .dd-divider {
  height: 1px; background: var(--nav-border); margin: 4px 0;
}
.nav-dropdown-menu .dd-badge {
  margin-left: auto; font-size: 10px; background: var(--nav-active);
  color: var(--nav-primary); padding: 1px 6px; border-radius: 10px;
  font-weight: 600;
}

/* Search in header */
.nav-search-box {
  position: relative; display: flex; align-items: center;
}
.nav-search-box input {
  width: 0; padding: 0; border: none; background: transparent;
  transition: all .25s; font-size: 13px; outline: none;
}
.nav-search-box.open input {
  width: 180px; padding: 7px 10px 7px 32px;
  background: rgba(255,255,255,.1); border-radius: 8px;
  border: 1px solid #444; color: #fff;
}
.nav-search-box .search-icon {
  position: absolute; left: 10px; color: #94a3b8;
  font-size: 13px; pointer-events: none; opacity: 0; transition: opacity .2s;
}
.nav-search-box.open .search-icon { opacity: 1; }
.nav-search-results {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: #fff; border: 1px solid var(--nav-border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
  width: 280px; max-height: 320px; overflow-y: auto;
  z-index: 9999; display: none; padding: 6px;
}
.nav-search-results.show { display: block; }

/* ===== Sidebar ===== */
.unified-sidebar {
  position: fixed; top: var(--nav-h); left: 0; bottom: var(--nav-footer-h);
  width: var(--nav-sidebar-w); background: #f8fafc;
  border-right: 1px solid var(--nav-border); z-index: 9997;
  overflow-y: auto; transform: translateX(-100%);
  transition: transform .25s ease;
}
.unified-sidebar.open { transform: translateX(0); }
.unified-sidebar .sidebar-inner { padding: 12px 8px; }
.unified-sidebar .sidebar-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: #94a3b8; padding: 10px 10px 6px; letter-spacing: .06em;
}
.unified-sidebar .sidebar-site {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; transition: all .12s;
  text-decoration: none; color: var(--nav-text);
}
.unified-sidebar .sidebar-site:hover { background: var(--nav-hover); }
.unified-sidebar .sidebar-site.active {
  background: var(--nav-active); color: var(--nav-primary);
}
.unified-sidebar .sidebar-site-icon {
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px;
}
.unified-sidebar .sidebar-site-info { flex: 1; min-width: 0; }
.unified-sidebar .sidebar-site-name {
  font-size: 13px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.unified-sidebar .sidebar-site-pages {
  font-size: 10px; color: #94a3b8; margin-top: 1px;
}
.unified-sidebar .sidebar-site .chev {
  font-size: 10px; color: #cbd5e1; transition: transform .2s;
}
.unified-sidebar .sidebar-site.expanded .chev { transform: rotate(90deg); }
.unified-sidebar .sidebar-pages {
  display: none; padding: 4px 0 4px 20px; margin: 2px 0;
  border-left: 2px solid #e2e8f0; margin-left: 24px;
}
.unified-sidebar .sidebar-site.expanded + .sidebar-pages { display: block; }
.unified-sidebar .sidebar-page-link {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 6px; font-size: 12px; color: var(--nav-text-light);
  text-decoration: none; transition: all .12s;
}
.unified-sidebar .sidebar-page-link:hover {
  background: var(--nav-hover); color: var(--nav-text);
}
.unified-sidebar .sidebar-page-link.active {
  color: var(--nav-primary); font-weight: 600; background: var(--nav-active);
}
.unified-sidebar .sidebar-page-link i { font-size: 10px; width: 12px; text-align: center; }

/* Sidebar overlay for mobile */
.unified-sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 9996; display: none;
}
.unified-sidebar-overlay.show { display: block; }

/* ===== Footer ===== */
.unified-footer {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-footer-h);
  background: #0a0a0a; border-top: 1px solid #2a2a2a;
  z-index: 9998; display: flex; align-items: center;
  padding: 4px 16px; gap: 16px; font-size: 11px; color: #94a3b8;
}
.unified-footer .footer-left {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  flex: 1; min-width: 0; overflow: hidden;
}
.unified-footer .footer-line1,
.unified-footer .footer-line2 {
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.unified-footer .footer-line2 { font-size: 10px; color: #64748b; }
.unified-footer .footer-left span { display: flex; align-items: center; gap: 4px; }
.unified-footer .footer-right {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.unified-footer a {
  color: #cbd5e1; text-decoration: none;
  transition: color .15s; display: flex; align-items: center; gap: 4px;
}
.unified-footer a:hover { color: #818cf8; }
.unified-footer .footer-dot { width: 3px; height: 3px; border-radius: 50%; background: #444; }

/* ===== Animations ===== */
@keyframes navFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .unified-header .nav-logo-text { display: none; }
  .unified-breadcrumb { font-size: 12px; }
  .nav-dropdown-btn span { display: none; }
  .nav-search-box.open input { width: 140px; color: #fff; }
  body.has-unified-nav.nav-sidebar-open { padding-left: 0 !important; }
  .unified-sidebar { width: 260px; }
  .unified-footer .footer-left .footer-hide-mobile { display: none; }
}

/* Scrollbar for sidebar */
.unified-sidebar::-webkit-scrollbar { width: 5px; }
.unified-sidebar::-webkit-scrollbar-track { background: transparent; }
.unified-sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ===== Hot Sites Grid ===== */
.sidebar-hot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 12px 12px;
}
.sidebar-hot-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--nav-text);
  font-size: 11px;
  text-align: center;
  transition: background .15s;
}
.sidebar-hot-item:hover { background: var(--nav-hover); }
.sidebar-hot-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
}

/* ===== Related Sites ===== */
.sidebar-related-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin: 0 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--nav-text);
  font-size: 12px;
  transition: background .15s;
}
.sidebar-related-link:hover { background: var(--nav-active); color: var(--nav-primary); }

/* ===== Footer hot links ===== */
.footer-hot-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.footer-hot-links a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  transition: color .15s, background .15s;
}
.footer-hot-links a:hover { color: #818cf8; background: rgba(255,255,255,.08); }

/* ===== Language Switch Button ===== */
.lang-switch-btn {
  display: flex !important;
  align-items: center;
  gap: 4px;
  padding: 6px 12px !important;
  border-radius: 6px;
  font-size: 0.8rem !important;
  font-weight: 600;
  transition: all 0.2s;
}
.lang-switch-btn:hover {
  background: rgba(99,102,241,0.25) !important;
  color: #a5b4fc !important;
}
.lang-switch-btn span {
  font-size: 0.75rem;
}
[data-lang="en"] .lang-switch-btn span { font-size: 0.8rem; }

/* ===== Single Line Logo (欣矩陣 ∞ 欣媒體 舒安境空間) ===== */
.nav-logo-single {
  white-space: nowrap !important;
  font-size: 0.85rem !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  display: flex !important;
  align-items: center !important;
  gap: 2px !important;
}
.nav-logo-single small {
  display: none !important;
}

/* 手機版品牌名縮小 */
@media (max-width: 768px) {
  .nav-logo-single {
    font-size: 0.7rem !important;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}


/* ===== Force Header/Footer Text White on Black ===== */
.unified-header,
.unified-header a,
.unified-header span,
.unified-header div,
.unified-header button,
.unified-header input,
.unified-header .nav-logo-text,
.unified-header .unified-breadcrumb,
.unified-header .unified-breadcrumb a,
.unified-header .unified-breadcrumb .bc-current,
.unified-header .nav-dropdown-btn,
.unified-header .lang-switch-btn,
.unified-footer,
.unified-footer a,
.unified-footer span,
.unified-footer div,
.unified-footer .footer-line1,
.unified-footer .footer-line2,
.unified-footer .footer-hot-sites,
.unified-footer .footer-hot-sites a {
  color: #ffffff !important;
}

/* header 背景黑色 */
.unified-header {
  background: #0a0a0a !important;
  border-bottom: 1px solid #2a2a2a !important;
}

/* footer 背景黑色 */
.unified-footer {
  background: #0a0a0a !important;
  border-top: 1px solid #2a2a2a !important;
}

/* 麵包屑分隔符顏色 */
.unified-header .bc-sep {
  color: #6b7280 !important;
}

/* 下拉按鈕 hover 保持白色文字 */
.unified-header .nav-dropdown-btn:hover,
.unified-header .lang-switch-btn:hover {
  color: #ffffff !important;
  background: rgba(255,255,255,.1) !important;
}

/* 搜尋框文字白色 */
.unified-header #navSearchInput {
  color: #ffffff !important;
}
.unified-header #navSearchInput::placeholder {
  color: #9ca3af !important;
}


/* ===== Red Girl Avatar (張書欣) ===== */
.girl-avatar {
  color: #ef4444 !important;
  background: #fee2e2 !important;
  border-radius: 50% !important;
  padding: 3px 5px !important;
  margin-right: 2px !important;
  font-size: 0.75rem !important;
  display: inline-block !important;
}

/* ===== All Links Hover: Red Bold Underline ===== */
a,
.unified-header a,
.unified-footer a,
.unified-sidebar a,
.portal-card a,
.site-hero a,
body a {
  text-decoration: none !important;
  transition: all 0.2s ease !important;
}

a:hover,
.unified-header a:hover,
.unified-footer a:hover,
.unified-sidebar a:hover,
.portal-card a:hover,
.site-hero a:hover,
body a:hover {
  text-decoration: underline !important;
  text-decoration-color: #ef4444 !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  text-decoration-skip-ink: none !important;
}

/* 按鈕類連結不顯示底線 */
.hero-btn:hover,
.nav-dropdown-btn:hover,
.lang-switch-btn:hover,
.nav-menu-btn:hover,
button:hover {
  text-decoration: none !important;
}


/* ===== Sitemap 側邊欄強化樣式 ===== */
.unified-sidebar .sidebar-sitemap-header {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  border-radius: 10px;
  padding: 14px 12px;
  margin-bottom: 14px;
  color: #fff;
}
.unified-sidebar .sidebar-sitemap-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.unified-sidebar .sidebar-sitemap-title i {
  color: #fbbf24;
}
.unified-sidebar .sidebar-sitemap-stats {
  font-size: 11px;
  opacity: 0.95;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.unified-sidebar .sidebar-sitemap-stats .sidebar-dot {
  opacity: 0.5;
}
.unified-sidebar .sidebar-sitemap-actions {
  display: flex;
  gap: 6px;
}
.unified-sidebar .sidebar-btn-expand,
.unified-sidebar .sidebar-btn-collapse {
  flex: 1;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.unified-sidebar .sidebar-btn-expand {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.unified-sidebar .sidebar-btn-expand:hover {
  background: rgba(255,255,255,0.4);
}
.unified-sidebar .sidebar-btn-collapse {
  background: rgba(0,0,0,0.15);
  color: #fff;
}
.unified-sidebar .sidebar-btn-collapse:hover {
  background: rgba(0,0,0,0.25);
}

/* 分類標題 */
.unified-sidebar .sidebar-category-title {
  font-size: 11px;
  font-weight: 700;
  color: #6366f1;
  padding: 8px 10px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.unified-sidebar .sidebar-category-count {
  background: #e0e7ff;
  color: #4f46e5;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

/* 側邊欄底部 */
.unified-sidebar .sidebar-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}
.unified-sidebar .sidebar-portal-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff !important;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none !important;
  transition: all 0.2s;
}
.unified-sidebar .sidebar-portal-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

/* 側邊欄滾動條美化 */
.unified-sidebar::-webkit-scrollbar {
  width: 5px;
}
.unified-sidebar::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.unified-sidebar::-webkit-scrollbar-thumb {
  background: #c7d2fe;
  border-radius: 3px;
}
.unified-sidebar::-webkit-scrollbar-thumb:hover {
  background: #a5b4fc;
}
