/* ══════════════════════════════════════════════════════════
   SIDEBAR + TOPBAR — shared between app-v2.html and admin/project-hq.html
   Requires CSS variables from app.css :root block.
   ══════════════════════════════════════════════════════════ */

/* ══ SIDEBAR ══ */
.sidebar { width: var(--sidebar-w); background: #1a1712; border-right: 0.5px solid rgba(240,232,215,0.07); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; z-index: 50; transition: transform var(--duration-slow) var(--ease); }
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.sidebar-logo { display: flex; align-items: center; gap: var(--space-sm); padding: 16px; border-bottom: 0.5px solid rgba(240,232,215,0.07); flex-shrink: 0; position: sticky; top: 0; z-index: 2; background: #1a1712; }
.logo-mark { width: 30px; height: 30px; background: var(--primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 900; font-size: 12px; color: var(--text-on-primary); flex-shrink: 0; box-shadow: var(--glow); }
.logo-name { font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: 15px; color: rgba(240,232,215,0.9); }

/* Context switcher */
.ctx-switcher { position: relative; padding: 8px 10px; border-bottom: 0.5px solid rgba(240,232,215,0.07); flex-shrink: 0; }
.ctx-btn { width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--primary-subtle); border: none; border-left: 3px solid var(--primary); border-radius: 8px; cursor: pointer; transition: background var(--duration) var(--ease); }
.ctx-btn:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.ctx-icon { font-size: 14px; flex-shrink: 0; }
.ctx-label { font-family: var(--font-heading); font-size: 0.82rem; font-weight: 600; color: rgba(240,232,215,0.9); flex: 1; text-align: left; }
.ctx-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.ctx-chevron { font-size: 10px; color: rgba(240,232,215,0.4); transition: transform var(--duration) var(--ease); }
.ctx-btn.open .ctx-chevron { transform: rotate(180deg); }
.ctx-dropdown { position: absolute; top: calc(100% - var(--space-xs)); left: var(--space-sm); right: var(--space-sm); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: var(--space-xs); z-index: 100; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(-6px); pointer-events: none; transition:background var(--duration) var(--ease),color var(--duration) var(--ease),border-color var(--duration) var(--ease),transform var(--duration) var(--ease); }
.ctx-dropdown.open { opacity: 1; transform: translateY(0); pointer-events: all; }
.ctx-option { display: flex; align-items: center; gap: var(--space-sm); padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--duration); border-left: 2px solid transparent; }
.ctx-option:hover { background: var(--primary-subtle); }
.ctx-option.active { border-left-color: var(--primary); background: var(--primary-subtle); }
.ctx-opt-icon { font-size: 15px; width: 20px; text-align: center; }
.ctx-opt-label { font-family: var(--font-heading); font-size: 0.82rem; font-weight: 600; color: var(--text); flex: 1; }
.ctx-opt-badge { font-family: var(--font-heading); font-size: 0.55rem; font-weight: 700; padding: 2px 6px; border-radius: 100px; }
.badge-pro { background: rgba(248,189,68,0.15); color: var(--primary); border: 1px solid rgba(248,189,68,0.25); }
.badge-free { background: var(--accent-green-soft); color: var(--accent-green); border: 1px solid rgba(136,211,117,0.2); }
.badge-admin { background: var(--accent-purple-soft); color: var(--accent-purple); border: 1px solid var(--accent-purple-soft); }

/* ── Topbar context pill (mobile only) ── */
.ctx-pill {
  display: none; /* hidden on desktop */
  align-items: center; gap: 4px;
  padding: 0 10px; height: 36px;
  background: none; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 0.75rem;
  font-family: var(--font-heading); font-weight: 600;
  cursor: pointer; flex-shrink: 0;
  transition: border-color var(--duration), color var(--duration);
}
.ctx-pill:hover { border-color: var(--primary); color: var(--text); }
.ctx-pill-icon { font-size: 14px; }
.ctx-pill-name { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-pill-chev { font-size: 10px; opacity: 0.6; transition: transform var(--duration); }
.ctx-pill.open .ctx-pill-chev { transform: rotate(180deg); }

.ctx-pill-wrap { position: relative; }
.ctx-pill-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 4px;
  min-width: 200px; z-index: 200;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.ctx-pill-menu.open { opacity: 1; transform: translateY(0); pointer-events: all; }
.ctx-pill-opt { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); border-radius: var(--radius-sm); cursor: pointer; font-size: 0.82rem; color: var(--text-muted); transition: background var(--duration); }
.ctx-pill-opt:hover { background: var(--surface-alt); }
.ctx-pill-opt.active { background: var(--primary-subtle); color: var(--text); }

@media (max-width: 1024px) {
  .ctx-pill { display: inline-flex; }
}

/* Nav */
.sidebar-nav { flex: 1; padding: var(--space-sm) 0; }
/* Nav groups — CSS-driven context visibility (instant, no flash) */
.nav-group { }
.nav-group.hidden { display: none; }
html[data-ctx="biz"] #nav-biz { display: block !important; }
html[data-ctx="biz"] #nav-personal { display: none !important; }
html[data-ctx="biz"] #nav-employer { display: none !important; }
html[data-ctx="employer"] #nav-biz { display: none !important; }
html[data-ctx="employer"] #nav-personal { display: none !important; }
html[data-ctx="employer"] #nav-employer { display: block !important; }
html[data-ctx="personal"] #nav-biz { display: none !important; }
html[data-ctx="personal"] #nav-personal { display: block !important; }
html[data-ctx="personal"] #nav-employer { display: none !important; }
.nav-section { font-family: var(--font-heading); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: rgba(240,232,215,0.45); padding: 16px 16px 6px; margin-top: 0; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px var(--space-md); font-family: var(--font-body); font-size: 0.875rem; color: rgba(240,232,215,0.7); cursor: pointer; border-left: 3px solid transparent; transition: background var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease); user-select: none; }
.nav-item:hover { color: rgba(240,232,215,0.95); background: rgba(255,255,255,0.06); border-left-color: transparent; }
.nav-item.active { color: var(--primary); background: rgba(248,189,68,0.08); border-left-color: var(--primary); border-radius: 0 8px 8px 0; font-weight: 500; }
.nav-icon { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: rgba(248,189,68,0.15); color: var(--primary); font-family: var(--font-heading); font-size: 0.58rem; font-weight: 700; padding: 2px 6px; border-radius: 100px; }
.nav-divider { height: 1px; background: var(--border); margin: var(--space-sm) var(--space-md); }

