/* ============================================================
   My Passive Income — Hub Shell (theme_hub.css)
   5-hub redesign per design_proposal.html:
   · Desktop ≥ 992px: fixed left sidebar
   · Mobile  < 992px: bottom tab bar + FAB
   · Dark-mode ready via CSS custom properties + data-bs-theme
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --hub-bg:            #f0f4f8;
  --hub-surface:       #ffffff;
  --hub-surface-2:     #f6f8fb;
  --hub-border:        #e3e8ef;
  --hub-text:          #1f2733;
  --hub-text-muted:    #6b7280;
  --hub-accent:        #0e7490;
  --hub-accent-soft:   rgba(14, 116, 144, 0.12);
  --hub-danger:        #dc2626;
  --hub-warning:       #d97706;
  --hub-success:       #15803d;
  --hub-appbar-bg:     #0f172a;
  --hub-appbar-text:   #ffffff;
  --hub-nav-bg:        #ffffff;
  --hub-nav-border:    #e5e7eb;
  --hub-shadow:        0 1px 4px rgba(0, 0, 0, 0.07);
  --hub-shadow-lg:     0 8px 18px rgba(14, 116, 144, 0.45);
  --hub-sidebar-w:     236px;
  --hub-bottomnav-h:   62px;
  --hub-ease:          0.18s ease;
}

html[data-bs-theme="dark"] {
  --hub-bg:            #0f172a;
  --hub-surface:       #1e293b;
  --hub-surface-2:     #172033;
  --hub-border:        #2a3548;
  --hub-text:          #e2e8f0;
  --hub-text-muted:    #94a3b8;
  --hub-accent:        #22d3ee;
  --hub-accent-soft:   rgba(34, 211, 238, 0.14);
  --hub-appbar-bg:     #0b1120;
  --hub-nav-bg:        #111a2c;
  --hub-nav-border:    #2a3548;
  --hub-shadow:        0 1px 4px rgba(0, 0, 0, 0.45);
}

body.pb-hub {
  background: var(--hub-bg);
  color: var(--hub-text);
  padding-bottom: 0;
}

/* ── Top app bar ───────────────────────────────────────────── */
.hub-appbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.9rem;
  background: var(--hub-appbar-bg);
  color: var(--hub-appbar-text);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}
.hub-appbar .hub-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--hub-appbar-text);
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.hub-brand-icon {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #2962ff 0%, #0dcaf0 100%);
  color: #fff; font-size: 0.95rem; flex-shrink: 0;
}
.hub-appbar-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
.hub-appbar-title {
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-appbar-greeting {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f8fafc;
  margin-bottom: 0.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.hub-appbar-greeting::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22d3ee 0%, #60a5fa 100%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}
.hub-appbar .hub-appbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.hub-appbar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  color: rgba(255, 255, 255, 0.85);
  background: transparent; border: 0;
  font-size: 1.05rem; text-decoration: none;
  transition: background var(--hub-ease);
}
.hub-appbar-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.hub-stale-badge {
  font-size: 0.66rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28) 0%, rgba(251, 191, 36, 0.14) 100%);
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 2rem;
  padding: 0.17rem 0.62rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.hub-stale-tagline {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #fef3c7;
}

.hub-stale-date {
  font-weight: 600;
  color: #fff;
  background: rgba(17, 24, 39, 0.32);
  border-radius: 999px;
  padding: 0.03rem 0.4rem;
}

.hub-nav-mode-wrap .form-select {
  min-width: 130px;
  height: 28px;
  padding-top: 0.1rem;
  padding-bottom: 0.1rem;
  font-size: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #e2e8f0;
  background-color: rgba(255, 255, 255, 0.08);
}
.hub-nav-mode-wrap .form-select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 0.15rem rgba(96, 165, 250, 0.25);
}

/* ── Desktop top-navbar mode (dropdown menu bar) ───────────── */
.hub-topnav {
  display: none;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.42rem 0.8rem;
  border-bottom: 1px solid var(--hub-nav-border);
  background: var(--hub-nav-bg);
  position: sticky;
  top: 56px;
  z-index: 1025;
}
.hub-top-link,
.hub-top-dd {
  border: 1px solid transparent;
  background: transparent;
  color: var(--hub-text);
  border-radius: 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.36rem 0.62rem;
  text-decoration: none;
}
.hub-top-dd { line-height: 1; }
.hub-top-link:hover,
.hub-top-dd:hover,
.hub-top-link.active,
.hub-top-dd.active {
  color: var(--hub-accent);
  background: var(--hub-accent-soft);
  border-color: color-mix(in srgb, var(--hub-accent) 28%, transparent);
}

