/* ════════════════════════════════════════════════════════════════════════
   APP CHROME — shared sidebar plan-card + page-header divider + domain
   dropdown. INBOX-206 / 207 (2026-05-09).

   IMPORTANT — specificity escalation:
   This file uses `!important` on the page-header divider rule because
   most pages declare their own `.page-header { margin-bottom: 16/24px; }`
   inline in <style>, which loads BEFORE this file and wins by document
   order at equal specificity. We need the divider + spacing to be
   identical on every page; !important here is intentional, not lazy.
   ═════════════════════════════════════════════════════════════════════ */

/* ─── PLAN CARD ─────────────────────────────────────────────────────── */
.app-plan-card {
  /* Sit at the bottom of the sidebar with consistent breathing room.
     Different sidebars have padding 16-24px; using 16px on left/right
     keeps the card aligned with nav items above. */
  margin: auto 16px 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-sizing: border-box;
}
.app-plan-card .app-plan-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.app-plan-card .app-plan-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}
.app-plan-card .app-plan-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-bottom: 10px;
  overflow: hidden;
}
.app-plan-card .app-plan-bar-fill {
  height: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: width 200ms ease;
  width: 0%;
}
.app-plan-card.is-free .app-plan-bar-fill {
  background: #ca8a04;
}
html[data-theme="dark"] .app-plan-card.is-free .app-plan-bar-fill {
  background: #f59e0b;
}
.app-plan-card .app-plan-link {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}
.app-plan-card .app-plan-link:hover { text-decoration: underline; }
.app-plan-card .app-plan-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ─── PAGE HEADER DIVIDER ──────────────────────────────────────────── */
/* !important needed — every per-page <style> sets its own
   margin-bottom and loads after this file in document order. */
.page-header,
.pm-page-header,
.dom-page-header,
.app-page-header {
  border-bottom: 1px solid var(--border) !important;
  padding-bottom: 20px !important;
  margin-bottom: 28px !important;
}

/* ─── UNIFIED DOMAIN DROPDOWN ──────────────────────────────────────── */
/* The "pill with chevron" pattern from Blacklist Monitor — adopt as
   the canonical app-wide domain picker. Apply via class to existing
   markup; native <select> elements on Postmaster/Microsoft will be
   converted in a follow-up commit (requires JS rewire). */