/* Employer selector in Work sidebar */
.sb-employer-select { padding: var(--space-xs, 4px) var(--space-md, 16px); }
.sb-employer-dropdown {
  width: 100%; padding: var(--space-sm, 8px) var(--space-md, 16px);
  background: var(--surface-alt, #332e25); border: 1px solid var(--border-strong, #585148);
  border-radius: var(--radius-sm, 8px); color: var(--text, #e9e1d9);
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif); font-size: 0.78rem; font-weight: 600;
  cursor: pointer; outline: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237c766f' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.sb-employer-dropdown:focus { border-color: var(--primary, #f8bd44); box-shadow: 0 0 0 2px var(--ring, rgba(248,189,68,0.3)); }
.sb-employer-name {
  padding: var(--space-sm, 8px) var(--space-md, 16px);
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif); font-size: 0.78rem; font-weight: 700;
  color: var(--text, #e9e1d9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Sidebar edit pencil */
.sb-edit-btn {
  background: none; border: none; cursor: pointer; color: var(--text-faint);
  padding: 2px 4px; border-radius: var(--radius-sm, 8px); opacity: 0.4;
  transition: opacity var(--duration, 0.18s), color var(--duration, 0.18s), background var(--duration, 0.18s);
}
.nav-section:hover .sb-edit-btn { opacity: 1; }
.sb-edit-btn:hover, .sb-edit-btn:active { color: var(--primary); background: var(--primary-subtle); opacity: 1; }

/* Sidebar editor modal items */
.sb-ed-item {
  display: flex; align-items: center; gap: var(--space-sm, 8px);
  padding: var(--space-sm, 8px) var(--space-md, 16px);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
  min-height: 44px;
}
.sb-ed-item[draggable="true"] { cursor: grab; }
.sb-ed-item[draggable="true"]:active { cursor: grabbing; }
.sb-ed-drag { color: var(--text-faint, #7c766f); font-size: 16px; width: 16px; user-select: none; }
.sb-ed-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.sb-ed-label { font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif); font-size: 0.85rem; color: var(--text, #e9e1d9); flex: 1; }
/* Toggle switch */
.sb-ed-toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; cursor: pointer; margin-left: auto; }
.sb-ed-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.sb-ed-slider {
  position: absolute; inset: 0; background: var(--border-strong, #585148);
  border-radius: 10px; transition: background var(--duration, 0.18s);
}
.sb-ed-slider::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform var(--duration, 0.18s);
}
.sb-ed-toggle input:checked + .sb-ed-slider { background: var(--primary, #f8bd44); }
.sb-ed-toggle input:checked + .sb-ed-slider::before { transform: translateX(16px); }

.sb-shop-btn {
  width: 100%; padding: var(--space-xs) var(--space-md);
  min-height: var(--touch-min);
  background: none; border: none; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-sm);
  cursor: pointer; text-align: left; border-radius: 0;
  transition: background var(--duration) var(--ease);
}
.sb-shop-btn:hover { background: var(--primary-subtle); }
.sb-shop-icon { width: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--primary); }
.sb-shop-label { font-family: var(--font-body); font-size: 0.875rem; font-weight: 600; color: var(--primary); flex: 1; }
.sb-shop-badge { font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 6px; border-radius: 100px; background: var(--accent-amber-soft); color: var(--accent-amber); flex-shrink: 0; }

.sidebar-footer {
  width: 100%; padding: var(--space-sm) var(--space-md);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border); background: #1a1712; border-left: none; border-right: none; border-bottom: none;
  display: flex; align-items: center; gap: var(--space-sm); flex-shrink: 0;
  cursor: pointer; text-align: left; border-radius: 0;
  transition: background var(--duration) var(--ease);
  position: sticky; bottom: 0; z-index: 2;
}
.sidebar-footer:hover { background: rgba(255,255,255,0.06); }
.sidebar-footer:hover .sf-arrow { color: var(--primary); }
.user-avatar { width: 32px; height: 32px; background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue)); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-heading); font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-family: var(--font-heading); font-size: 0.72rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 0.65rem; color: var(--text-faint); }
.sf-arrow { font-size: 0.9rem; color: var(--text-faint); transition: color var(--duration) var(--ease); flex-shrink: 0; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: var(--overlay); z-index: 40; backdrop-filter: blur(4px); }
.sidebar-overlay.open { display: block; }

/* ══ APP RIGHT ══ */
.app-right { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ══ 2-ROW HEADER (topbar-v2) ══ */
.topbar-v2 {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  z-index: 30;
  position: relative;
}

/* Row 1 — brand bar */
.topbar-row1 {
  height: 58px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  gap: var(--space-sm);
}

.topbar-hamburger {
  display: none;
  width: 36px; height: 36px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: border-color var(--duration), color var(--duration);
  flex-shrink: 0;
}
.topbar-hamburger:hover { border-color: var(--primary); color: var(--primary); }
/* Invisible 44px tap targets on 36px buttons */
.topbar-hamburger, .topbar-quick-add, .topbar-search-btn { position: relative; }
.topbar-hamburger::after, .topbar-quick-add::after, .topbar-search-btn::after {
  content: ''; position: absolute; inset: -4px; border-radius: 14px;
}

.topbar-brand {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  font-weight: 400;
  color: var(--primary);
  margin-right: auto;
  user-select: none;
}

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

.topbar-quick-add {
  width: 36px; height: 36px;
  background: var(--primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary-fg, #1a1712);
  transition: background var(--duration), transform var(--duration);
  flex-shrink: 0;
}
.topbar-quick-add:hover { background: var(--primary-hover); }
.topbar-quick-add:active { transform: scale(0.95); }

.topbar-search-btn {
  width: 36px; height: 36px;
  background: none;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  transition: border-color var(--duration), color var(--duration);
  flex-shrink: 0;
}
.topbar-search-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Row 2 — bottom nav */
.topbar-row2 {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 0 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  transition: color var(--duration);
  -webkit-tap-highlight-color: transparent;
}
.bnav-item svg { opacity: 0.4; transition: opacity var(--duration); }
.bnav-item:hover { color: var(--text-muted); }
.bnav-item.active { color: var(--primary); }
.bnav-item.active svg { opacity: 1; color: var(--primary); }

.bnav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.bnav-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

/* ══ Legacy topbar compat — keep .tb-btn for notification-center.js ══ */
.tb-btn { width: 40px; height: 40px; background: none; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 13px; transition:background var(--duration) var(--ease),color var(--duration) var(--ease),border-color var(--duration) var(--ease),transform var(--duration) var(--ease); position: relative; flex-shrink: 0; }
.tb-btn:hover { border-color: var(--primary); color: var(--primary); }
.notif-dot { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; background: var(--accent-red); border-radius: 50%; border: 1.5px solid var(--surface); }

/* Desktop: hide bottom nav row 2, show full desktop header */
@media (min-width: 1025px) {
  .topbar-row2 { display: none; }
  .topbar-hamburger { display: none; }
  .topbar-row1 {
    height: 54px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 0.5px solid var(--border);
  }
  /* Hide mobile-only elements on desktop (keep quick-add visible) */
  .topbar-brand { display: none; }
  .topbar-search-btn { display: none; } /* desktop has its own search icon */
}

/* Desktop header — context breadcrumb + page title + actions */
@media (min-width: 1025px) {
  .topbar-ctx-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    flex-shrink: 0;
  }
  .topbar-ctx-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
  }
  .topbar-separator {
    color: var(--text-faint);
    font-size: 16px;
    margin: 0 2px;
    flex-shrink: 0;
  }
  .topbar-page-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 22px;
    font-weight: 400;
    color: var(--text);
    flex: 1;
    min-width: 0;
  }
  .topbar-icon-btn {
    width: 36px; height: 36px;
    background: none;
    border: 0.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-faint);
    transition: border-color var(--duration), color var(--duration);
    flex-shrink: 0;
  }
  .topbar-icon-btn:hover { border-color: var(--primary); color: var(--primary); }
  .topbar-cta {
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    border-radius: 10px;
    padding: 9px 18px;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--duration);
    white-space: nowrap;
  }
  .topbar-cta:hover { background: var(--primary-hover); }
}

