/* ==========================================================================
   Customer brand layer. Loaded only on customer pages (customer area, guest
   /order and /cart, customer sign-in), after app.css and auth.css. layout_top()
   emits the --brand-* values for the business from its published Theme
   (app/core/Brand.php), so every business gets its own colours here while the
   business admin and master console keep the platform design.

   It maps brand values onto the shared app tokens, swaps the ink sidebar for a
   light rail, gives the logo a fixed box, and lines the storefront pieces up
   with the Next storefront (apps/web/app/globals.css: .hx-pcard, .hx-btn,
   .hx-cats-nav). Fallbacks equal the Portal Classic preset.
   ========================================================================== */

body.brand-customer{
  --primary:var(--brand,#2563EB); --primary-hover:var(--brand-hover,#1F53C8); --primary-fg:var(--brand-contrast,#fff);
  --primary-soft:var(--brand-soft,#E9EFFD); --ring:var(--brand-ring,rgba(37,99,235,.28));
  --bg:var(--brand-bg,#F8FAFC); --bg-elevated:var(--brand-surface,#fff); --bg-subtle:var(--brand-subtle,#F0F2F5); --field-bg:var(--brand-surface,#fff);
  --fg:var(--brand-text,#0F172A); --fg-muted:var(--brand-muted,#475569); --fg-subtle:var(--brand-muted,#475569);
  --line:var(--brand-line,#E2E8F0); --line-strong:var(--brand-line-strong,#B4BCC8);
  --topbar-bg:color-mix(in srgb,var(--brand-bg,#F8FAFC) 92%,transparent);
  --radius-lg:var(--brand-radius,10px);
  /* Light rail: surface background, hairline edge, theme text */
  --chrome-bg:var(--bg-elevated); --chrome-fg:var(--fg-muted); --chrome-fg-strong:var(--fg); --chrome-line:var(--line);
  background:var(--bg); color:var(--fg);
}
body.brand-customer :focus-visible{outline-color:var(--brand-ink,var(--primary))}
body.brand-customer ::selection{background:var(--primary-soft)}

/* ---------- Buttons (Next .hx-btn: 7px corners, bold label) ---------- */
body.brand-customer .btn{border-radius:7px;font-weight:700}
body.brand-customer .btn:not(.btn-ghost):not(.btn-danger):not(.btn-ok){background:var(--primary);color:var(--primary-fg)}
body.brand-customer .btn:not(.btn-ghost):not(.btn-danger):not(.btn-ok):hover{background:var(--primary-hover);color:var(--primary-fg)}
body.brand-customer .btn-danger,body.brand-customer .btn-ok,body.brand-customer .btn-danger:hover,body.brand-customer .btn-ok:hover{color:#fff}
body.brand-customer .btn-ghost{color:var(--fg)}
body.brand-customer .btn[aria-busy=true]::after{border-color:var(--primary-fg);border-top-color:transparent;border-bottom-color:transparent}
body.brand-customer .badge,body.brand-customer .nav-badge{background:var(--primary);color:var(--primary-fg)}

/* ---------- Logo: fixed box, never stretched; light logos sit on a dark brand chip ---------- */
body.brand-customer .brand-logo{display:block;height:32px;width:auto;max-width:150px;object-fit:contain;object-position:left center;border-radius:4px}
body.brand-customer .brand-logo.logo-is-light,
body.brand-customer .auth-logo-img.logo-is-light{background:var(--brand-deep,#1B2233);padding:4px 8px;box-sizing:content-box;border-radius:6px}
/* A logo is usually a wordmark: show it alone (the name stays for screen readers) */
body.brand-customer .sidebar-brand a:has(.brand-logo){flex-direction:column;align-items:flex-start;gap:.3rem}
body.brand-customer .sidebar-brand .brand-logo{height:36px;max-width:200px}
body.brand-customer a:has(.brand-logo) .brand-text b,
body.brand-customer a:has(.brand-logo) .brand-name,
body.brand-customer .auth-logo:has(.auth-logo-img) > span:not(.auth-logo-badge){position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
body.brand-customer .brand-mark{background:var(--primary);color:var(--primary-fg);border-radius:8px;font-family:var(--font-sans);font-weight:800}

/* ---------- Light sidebar rail ---------- */
body.brand-customer .sidebar{border-right:1px solid var(--line);scrollbar-color:var(--line-strong) transparent}
body.brand-customer .sidebar-brand{padding:.35rem .5rem 1.1rem;margin-bottom:.4rem;border-bottom:1px solid var(--line)}
body.brand-customer .sidebar-brand a{color:var(--fg)}
body.brand-customer .brand-sub{color:var(--fg-muted);opacity:1}
body.brand-customer .sidenav-heading{color:var(--fg-muted)}
body.brand-customer .sidenav a{color:var(--fg-muted)}
body.brand-customer .sidenav a:hover{background:var(--bg-subtle);color:var(--fg)}
body.brand-customer .sidenav a.active{background:var(--primary-soft);color:var(--brand-ink,var(--primary))}
body.brand-customer .sidenav a.active::before{background:var(--primary)}
body.brand-customer .sidenav a.active svg{color:var(--brand-ink,var(--primary))}
body.brand-customer .sidebar-user{background:var(--bg);border-color:var(--line)}
body.brand-customer .sidebar-user .who a,body.brand-customer .sidebar-user .who span{color:var(--fg)}
body.brand-customer .sidebar-user button:hover{background:var(--bg-subtle);color:var(--fg)}
body.brand-customer .avatar{background:var(--primary-soft);color:var(--brand-ink,var(--primary))}
body.brand-customer .avatar-sm{color:var(--brand-ink,var(--primary))}

/* ---------- Guest header (Next .hx-header) and footer ---------- */
body.brand-customer .topbar{height:64px}
body.brand-customer .brand a{gap:.6rem;font-size:1.02rem;color:var(--fg)}
body.brand-customer .brand .brand-mark{width:30px;height:30px;display:grid;place-items:center;font-size:.85rem}
body.brand-customer .topnav a{color:var(--fg)}
body.brand-customer .topnav a:hover{color:var(--brand-ink,var(--primary))}
body.brand-customer .footer{color:var(--fg-muted);border-top:1px solid var(--line);margin-top:2rem}

/* ---------- Store page: Next category list + plan cards ---------- */
body.brand-customer .store{grid-template-columns:220px minmax(0,1fr);gap:2.5rem}
body.brand-customer .store-box{background:none;border:0;border-radius:0;padding:0;margin:0}
body.brand-customer .store-box .panel-title{padding:0 0 .5rem;margin:0;border-bottom:1px solid var(--fg)}
body.brand-customer .store-cats{margin:0}
body.brand-customer .store-cats a{padding:.6rem .2rem;border-top:0;border-bottom:1px solid var(--line);font-weight:600;font-size:.94rem;color:var(--fg)}
body.brand-customer .store-cats a:hover{background:none;color:var(--brand-ink,var(--primary))}
body.brand-customer .store-cats a.active{background:none;color:var(--brand-ink,var(--primary));box-shadow:inset 3px 0 0 var(--primary);padding-left:.7rem}
body.brand-customer .store-section{border-top:1px solid var(--fg);padding-top:.9rem}
body.brand-customer .store-heading{font-size:1.45rem;font-weight:750;letter-spacing:-.025em}

body.brand-customer .plan-card{gap:.55rem;padding:1.25rem;background:var(--bg-elevated);border:1px solid var(--line);border-radius:var(--radius-lg);overflow:visible}
body.brand-customer .plan-card-head{display:flex;flex-direction:column-reverse;align-items:flex-start;gap:.5rem;padding:0;border:0;background:none}
body.brand-customer .plan-card-head h3{font-size:1.1rem;color:var(--fg)}
body.brand-customer .plan-card-head .pill{text-transform:uppercase;letter-spacing:.04em;font-size:.72rem;font-weight:700;padding:.1rem .55rem}
body.brand-customer .plan-card-head .pill::before{content:none}
body.brand-customer .plan-card-head .pill-info{background:var(--primary);color:var(--primary-fg)}
body.brand-customer .plan-card-body{padding:0;gap:.55rem}
body.brand-customer .plan-card-price .price{font-size:1.7rem;color:var(--fg)}
body.brand-customer .plan-features{gap:0;font-size:.9rem}
body.brand-customer .plan-features li{padding:.22rem 0 .22rem 1.2rem;border-top:1px solid var(--line)}
body.brand-customer .plan-features li::before{content:"+";top:.22rem;width:auto;height:auto;background:none;color:var(--brand-ink,var(--primary));font-weight:700}
body.brand-customer .plan-card-foot{padding:0;margin-top:.4rem;border:0}
body.brand-customer .plan-card-foot .btn{min-height:42px;font-size:.95rem}
body.brand-customer .plan-card.is-trial{border-color:var(--primary);box-shadow:inset 0 3px 0 var(--primary)}
body.brand-customer .plan-card.is-trial .plan-card-head{background:none;color:inherit}
body.brand-customer .plan-card.is-trial .plan-card-head h3{color:var(--fg)}
body.brand-customer .plan-card-sm .plan-card-price{padding:0}
body.brand-customer .plan-card-sm.is-trial .plan-card-head{background:none}
body.brand-customer .plan-row:target{box-shadow:inset 3px 0 0 var(--primary)}
@media(max-width:860px){
  /* Categories become a chip row (Next .hx-cats-nav on small screens) so plans start near the top */
  body.brand-customer .store{grid-template-columns:1fr;gap:1.2rem}
  body.brand-customer .store-side{flex-direction:column;gap:.8rem}
  body.brand-customer .store-side .store-box{flex:none}
  body.brand-customer .store-box .panel-title{display:none}
  body.brand-customer .store-cats{flex-direction:row;flex-wrap:wrap;gap:.5rem}
  body.brand-customer .store-cats a{padding:.3rem .8rem;border:1px solid var(--line);border-radius:999px;background:var(--bg-elevated);font-size:.86rem;min-height:36px}
  body.brand-customer .store-cats a.active{box-shadow:none;padding-left:.8rem;border-color:var(--primary)}
}

/* ---------- Dashboard and lists ---------- */
body.brand-customer .card{border-radius:var(--radius-lg)}
body.brand-customer .stat::before{background:var(--primary)}
body.brand-customer .stat.is-ok::before{background:var(--success)}
body.brand-customer .stat.is-warn::before{background:var(--warning)}
body.brand-customer .stat.is-danger::before{background:var(--danger)}
body.brand-customer .buy-trial{background:var(--primary-soft);border-color:var(--primary)}
body.brand-customer .buy-cat,body.brand-customer .buy-feats li::before{color:var(--brand-ink,var(--primary))}
body.brand-customer .buy-card{border-radius:var(--radius-lg)}
body.brand-customer .next-step.tone-info{border-left-color:var(--primary)}
body.brand-customer .tabs a.on{border-bottom-color:var(--primary)}
body.brand-customer .tabs a.on .tab-count{color:var(--brand-ink,var(--primary))}
body.brand-customer .alert-info{color:var(--fg);border-color:var(--line);border-left-color:var(--primary);background:var(--primary-soft)}
body.brand-customer .minichart rect{fill:var(--primary-soft)}
body.brand-customer .post-staff .post-body,body.brand-customer .msg-admin{background:var(--primary-soft);border-color:var(--line)}
body.brand-customer .pill-info{background:var(--primary-soft);color:var(--brand-ink,var(--primary))}
body.brand-customer .live-toast{border-left-color:var(--primary)}

/* ---------- Customer invoice crypto box: brand variables only ---------- */
body.brand-customer .crypto-card{border-color:var(--line-strong)}
body.brand-customer .crypto-head{background:var(--primary-soft);border-bottom-color:var(--line)}
body.brand-customer .crypto-icon,body.brand-customer .crypto-step > span:first-child{background:var(--primary);color:var(--primary-fg)}
body.brand-customer .crypto-badge{background:var(--primary-soft);color:var(--brand-ink,var(--primary))}
body.brand-customer .crypto-coin:hover > span{border-color:var(--line-strong)}
body.brand-customer .crypto-coin input:checked + span{border-color:var(--primary);box-shadow:0 0 0 2px var(--ring);background:var(--primary-soft)}
body.brand-customer .crypto-address .copy-field input{background:var(--primary-soft);border-color:var(--line-strong)}

/* ---------- Customer sign-in pages (auth.css scopes its own tokens to .auth-page) ---------- */
body.brand-customer.area-auth{background:var(--brand-bg,#F8FAFC)}
body.brand-customer .auth-page{
  --primary:var(--brand,#2563EB); --primary-hover:var(--brand-hover,#1F53C8); --primary-soft:var(--brand-soft,#E9EFFD);
  --ring:var(--brand-ring,rgba(37,99,235,.28)); --bg:var(--brand-bg,#F8FAFC); --bg-elevated:var(--brand-surface,#fff);
  --fg:var(--brand-text,#0F172A); --fg-muted:var(--brand-muted,#475569); --line:var(--brand-line,#E2E8F0); --line-strong:var(--brand-line-strong,#B4BCC8);
}
body.brand-customer .auth-page a,body.brand-customer .auth-link-btn{color:var(--brand-ink,var(--primary))}
body.brand-customer .auth-page .auth-logo{color:var(--fg)!important}
body.brand-customer .auth-logo-img{height:40px;max-width:200px;object-fit:contain;object-position:left center}
body.brand-customer .auth-logo-mark,body.brand-customer .auth-submit,body.brand-customer .auth-testimonial-avatar,
body.brand-customer .auth-favicon-dot-primary{background:var(--primary);color:var(--brand-contrast,#fff)}
body.brand-customer .auth-submit:hover:not(:disabled){background:var(--primary-hover)}
body.brand-customer .auth-panel{background:var(--brand-deep,#0a1122)}
body.brand-customer .auth-panel-eyebrow{color:var(--brand-on-deep,#9fc0ff)}
body.brand-customer .auth-verified-primary{color:var(--brand-ink,var(--primary))}

/* Long business names truncate instead of running under the cart and sign-in buttons on phones. */
@media (max-width:768px){
  .topbar-guest .brand{overflow:hidden}
  .topbar-guest .brand a{max-width:100%}
  .topbar-guest .brand-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
}