.app-domain-select {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: var(--bg, var(--surface));
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all 100ms ease;
  font-family: inherit;
  user-select: none;
}
.app-domain-select:hover {
  border-color: var(--text);
  background: var(--surface, var(--bg));
}
.app-domain-select-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00875a;
  flex-shrink: 0;
}
html[data-theme="dark"] .app-domain-select-dot { background: #26d978; }
.app-domain-select-name {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.app-domain-select-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Custom div-dropdown override — apply the same pill styling to the
   legacy class names (.domain-select, .bl-domain-select, .al-domain-select)
   without requiring page edits. Same shape as .app-domain-select. */
.domain-select,
.bl-domain-select,
.al-domain-select {
  border-radius: 999px !important;
  padding: 7px 14px !important;
  border: 1px solid var(--border) !important;
}
.domain-select:hover,
.bl-domain-select:hover,
.al-domain-select:hover {
  border-color: var(--text) !important;
}

/* Native <select> override — matches the custom .app-domain-select look.
   Targets the existing `.eh-select` class on Postmaster/Microsoft so we
   don't have to rewire their JS. Strips browser default chrome and
   draws our own chevron via background-image. */
select.eh-select,
select.app-domain-select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  display: inline-flex;
  align-items: center;
  padding: 7px 36px 7px 14px !important;
  background: var(--bg, var(--surface)) !important;
  border: 1px solid var(--border) !important;
  border-radius: 999px !important;
  cursor: pointer;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  font-family: inherit !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  transition: all 100ms ease;
  min-height: 32px;
}
select.eh-select:hover,
select.app-domain-select:hover {
  border-color: var(--text) !important;
}
select.eh-select:focus,
select.app-domain-select:focus {
  outline: none;
  border-color: var(--text) !important;
}


/* ─── INBOX-218: Canonical domain-select component ──────────────────
   Migrated from dashboard-page.css so every app page has access to
   the same component (previously dashboard-only). The pattern is:

       <div class="domain-select" onclick="...toggle...">
         <span class="domain-select-dot"></span>
         <div style="flex:1;...">
           <div id="..-selected-domain">domain.com</div>
         </div>
         <span class="domain-select-arrow">▾</span>
         <div class="domain-dropdown" id="...">
           <div class="domain-dropdown-item">domain1.com</div>
           ...
         </div>
       </div>

   See static/js/app-domain-select.js for the JS helper that wires
   render/toggle/select for any page using this markup.
   ────────────────────────────────────────────────────────────────── */
.domain-select {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  background: var(--bg-1, var(--surface)); border: 1px solid var(--border-strong, var(--border));
  border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--fg, var(--text));
  cursor: pointer; position: relative;
  transition: border-color 100ms ease;
  font-family: inherit;
}
.domain-select:hover { border-color: var(--fg, var(--text)); }
.domain-select-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success, #00875a);
  flex-shrink: 0;
}
html[data-theme="dark"] .domain-select-dot { background: #26d978; }
.domain-select-meta { font-size: 11px; color: var(--fg-3, var(--text-muted)); font-family: 'Geist Mono', ui-monospace, monospace; }
.domain-select-arrow {
  color: var(--fg-3, var(--text-muted));
  display: inline-flex; align-items: center;
  margin-left: 4px;
}
.domain-dropdown {
  display: none; position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-1, var(--surface)); border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-dropdown, 0 4px 12px rgba(0,0,0,0.08));
  z-index: 50; max-height: 320px; overflow-y: auto;
  min-width: 220px;
}
.domain-dropdown.open { display: block; }
.domain-dropdown-item {
  padding: 10px 14px; font-size: 13px; color: var(--fg, var(--text));
  cursor: pointer; border-bottom: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.domain-dropdown-item:last-child { border-bottom: none; }
.domain-dropdown-item:hover { background: var(--bg-2, var(--surface-2)); }
.domain-dropdown-item.selected {
  background: var(--bg-2, var(--surface-2));
  color: var(--fg, var(--text));
  font-weight: 500;
}


/* ─── INBOX-219: CANONICAL SIDEBAR ──────────────────────────────────
   Migrated from dashboard-page.css's .sidebar / .brand / .sidebar-nav /
   .sidebar-footer rules. The Dashboard look is now the source of truth
   for every page. Three things were INTENTIONALLY left out vs. the
   per-page inline copies that drifted (Sending IPs, Settings, etc.):

     • NO border-bottom on .brand
       — the plan card has its own border, and active nav items have
         their own background highlight; an extra hairline below the
         logo is redundant chrome.

     • NO border-top on .sidebar-footer
       — same reason: the plan card's own top border already separates
         the footer region. Stacking two borders 14px apart is noise.

     • NO border-right on the sidebar
       — Dashboard ships without one and the design reads cleaner;
         keep the option below as a comment in case we revisit.

   Pages with .pm-sidebar / .dom-sidebar (Postmaster / Microsoft /
   Domains) get migrated to .sidebar markup in a follow-up commit so
   one set of rules governs everything.
   ────────────────────────────────────────────────────────────────── */
.sidebar {
  /* width + flex-shrink keep the sidebar at 240px on flex-layout pages
     (Sending IPs / Settings / etc.); Dashboard uses grid layout where
     the column is sized by `.layout { grid-template-columns: 240px 1fr }`,
     so the explicit width here is harmless and ensures consistency. */
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg, var(--surface));
  /* INBOX-220 confirmed-on-Dashboard look: vertical line on right edge.
     Visually separates sidebar from main content area on every page. */
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 20px;
  /* INBOX-220 confirmed: hairline below the logo. Visually separates
     brand from nav list. */
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  text-decoration: none;
  color: var(--fg, var(--text));
}
.sidebar .brand-mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--fg, var(--text)); color: var(--bg, var(--surface));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: -0.04em;
}
.sidebar .brand-name {
  font-size: 15px; font-weight: 600; letter-spacing: -0.025em;
  color: var(--fg, var(--text));
}
.sidebar .mobile-toggle {
  display: none;
  background: none; border: none; color: var(--fg-2, var(--text-muted));
  font-size: 20px; cursor: pointer; padding: 4px;
  position: absolute; top: 16px; right: 16px;
}

.sidebar-nav { list-style: none; flex: 1; padding: 0; margin: 0; }
.sidebar-nav li { list-style: none; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  color: var(--fg-2, var(--text-muted)); text-decoration: none;
  font-size: 13px; font-weight: 500;
  border-radius: 6px;
  margin-bottom: 1px;
  transition: background 100ms ease, color 100ms ease;
}
.sidebar-nav li a:hover { background: var(--bg-2, var(--surface-2)); color: var(--fg, var(--text)); }
.sidebar-nav li a.active { background: var(--bg-2, var(--surface-2)); color: var(--fg, var(--text)); }
.sidebar-nav li a .nav-icon {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--fg-3, var(--text-muted));
}
.sidebar-nav li a.active .nav-icon,
.sidebar-nav li a:hover .nav-icon { color: var(--fg, var(--text)); }
.sidebar-nav li a .nav-icon svg { display: block; }

.sidebar .alert-badge {
  background: var(--danger, #e5484d); color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px;
  margin-left: auto; min-width: 18px; text-align: center;
}

/* INBOX-220 confirmed: hairline above the plan card. Visually
   separates the nav list from the plan-management region. Vinoop's
   confirmed Dashboard look. */
.sidebar-footer {
  padding: 14px 8px 6px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  /* margin-top above the line so the line itself sits flush with the
     bottom of the nav list, then 14px of breathing room below before
     the plan card. */
}
