/* ══════════════════════════════════════════════════════════════════════════
   LABBIE DASHBOARD — SHARED SHELL & COMPONENT SYSTEM

   The single implementation of the Labbie dashboard chrome: design tokens,
   topbar, layout, sidebar, navigation, account menu, cards, buttons, form
   controls, empty states, the modal dialog, and the ≤720px drawer.

   Extracted VERBATIM from frontend/dashboard.html so the approved dashboard
   keeps its exact appearance: this file is linked from the same position in
   <head> that the inline <style> occupied, so cascade order is unchanged.
   It loads BEFORE /assets/glass.css, exactly as the inline block did — glass
   .css intentionally overrides parts of it with !important.

   Consumers:
     frontend/dashboard.html          the Labbie user dashboard
     coldcalling/public/index.html    Labbie AI Cold Calling

   Anything product-specific (project cards, billing plans, published sites,
   cold-calling panels) stays with its product. Only shared chrome lives here.
   ══════════════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════════════
   TOKENS, RESET, SHELL, COMPONENTS
   ══════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #ffffff;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #111827;
  --shadow: 0 1px 6px rgba(0,0,0,0.05);
  --shadow-soft: 0 1px 3px rgba(0,0,0,0.03);
  --radius-xl: 16px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --sidebar-w: 228px;
  --blue: #111827;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; }

/* ── Topbar ── */
.topbar {
  height: 48px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topbar-left { display: inline-flex; align-items: center; gap: 10px; }
/* Hamburger, drawer header, and backdrop are mobile-only — hidden on desktop. */
.topbar-menu     { display: none; }
.sidebar-header  { display: none; }
.sidebar-backdrop { display: none; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}
/* The logo URL is RELATIVE TO THIS STYLESHEET, not to the page. Served from
   /assets/ it resolves to /assets/brand/labbie-logo.png exactly as the absolute
   form did; served to a product mounted elsewhere (Labbie AI Cold Calling, at
   /coldcalling/assets/labbie/) it resolves under that mount instead of 404ing
   against a /assets/ path that host does not serve. Do not re-absolutise. */
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 0;
  display: block; background: url("brand/labbie-logo.png") center / contain no-repeat;
  box-shadow: none;
}
.brand-word { font-family: 'Geist', 'Inter', ui-sans-serif, system-ui, sans-serif; font-weight: 500; letter-spacing: -0.02em; }
.tb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 400;
  position: relative;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--token-avatar-bg, #111827);
  color: var(--token-avatar-color, #fff);
  display: grid; place-items: center;
  font-size: 0.82rem;
  font-weight: 500;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-lg {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--token-avatar-user-bg, #e5e7eb);
  color: var(--token-avatar-color, #fff);
  display: grid; place-items: center;
  font-size: 1.25rem;
  font-weight: 500;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img, .avatar-lg img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
/* When a profile picture is set, hide the blue gradient fallback and let the
   image fill a true square (grid centering can letterbox the img into an oval). */
.avatar.has-image, .avatar-lg.has-image {
  background: none;
  display: block;
  padding: 0;
}
/* Lock avatars to a perfect square so the circle never renders oval. */
.avatar, .avatar-lg { flex-shrink: 0; aspect-ratio: 1 / 1; }
.name-edit-input {
  font: inherit;
  color: var(--text, inherit);
  background: rgba(127,127,127,0.10);
  border: 1px solid rgba(127,127,127,0.35);
  border-radius: 8px;
  padding: 2px 8px;
  max-width: 220px;
  width: 220px;
}
.detail-val.editable-name { cursor: pointer; }

/* ── Layout ── */
.layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - 48px);
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  overflow-y: auto;
  gap: 2px;
}
.sidebar-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 140ms, color 140ms;
  text-decoration: none;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: rgba(0,0,0,0.03);
  color: var(--text);
}
.nav-item.active {
  background: rgba(0,0,0,0.05);
  color: var(--text);
  font-weight: 500;
}
.nav-item svg { flex-shrink: 0; }
.nav-item.logout { color: #111827; margin-top: 8px; }
.nav-item.logout:hover {
  background: rgba(0,0,0,0.03);
  color: #111827;
}
.sidebar-spacer { flex: 1; min-height: 20px; }

/* ── Main ── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 36px;
}
.page-title {
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}
.page-sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 28px;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.stat-label {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-badge {
  display: inline-block;
  margin-top: 7px;
  font-size: 0.76rem;
  font-weight: 400;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-blue  { background: var(--token-empty-icon-bg, rgba(17,24,39,0.15)); color: var(--text); }
.badge-green { background: var(--token-empty-icon-bg, rgba(17,24,39,0.12)); color: var(--text); }
.badge-amber { background: var(--token-empty-icon-bg, rgba(17,24,39,0.15)); color: var(--text); }

/* ── Section card ── */
.section-card {
  background: var(--card);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  margin-bottom: 20px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-title {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.section-link {
  font-size: 0.82rem;
  color: #374151;
  font-weight: 400;
  cursor: pointer;
}
.section-link:hover { opacity: 0.75; }

/* Profile */
.profile-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.profile-info strong { display: block; font-size: 1.02rem; font-weight: 500; }
.profile-info span { font-size: 0.88rem; color: var(--muted); }

/* Detail rows */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.detail-row:last-child { border-bottom: 0; }
.detail-key { color: var(--muted); font-weight: 500; }
.detail-val { font-weight: 400; }

/* Credit bar */
.credit-bar {
  height: 7px;
  background: var(--token-credit-bar, rgba(17,24,39,0.18));
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.credit-fill {
  height: 100%;
  background: var(--token-credit-fill, #111827);
  border-radius: 999px;
  transition: width 600ms ease;
}

/* Activity */
.activity-list { list-style: none; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.activity-item:last-child { border-bottom: 0; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--token-activity-dot, #9ca3af);
  flex-shrink: 0;
  margin-top: 4px;
}
.activity-time { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

/* Websites empty state */
.empty-state {
  text-align: center;
  padding: 36px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.empty-state svg { display: block; margin: 0 auto 12px; }
.empty-state strong { display: block; color: var(--text); margin-bottom: 6px; }

/* Buttons */
.btn-dark {
  background: var(--token-btn-action-bg, #101012);
  color: var(--token-btn-action-color, #fff);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: opacity 150ms;
  cursor: pointer;
  border: 0;
}
.btn-dark:hover { opacity: 0.85; }
.btn-ghost {
  background: var(--token-btn-ghost-bg, #f3f4f6);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 0.87rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  transition: background 140ms;
}
.btn-ghost:hover { background: var(--token-btn-ghost-hover, rgba(17,24,39,0.20)); }

/* Views */
.view { display: none; }
.view.active { display: block; }

/* ══════════════════════════════════════════════════════════════════════
   MOBILE ≤720px — SHARED SHELL (drawer, backdrop, hamburger)
   ══════════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════
   MOBILE  — ≤720px
   Sidebar becomes a slide-in drawer triggered by a
   hamburger button in the topbar. Linear/Notion-style.
   Desktop layout untouched.
   ══════════════════════════════════════════════ */
@media (max-width: 720px) {
  /* Layout: stop being a horizontal flex; let main flow vertically. */
  .layout {
    display: block;
    height: auto;
    overflow: visible;
  }

  /* Topbar: tighten padding, truncate long usernames. */
  .topbar { padding: 0 14px; }
  /* Mobile: keep only the logo mark as a home affordance; hide the wordmark. */
  .brand-word { display: none; }
  .tb-user { gap: 8px; }
  /* Bigger tap target on mobile; negative margin keeps the edge aligned.
     Scoped to .tb-user so it outranks the base rule defined later in the sheet. */
  .tb-user .tb-user-trigger { gap: 8px; padding: 6px; margin-right: -6px; }
  .tb-user #topName {
    display: none;
  }

  /* Hamburger — visible only on mobile, ≥44px tap target. */
  .topbar-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    margin-left: -6px;
    background: transparent;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    transition: background 140ms;
  }
  .topbar-menu:hover,
  .topbar-menu:focus-visible { background: #f3f4f6; outline: none; }

  /* Sidebar → off-canvas drawer, slides in from the left. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 86vw;
    height: 100vh;
    height: 100dvh;   /* track the real visible height when mobile browser bars show/hide */
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(.32,.72,.36,1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    padding-top: 18px;
    /* All other vertical-sidebar rules (flex-direction: column, labels,
       spacer, full-width nav items) cascade from the desktop styles. */
  }
  body.menu-open .sidebar { transform: translateX(0); }

  /* Drawer header — gives the open drawer an anchor; mobile only. */
  .sidebar-header {
    display: block;
    padding: 2px 12px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--line);
  }

  /* Backdrop — fades in behind the drawer, taps to close. */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10,10,12,0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms;
    z-index: 150;
  }
  body.menu-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  /* Scroll-lock the page behind the drawer. */
  body.menu-open { overflow: hidden; }

  /* Main: tighter padding, allow body to scroll the page. */
  .main {
    padding: 18px 14px 60px;
    overflow-y: visible;
  }

  /* Headlines: smaller and tighter on mobile. */
  .page-title { font-size: 1.25rem; margin-bottom: 18px; }
  .page-sub   { margin-bottom: 20px; }

  /* Stat grid: 2 columns on phones. */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
  }
  .stat-card { padding: 14px 16px; border-radius: 18px; }
  .stat-value { font-size: 1.35rem; }

  /* Section card: tighter, slightly smaller corners. */
  .section-card {
    padding: 18px 16px;
    border-radius: 22px;
    margin-bottom: 16px;
  }

  /* Profile row stacks vertically. */
  .profile-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Detail rows: allow value to wrap below key on narrow screens. */
  .detail-row {
    flex-wrap: wrap;
    gap: 8px 12px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   ACCOUNT TRIGGER + POPOVER (the user menu)
   ══════════════════════════════════════════════════════════════════════ */

/* ── Account trigger (avatar + name = one button) ── */
.tb-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border-radius: 12px;
}
.account-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(20,18,15,0.14);
  z-index: 110;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.account-popover.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.account-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background 120ms;
}
.account-popover-item:hover { background: rgba(0,0,0,0.05); }
.account-popover-item svg   { display: none; }
.account-popover-item-danger { color: #111827; }
.account-popover-item-danger:hover { background: rgba(17,24,39,0.06); }
.account-popover-sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 6px 4px;
}

/* ══════════════════════════════════════════════════════════════════════
   MODAL DIALOG
   ══════════════════════════════════════════════════════════════════════ */

/* ── Labbie modal dialog (rename / recycle-bin confirm) ── */
.wb-modal-overlay {
  position: fixed; inset: 0; z-index: 3000;
  display: none; align-items: center; justify-content: center;
  background: rgba(10,10,11,0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 20px;
}
.wb-modal-overlay.open { display: flex; }
.wb-modal {
  background: var(--card, #fff); color: var(--text, #111827);
  border: 1px solid var(--border, #e5e7eb); border-radius: 16px;
  width: 100%; max-width: 400px; padding: 22px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  animation: wb-modal-in var(--wb-dur-med, 260ms) var(--wb-ease-out, ease) both;
}
.wb-modal-title { font-size: 1.02rem; font-weight: 550; margin: 0 0 6px; }
.wb-modal-msg   { font-size: 0.88rem; color: var(--muted, #6b7280); margin: 0 0 16px; line-height: 1.5; }
.wb-modal-input {
  width: 100%; box-sizing: border-box; margin: 0 0 16px;
  padding: 10px 12px; font: inherit; font-size: 0.92rem;
  border: 1px solid var(--border, #d1d5db); border-radius: 10px;
  background: var(--bg, #fff); color: inherit; outline: none;
}
.wb-modal-input:focus { border-color: #5168e6; box-shadow: 0 0 0 3px rgba(81,104,230,0.18); }
.wb-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.wb-modal-btn {
  font: inherit; font-size: 0.88rem; font-weight: 500;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border, #d1d5db); background: transparent; color: inherit;
}
.wb-modal-btn:hover { background: rgba(0,0,0,0.045); }
.wb-modal-btn-primary { background: #111827; border-color: #111827; color: #fff; }
.wb-modal-btn-primary:hover { background: #1f2937; }
.wb-modal-btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.wb-modal-btn-danger:hover { background: #b91c1c; }
/* Change-password fields: label + masked input with show/hide eye toggle */
.wb-pass-label { display: block; font-size: 0.8rem; font-weight: 550; color: var(--muted, #6b7280); margin: 0 0 5px; }
.wb-pass-wrap { position: relative; margin: 0 0 12px; }
.wb-pass-wrap .wb-modal-input { margin: 0; padding-right: 42px; }  /* room for the eye icon */
.wb-pass-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted, #6b7280);
  cursor: pointer; border-radius: 8px; padding: 0;
  transition: color 140ms, background 140ms;
}
.wb-pass-toggle:hover { color: var(--text, #111827); background: rgba(0,0,0,0.05); }
.wb-pass-toggle svg { display: block; }
.wb-pass-err { display: none; font-size: 0.82rem; color: #dc2626; margin: 0 0 12px; }
.wb-pass-err.show { display: block; }