/* ── Desktop sidebar ───────────────────────────────────────── */
.hub-sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: var(--hub-sidebar-w);
  background:
    radial-gradient(120% 56% at 8% 0%, var(--hub-accent-soft) 0%, transparent 60%),
    var(--hub-nav-bg);
  border-right: 1px solid var(--hub-nav-border);
  overflow-y: auto;
  padding: 0.75rem 0.6rem 1.25rem;
  z-index: 1020;
  display: none;
  backdrop-filter: saturate(120%) blur(4px);
}
.hub-sidebar::-webkit-scrollbar { width: 8px; }
.hub-sidebar::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--hub-text-muted) 35%, transparent);
  border-radius: 999px;
}
.hub-sidebar::-webkit-scrollbar-track { background: transparent; }
.hub-side-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.7rem;
  color: var(--hub-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 3px;
  border: 1px solid transparent;
  transition: background var(--hub-ease), color var(--hub-ease), transform var(--hub-ease), box-shadow var(--hub-ease), border-color var(--hub-ease);
}
.hub-side-link i {
  font-size: 1.02rem;
  width: 26px;
  height: 26px;
  border-radius: 0.55rem;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--hub-accent-soft) 60%, transparent);
  color: var(--hub-accent);
  transition: transform var(--hub-ease), background var(--hub-ease), color var(--hub-ease);
}
.hub-side-link:hover {
  background: var(--hub-surface-2);
  color: var(--hub-accent);
  border-color: color-mix(in srgb, var(--hub-accent) 22%, transparent);
  transform: translateX(2px);
}
.hub-side-link:hover i {
  transform: scale(1.06);
}
.hub-side-link.active {
  background: var(--hub-accent-soft);
  color: var(--hub-accent);
  border-color: color-mix(in srgb, var(--hub-accent) 34%, transparent);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--hub-accent) 18%, transparent);
  position: relative;
}
.hub-side-link.active::before {
  content: '';
  position: absolute;
  left: -0.35rem;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 3px;
  border-radius: 3px;
  background: var(--hub-accent);
}
.hub-side-sub {
  margin: 0.05rem 0 0.55rem 2.35rem;
  padding-left: 0.55rem;
  border-left: 1px dashed color-mix(in srgb, var(--hub-text-muted) 28%, transparent);
  display: flex;
  flex-direction: column;
}
.hub-side-sub a {
  display: block;
  padding: 0.32rem 0.58rem;
  border-radius: 0.45rem;
  font-size: 0.82rem;
  color: var(--hub-text-muted);
  text-decoration: none;
  transition: background var(--hub-ease), color var(--hub-ease), transform var(--hub-ease);
}
.hub-side-sub a:hover {
  color: var(--hub-accent);
  background: var(--hub-surface-2);
  transform: translateX(2px);
}
.hub-side-sub a.active { color: var(--hub-accent); font-weight: 600; background: var(--hub-accent-soft); }
.hub-side-divider {
  border-top: 1px solid var(--hub-nav-border);
  margin: 0.6rem 0.4rem;
}

/* ── Mobile sub-nav chips (per-hub secondary navigation) ───── */
.hub-chipbar {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.55rem 0.9rem;
  background: var(--hub-nav-bg);
  border-bottom: 1px solid var(--hub-nav-border);
  position: sticky;
  top: 56px;
  z-index: 1015;
}
.hub-chipbar::-webkit-scrollbar { display: none; }
.hub-chipbar a {
  flex-shrink: 0;
  padding: 0.28rem 0.8rem;
  border-radius: 2rem;
  border: 1px solid var(--hub-border);
  background: var(--hub-surface);
  color: var(--hub-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--hub-ease);
}
.hub-chipbar a.active,
.hub-chipbar a:hover {
  background: var(--hub-accent);
  border-color: var(--hub-accent);
  color: #fff;
}

/* ── Main content area ─────────────────────────────────────── */
.hub-main {
  padding: 1rem 5% calc(var(--hub-bottomnav-h) + 84px);
  min-height: calc(100vh - 56px);
}

/* ── Mobile bottom tab bar ─────────────────────────────────── */
.hub-bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  display: flex;
  height: calc(var(--hub-bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--hub-nav-bg);
  border-top: 1px solid var(--hub-nav-border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}
.hub-bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--hub-text-muted);
  text-decoration: none;
  transition: color var(--hub-ease);
}
.hub-bottomnav a i { font-size: 1.25rem; line-height: 1; }
.hub-bottomnav a.active { color: var(--hub-accent); }
.hub-bottomnav a.active i { transform: translateY(-1px); }