/* Mobile: hide desktop-only topbar elements */
@media (max-width: 1024px) {
  .topbar-ctx-badge, .topbar-separator, .topbar-page-title,
  .topbar-icon-btn, .topbar-cta { display: none; }
  /* Keep notification bell visible on mobile */
  .notif-container { display: flex !important; position: relative; }
  .notif-container .topbar-icon-btn {
    display: flex !important;
    width: 36px; height: 36px;
    background: none;
    border: 0.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    align-items: center; justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
  }
}

/* ── FAB (floating action button) — mobile only ── */
.fab { display: none; }
@media (max-width: 767px) {
  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: fixed;
    z-index: 150;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    height: 48px;
    padding: 0 20px;
    border-radius: 24px;
    border: none;
    background: var(--primary);
    color: var(--primary-fg);
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform var(--duration), box-shadow var(--duration);
    -webkit-tap-highlight-color: transparent;
  }
  .fab:active { transform: scale(0.92); box-shadow: 0 2px 8px rgba(0,0,0,0.25); }
  .fab.hidden { display: none; }
  /* Hide FAB when drawer is open */
  body.drawer-open .fab { display: none; }
  /* Hide hero action button on mobile — FAB replaces it */
  .hero-action-mobile { display: none !important; }
}

/* ── Sidebar always-dark color overrides ── */
.sidebar { color: rgba(240,232,215,0.9); }
.sidebar .user-name { color: rgba(240,232,215,0.9); }
.sidebar .user-plan { color: rgba(240,232,215,0.5); }
.sidebar .sf-arrow { color: rgba(240,232,215,0.45); }
.sidebar-footer:hover { background: rgba(255,255,255,0.04); }
.sidebar .nav-divider { background: rgba(240,232,215,0.07); }

/* ── Uniform muted icon color — all inactive nav icons match ── */
.sidebar .nav-item .nav-icon,
.sidebar .nav-item svg { color: rgba(240,232,215,0.55); fill: none; }
.sidebar .nav-item.active .nav-icon,
.sidebar .nav-item.active svg { color: var(--primary); }
