/* Shared structural styles + CMS content vocabulary. Color/font identity is
   supplied by each theme skin via CSS variables, and tenant colors come from
   the inline --cms-primary/--cms-secondary set on the .cms-theme-scope wrapper.
   CMS page content only ever uses these cms-* classes, so the same stored
   content re-skins automatically when the tenant switches template. */
    html { scroll-behavior: smooth; }
    main:has(.cms-theme-scope) { overflow: visible !important; }
    html:has(.cms-legal), body:has(.cms-legal) { overflow-x: clip !important; overflow-y: visible !important; }

    /* Tenant-configured background_color (--cms-background) wins over the theme
       skin's own --cms-bg default, so the reseller can recolor the whole template.
       The scope fills the viewport (min-h-screen), so this backs the whole page. */
    .cms-theme-scope { font-family: var(--cms-font-body, inherit); background: var(--cms-background, var(--cms-bg, transparent)); color: var(--cms-text, #475569); }

    /* Site chrome (shared nav + footer) — neutral light defaults; each theme
       skin can override the --cms-chrome-* vars (e.g. Atlas goes dark). */
    .cms-theme-scope {
        --cms-chrome-bg: var(--cms-chrome-bg-override, #ffffff);
        --cms-chrome-heading: var(--cms-chrome-heading-override, #0f172a);
        --cms-chrome-text: var(--cms-chrome-text-override, #334155);
        --cms-chrome-muted: var(--cms-chrome-muted-override, #64748b);
        --cms-chrome-border: var(--cms-chrome-border-override, #e2e8f0);
    }

    /* Layout */
    .cms-theme-scope .cms-section { padding: 4rem 0; }
    @media (min-width: 640px) { .cms-theme-scope .cms-section { padding: 5rem 0; } }
    .cms-theme-scope .cms-section--tint { background: var(--cms-tint, rgba(15, 23, 42, 0.03)); }
    .cms-theme-scope .cms-container { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 1rem; }
    @media (min-width: 640px) { .cms-theme-scope .cms-container { padding: 0 1.5rem; } }
    .cms-theme-scope .cms-narrow { max-width: 48rem; }
    .cms-theme-scope .cms-grid { display: grid; gap: 1.5rem; }
    .cms-theme-scope .cms-grid-2, .cms-theme-scope .cms-grid-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    @media (min-width: 768px) {
        .cms-theme-scope .cms-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .cms-theme-scope .cms-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    }
    .cms-theme-scope .cms-split { display: grid; gap: 3rem; grid-template-columns: 1fr; }
    @media (min-width: 1024px) { .cms-theme-scope .cms-split { grid-template-columns: 1.1fr 0.9fr; align-items: center; } }
    .cms-theme-scope .cms-mt-sm { margin-top: 1rem; }
    .cms-theme-scope .cms-mt { margin-top: 2rem; }
    .cms-theme-scope .cms-mt-lg { margin-top: 3rem; }

    /* Typography */
    .cms-theme-scope .cms-eyebrow { display: inline-flex; align-items: center; gap: 0.6rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; color: var(--cms-eyebrow-color, var(--cms-primary, #0f172a)); }
    .cms-theme-scope .cms-title { font-family: var(--cms-font-head, inherit); color: var(--cms-heading, #0f172a); font-size: 2.25rem; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
    @media (min-width: 640px) { .cms-theme-scope .cms-title { font-size: 3rem; } }
    .cms-theme-scope .cms-heading { font-family: var(--cms-font-head, inherit); color: var(--cms-heading, #0f172a); font-size: 1.75rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
    .cms-theme-scope .cms-subheading { font-family: var(--cms-font-head, inherit); color: var(--cms-heading, #0f172a); font-size: 1.15rem; font-weight: 600; }
    .cms-theme-scope .cms-lead { font-size: 1.125rem; line-height: 1.7; color: var(--cms-muted, #64748b); }
    .cms-theme-scope .cms-text { color: var(--cms-text, #475569); }
    .cms-theme-scope .cms-muted { color: var(--cms-muted, #64748b); }

    /* Surfaces */
    .cms-theme-scope .cms-card { background: var(--cms-surface, #fff); border: 1px solid var(--cms-border, #e5e7eb); border-radius: var(--cms-radius, 1rem); padding: 1.5rem; box-shadow: var(--cms-card-shadow, 0 1px 2px rgba(0, 0, 0, 0.05)); }
    .cms-theme-scope .cms-stat-value { font-family: var(--cms-font-head, inherit); font-size: 2rem; font-weight: 700; color: var(--cms-heading, #0f172a); }
    .cms-theme-scope .cms-stat-label { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cms-muted, #64748b); margin-top: 0.35rem; }

    /* Buttons */
    .cms-theme-scope .cms-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; border-radius: var(--cms-btn-radius, var(--cms-radius, 0.6rem)); padding: 0.8rem 1.6rem; font-weight: 600; font-size: 0.9rem; text-decoration: none; transition: all 0.18s ease; border: 1px solid transparent; cursor: pointer; }
    .cms-theme-scope .cms-btn--primary { background: var(--cms-primary, #0f172a); color: var(--cms-on-primary, #fff); }
    .cms-theme-scope .cms-btn--primary:hover { filter: brightness(0.94); }
    .cms-theme-scope .cms-btn--outline { background: transparent; border-color: var(--cms-primary, #0f172a); color: var(--cms-primary, #0f172a); }
    .cms-theme-scope .cms-btn--outline:hover { background: var(--cms-tint, rgba(15, 23, 42, 0.05)); }

    /* Hero — by default it blends into the active theme's own background
       (no forced colored band). A theme can opt into a distinct hero look by
       setting --cms-hero-bg / --cms-hero-text / --cms-hero-muted. */
    .cms-theme-scope .cms-hero { background: var(--cms-hero-bg, transparent); color: var(--cms-hero-text, var(--cms-text, #475569)); padding: 4rem 0; }
    @media (min-width: 640px) { .cms-theme-scope .cms-hero { padding: 5rem 0; } }
    .cms-theme-scope .cms-hero .cms-title, .cms-theme-scope .cms-hero .cms-heading { color: var(--cms-hero-text, var(--cms-heading, #0f172a)); }
    .cms-theme-scope .cms-hero .cms-lead { color: var(--cms-hero-muted, var(--cms-muted, #64748b)); }
    .cms-theme-scope .cms-hero .cms-eyebrow { color: var(--cms-hero-eyebrow, var(--cms-eyebrow-color, var(--cms-primary, #0f172a))); }

    /* Rich text (editable content) */
    .cms-theme-scope .cms-prose { color: var(--cms-text, #475569); font-size: 15px; line-height: 1.8; }
    .cms-theme-scope .cms-prose > :first-child { margin-top: 0; }
    .cms-theme-scope .cms-prose h2 { font-family: var(--cms-font-head, inherit); color: var(--cms-heading, #0f172a); font-size: 1.5rem; font-weight: 700; margin-top: 2.5rem; scroll-margin-top: 7rem; }
    .cms-theme-scope .cms-prose h3 { font-family: var(--cms-font-head, inherit); color: var(--cms-heading, #0f172a); font-size: 1.2rem; font-weight: 600; margin-top: 1.75rem; scroll-margin-top: 7rem; }
    .cms-theme-scope .cms-prose p { margin-top: 1rem; }
    .cms-theme-scope .cms-prose ul { margin-top: 1rem; list-style: disc; padding-left: 1.5rem; }
    .cms-theme-scope .cms-prose ol { margin-top: 1rem; list-style: decimal; padding-left: 1.5rem; }
    .cms-theme-scope .cms-prose li { margin-top: 0.4rem; }
    .cms-theme-scope .cms-prose a { color: var(--cms-primary, #0f172a); text-decoration: underline; text-underline-offset: 2px; }

    /* Legal layout + table of contents */
    .cms-theme-scope .cms-legal-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; }
    @media (min-width: 1024px) { .cms-theme-scope .cms-legal-grid { grid-template-columns: 260px minmax(0, 1fr); } }
    @media (min-width: 1024px) {
        .cms-theme-scope .cms-legal-sticky { position: sticky; top: 1.5rem; z-index: 20; max-height: calc(100vh - 2rem); overflow-y: auto; overscroll-behavior: contain; }
        header.sticky ~ main .cms-theme-scope .cms-legal-sticky { top: 6.5rem; max-height: calc(100vh - 7.5rem); }
    }
    .cms-theme-scope .legal-toc-link { display: block; border-radius: var(--cms-radius, 0.5rem); padding: 0.5rem 0.75rem; font-size: 0.875rem; font-family: var(--cms-font-body, inherit); color: var(--cms-muted, #64748b); transition: all 0.15s ease; }
    .cms-theme-scope .legal-toc-link:hover { background: var(--cms-tint, rgba(15, 23, 42, 0.05)); color: var(--cms-heading, #0f172a); }
    .cms-theme-scope .legal-toc-link.is-active { background: var(--cms-primary, #0f172a); color: var(--cms-on-primary, #fff); font-weight: 600; }
    .cms-theme-scope .legal-switch-link { display: block; border-radius: var(--cms-radius, 0.5rem); padding: 0.5rem 0.75rem; font-size: 0.875rem; font-family: var(--cms-font-body, inherit); color: var(--cms-text, #475569); transition: all 0.15s ease; }
    .cms-theme-scope .legal-switch-link:hover { background: var(--cms-tint, rgba(15, 23, 42, 0.05)); }
    .cms-theme-scope .legal-switch-link.is-active { background: var(--cms-primary, #0f172a); color: var(--cms-on-primary, #fff); }

    /* FAQ accordion (static <details> in CMS home sections) */
    .cms-theme-scope .cms-faq details { border-radius: var(--cms-radius, 1rem); }
    .cms-theme-scope .cms-faq summary { cursor: pointer; list-style: none; }
    .cms-theme-scope .cms-faq summary::-webkit-details-marker { display: none; }

    /* ===== Products / pricing table (store products section) ===== */
    .cms-theme-scope .cms-products-table-wrap {
        width: 100%;
        overflow-x: auto;
        background: var(--cms-surface, #fff);
        border: 1px solid var(--cms-border, #e5e7eb);
        border-radius: var(--cms-radius, 1rem);
        box-shadow: var(--cms-card-shadow, 0 1px 2px rgba(0, 0, 0, 0.05));
        -webkit-overflow-scrolling: touch;
    }
    .cms-theme-scope .cms-products-table {
        width: 100%;
        min-width: 640px;
        border-collapse: collapse;
        font-size: 0.925rem;
    }
    .cms-theme-scope .cms-products-table thead th {
        text-align: left;
        padding: 1rem 1.25rem;
        font-size: 0.72rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--cms-muted, #64748b);
        border-bottom: 1px solid var(--cms-border, #e5e7eb);
        white-space: nowrap;
    }
    .cms-theme-scope .cms-products-table tbody td {
        padding: 1rem 1.25rem;
        border-bottom: 1px solid var(--cms-border, #e5e7eb);
        color: var(--cms-text, #475569);
        vertical-align: middle;
    }
    .cms-theme-scope .cms-products-table tbody tr:last-child td { border-bottom: 0; }
    .cms-theme-scope .cms-products-table tbody tr:hover td { background: var(--cms-tint, rgba(15, 23, 42, 0.03)); }

    .cms-theme-scope .cms-products-table__product { width: 40%; }
    .cms-theme-scope .cms-products-table__product-cell {
        display: flex;
        align-items: center;
        gap: 0.85rem;
    }
    .cms-theme-scope .cms-products-table__icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 2.75rem;
        height: 2.75rem;
        border-radius: var(--cms-radius, 0.75rem);
        overflow: hidden;
        background: var(--cms-tint, rgba(15, 23, 42, 0.05));
        color: var(--cms-muted, #94a3b8);
    }
    .cms-theme-scope .cms-products-table__icon img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    .cms-theme-scope .cms-products-table__icon svg {
        width: 1.5rem;
        height: 1.5rem;
    }
    .cms-theme-scope .cms-products-table__name {
        font-weight: 600;
        color: var(--cms-heading, #0f172a);
        text-decoration: none;
    }
    a.cms-theme-scope .cms-products-table__name:hover,
    .cms-theme-scope a.cms-products-table__name:hover { color: var(--cms-primary, #0f172a); }

    .cms-theme-scope .cms-products-table__price {
        font-weight: 700;
        color: var(--cms-heading, #0f172a);
    }
    .cms-theme-scope .cms-products-table__price-alt {
        font-weight: 500;
        color: var(--cms-muted, #64748b);
    }
    .cms-theme-scope .cms-products-table__metric {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        font-weight: 600;
        color: var(--cms-heading, #0f172a);
        white-space: nowrap;
    }
    .cms-theme-scope .cms-products-table__metric svg {
        width: 1.05rem;
        height: 1.05rem;
        flex: 0 0 auto;
        color: var(--cms-primary, #16a34a);
    }
    .cms-theme-scope .cms-products-table__metric--speed svg { color: var(--cms-muted, #64748b); }

    /* ===== Site chrome (nav + footer) re-skinned by the active theme ===== */
    .cms-theme-scope header,
    .cms-theme-scope footer { font-family: var(--cms-font-body, inherit); }
    .cms-theme-scope header { background: var(--cms-chrome-bg) !important; border-color: var(--cms-chrome-border) !important; }
    .cms-theme-scope footer { background: var(--cms-chrome-bg) !important; border-color: var(--cms-chrome-border) !important; color: var(--cms-chrome-text); }

    /* Headings / brand text */
    .cms-theme-scope header h1, .cms-theme-scope footer h1,
    .cms-theme-scope header h2, .cms-theme-scope footer h2,
    .cms-theme-scope header h3, .cms-theme-scope footer h3 { font-family: var(--cms-font-head, inherit); }
    .cms-theme-scope header .text-slate-900,
    .cms-theme-scope footer .text-slate-900,
    .cms-theme-scope footer h3 { color: var(--cms-chrome-heading) !important; }

    /* Body / link text */
    .cms-theme-scope header .text-slate-700, .cms-theme-scope footer .text-slate-700 { color: var(--cms-chrome-text) !important; }
    .cms-theme-scope header .text-slate-400, .cms-theme-scope header .text-slate-500,
    .cms-theme-scope footer .text-slate-400, .cms-theme-scope footer .text-slate-500,
    .cms-theme-scope footer .text-slate-600 { color: var(--cms-chrome-muted) !important; }

    /* Borders + tinted surfaces inside the chrome */
    .cms-theme-scope header .border-slate-200, .cms-theme-scope header .border-slate-300,
    .cms-theme-scope footer .border-slate-200, .cms-theme-scope footer .border-slate-300,
    .cms-theme-scope header .border-slate-200\/80 { border-color: var(--cms-chrome-border) !important; }

    /* Primary (solid) chrome buttons follow the theme accent */
    .cms-theme-scope header .bg-slate-900 { background: var(--cms-primary, #0f172a) !important; color: var(--cms-on-primary, #fff) !important; }
    .cms-theme-scope header .bg-slate-900 * { color: var(--cms-on-primary, #fff) !important; }
    /* Outline (light) chrome buttons blend into the chrome surface */
    .cms-theme-scope header .bg-white { background: var(--cms-chrome-bg) !important; color: var(--cms-chrome-heading) !important; }

    /* Active nav underline uses the theme accent */
    .cms-theme-scope header .border-slate-900 { border-color: var(--cms-primary, #0f172a) !important; }

    /* ===== Auth pages (login / register / password) re-skinned by theme ===== */
    .cms-auth { min-height: 100vh; background: var(--cms-auth-bg, var(--cms-bg, #0f172a)); color: var(--cms-text, #475569); font-family: var(--cms-font-body, inherit); }
    .cms-auth-brand { color: var(--cms-muted, #64748b); }
    .cms-auth-card { background: var(--cms-surface, #ffffff); border: 1px solid var(--cms-border, #e2e8f0); border-radius: var(--cms-radius, 1rem); box-shadow: var(--cms-card-shadow, 0 24px 60px -30px rgba(0, 0, 0, 0.4)); }
    .cms-auth-badge { color: var(--cms-eyebrow-color, var(--cms-primary, #0f172a)); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; }
    .cms-auth-title { font-family: var(--cms-font-head, inherit); color: var(--cms-heading, #0f172a); }
    .cms-auth-sub, .cms-auth-foot { color: var(--cms-muted, #64748b); }
    .cms-auth label { color: var(--cms-text, #475569) !important; }
    .cms-auth input[type="text"], .cms-auth input[type="email"], .cms-auth input[type="password"] {
        background: var(--cms-auth-field-bg, transparent) !important;
        border-color: var(--cms-border, #e2e8f0) !important;
        color: var(--cms-heading, #0f172a) !important;
    }
    .cms-auth input::placeholder { color: var(--cms-muted, #94a3b8) !important; }
    .cms-auth input:focus { border-color: var(--cms-primary, #0f172a) !important; }
    .cms-auth button[type="submit"] { background: var(--cms-primary, #0f172a) !important; color: var(--cms-on-primary, #fff) !important; }
    /* Secondary copy ("Remember me", "New here?", ...) reads as muted text */
    .cms-auth .text-white\/80, .cms-auth .text-white\/70, .cms-auth .text-white\/60 { color: var(--cms-muted, #64748b) !important; }
    /* Inline links pick up the theme accent */
    .cms-auth a, .cms-auth a.text-white { color: var(--cms-primary, #0f172a) !important; text-decoration-color: currentColor; }
    /* Keep validation alerts readable on any (light or dark) card */
    .cms-auth .text-red-100 { color: #dc2626 !important; }
    .cms-auth .text-emerald-100 { color: #059669 !important; }

/* ==========================================================================
   Chrome CTA color helpers — drive nav/footer buttons & accents from the
   reseller's chosen primary/secondary colors (injected as CSS vars on the
   theme scope). Plain CSS (not Tailwind) so they apply without a build step
   and support :hover. Used by every template's nav/footer.
   ========================================================================== */
.cms-cta-primary { background: var(--cms-primary) !important; color: var(--cms-on-primary, #fff) !important; }
.cms-cta-primary:hover { filter: brightness(1.08); }
.cms-cta-gradient { background: linear-gradient(135deg, var(--cms-primary), var(--cms-secondary)) !important; color: var(--cms-on-primary, #fff) !important; }
.cms-cta-gradient:hover { filter: brightness(1.06); }
.cms-cta-outline { border-color: var(--cms-secondary) !important; color: var(--cms-secondary) !important; }
.cms-cta-outline:hover { filter: brightness(1.12); }
.cms-accent-text { color: var(--cms-primary) !important; }
.cms-accent-hover:hover { color: var(--cms-primary) !important; }
.cms-accent-border-hover:hover { border-color: var(--cms-primary) !important; color: var(--cms-primary) !important; }
.cms-accent-decoration { text-decoration-color: var(--cms-primary) !important; }

/* ==========================================================================
   Customer dashboard / authenticated CMS portal sections (cms-dash*).
   These wrappers ship in stored page HTML but had no styling, so inner pages
   spilled full-width with unstyled nav/tool links. Themed via the shared vars
   so the dashboard matches whichever template the tenant selected.
   ========================================================================== */
.cms-theme-scope .cms-dash { padding: clamp(1.5rem, 4vw, 2.75rem) 0; }
.cms-theme-scope .cms-dash-shell { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2rem); }
.cms-theme-scope .cms-dash-badge {
    display: inline-flex; align-items: center; gap: 0.5rem;
    border-radius: var(--cms-btn-radius, var(--cms-radius, 0.6rem));
    background: var(--cms-tint); color: var(--cms-heading); border: 1px solid var(--cms-border);
    padding: 0.55rem 1.15rem; font-weight: 700; font-size: 0.95rem;
}
.cms-theme-scope .cms-dash-stat { font-family: var(--cms-font-head, inherit); color: var(--cms-heading); }
.cms-theme-scope .cms-dash-nav a,
.cms-theme-scope .cms-dash-nav button {
    display: block; width: 100%; text-align: inherit; border-radius: calc(var(--cms-radius, 0.75rem) * 0.5);
    padding: 0.55rem 0.8rem; color: var(--cms-text); text-decoration: none; background: transparent;
    font: inherit; cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.cms-theme-scope .cms-dash-nav a:hover,
.cms-theme-scope .cms-dash-nav button:hover { background: var(--cms-tint); color: var(--cms-primary); }
.cms-theme-scope .cms-dash-tool {
    display: block; border: 1px solid var(--cms-border); border-radius: calc(var(--cms-radius, 0.75rem) * 0.6);
    padding: 0.9rem 1.1rem; color: var(--cms-heading); text-decoration: none; font-weight: 600; font-size: 0.9rem;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.cms-theme-scope .cms-dash-tool:hover { border-color: var(--cms-primary); color: var(--cms-primary); background: var(--cms-tint); }