/* ── Floating action button + quick-add sheet ──────────────── */
.hub-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--hub-bottomnav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--hub-accent);
  color: #fff;
  font-size: 1.5rem;
  z-index: 1035;
  box-shadow: var(--hub-shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--hub-ease);
}
.hub-fab:active { transform: scale(0.92); }
.hub-fab.open { transform: rotate(45deg); }
.hub-quickadd {
  position: fixed;
  right: 16px;
  bottom: calc(var(--hub-bottomnav-h) + env(safe-area-inset-bottom, 0px) + 78px);
  z-index: 1035;
  display: none;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-end;
}
.hub-quickadd.open { display: flex; }
.hub-quickadd a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--hub-surface);
  color: var(--hub-text);
  border: 1px solid var(--hub-border);
  border-radius: 2rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--hub-shadow);
  white-space: nowrap;
}
.hub-quickadd a i { color: var(--hub-accent); }
.hub-quickadd a:hover { background: var(--hub-accent-soft); }

/* ── Action cards (Today feed) ─────────────────────────────── */
.hub-card {
  background: var(--hub-surface);
  border: 1px solid var(--hub-border);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
  box-shadow: var(--hub-shadow);
}
.hub-card.act-danger  { border-left: 4px solid var(--hub-danger); }
.hub-card.act-warning { border-left: 4px solid var(--hub-warning); }
.hub-card.act-success { border-left: 4px solid var(--hub-success); }
.hub-card.act-primary { border-left: 4px solid var(--hub-accent); }
.hub-card.act-muted   { border-left: 4px solid var(--hub-border); }
.hub-card .hub-card-title { font-weight: 700; font-size: 0.95rem; }
.hub-card .hub-card-detail { color: var(--hub-text-muted); font-size: 0.82rem; }
.hub-card .hub-card-actions { margin-top: 0.5rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.hub-card .hub-card-actions .btn { font-size: 0.75rem; padding: 0.2rem 0.7rem; }

.hub-zero-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--hub-text-muted);
}
.hub-zero-state .hub-zero-icon { font-size: 3rem; color: var(--hub-success); }

.hub-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--hub-text-muted);
  margin: 1rem 0.15rem 0.5rem;
}

/* ── More hub grouped list ─────────────────────────────────── */
.hub-list-group {
  background: var(--hub-surface);
  border: 1px solid var(--hub-border);
  border-radius: 0.85rem;
  overflow: hidden;
  margin-bottom: 1rem;
}
.hub-list-group a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  color: var(--hub-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--hub-border);
  transition: background var(--hub-ease);
}
.hub-list-group a:last-child { border-bottom: 0; }
.hub-list-group a:hover { background: var(--hub-surface-2); }
.hub-list-group a i:first-child { color: var(--hub-accent); width: 22px; text-align: center; }
.hub-list-group a .bi-chevron-right { margin-left: auto; color: var(--hub-text-muted); font-size: 0.8rem; }

/* ── Desktop layout ────────────────────────────────────────── */
@media (min-width: 992px) {
  .hub-sidebar { display: block; }
  .hub-bottomnav, .hub-chipbar { display: none; }
  .hub-topnav { display: none; }
  .hub-main {
    margin-left: var(--hub-sidebar-w);
    padding: 1.25rem 5% 3rem;   /* 5% gutters → content uses ~90% of the area */
    min-height: calc(100vh - 56px);
  }
  /* Collapsible sidebar — toggled via appbar button, persisted per browser */
  body.hub-side-collapsed .hub-sidebar { display: none; }
  body.hub-side-collapsed .hub-main { margin-left: 0; }

  /* Top-navbar mode: hide sidebar and show dropdown navbar */
  body.hub-nav-top .hub-sidebar { display: none; }
  body.hub-nav-top .hub-topnav { display: flex; }
  body.hub-nav-top .hub-main { margin-left: 0; }
  body.hub-nav-top #hubSideToggle { display: none !important; }

  .hub-fab { bottom: 28px; right: 28px; }
  .hub-quickadd { bottom: 96px; right: 28px; }
}

/* Dark-mode: soften legacy white cards/tables */
html[data-bs-theme="dark"] body.pb-hub .card,
html[data-bs-theme="dark"] body.pb-hub .table {
  --bs-card-bg: var(--hub-surface);
}

@media print {
  .hub-appbar, .hub-sidebar, .hub-topnav, .hub-bottomnav, .hub-chipbar, .hub-fab, .hub-quickadd { display: none !important; }
  .hub-main { margin-left: 0; padding: 0; }
}
