/*
 * Customer-facing panel only (customer-panel.twig, cancel-sub.twig,
 * plan-change.twig, new-subscription*.twig, paddle/mp-checkout.twig).
 * Admin screens (src/Templates/admin/) load admin.css instead — see
 * partials/head.twig — so the two never share a component class that
 * happens to look similar today but is free to diverge tomorrow. Truly
 * shared chrome (the top bar, the shared <dialog>/toast styling) lives in
 * minihotel.css.
 *
 * Same rule as minihotel.css: recolor tokens already defined there
 * instead of introducing new ones. This file also carries the brand-color
 * .btn- .form-control overrides (see the Bootstrap section below) — they
 * stay out of minihotel.css on purpose, since that file also loads on
 * admin, which keeps Bootstrap's stock colors. 
 */

/* ---- Bootstrap component overrides: brand colors ----------------------
 * Bootstrap's .btn-* variants are scoped by their own --bs-btn-* custom
 * properties (see bootstrap.min.css) — overriding those per class keeps
 * the customer panel on the Minihotel palette without touching Bootstrap's
 * global --bs-primary (which would also recolor admin if it lived in
 * minihotel.css instead).
 */
.btn-primary {
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-bg: var(--brand-primary-hover);
    --bs-btn-hover-border-color: var(--brand-primary-hover);
    --bs-btn-active-bg: var(--brand-primary-hover);
    --bs-btn-active-border-color: var(--brand-primary-hover);
    --bs-btn-disabled-bg: var(--brand-primary);
    --bs-btn-disabled-border-color: var(--brand-primary);
    --bs-btn-focus-shadow-rgb: 19, 80, 157;
}

/* Outline secondary action = light blue border/text on white, not a solid
 * gray fill — a solid gray read as too crude for this design. */
.btn-outline-primary {
    --bs-btn-color: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary-border);
    --bs-btn-hover-color: var(--brand-primary);
    --bs-btn-hover-bg: var(--brand-primary-soft);
    --bs-btn-hover-border-color: var(--brand-primary);
    --bs-btn-active-color: var(--brand-primary);
    --bs-btn-active-bg: var(--brand-primary-soft);
    --bs-btn-active-border-color: var(--brand-primary);
    --bs-btn-disabled-color: var(--brand-primary);
    --bs-btn-disabled-border-color: var(--brand-primary-border);
    --bs-btn-focus-shadow-rgb: 19, 80, 157;
}

/* Solid — only used inside a confirmation <dialog>, where the destructive
 * action is already the expected one. */
.btn-danger {
    --bs-btn-bg: var(--brand-danger);
    --bs-btn-border-color: var(--brand-danger);
    --bs-btn-hover-bg: var(--brand-danger-hover);
    --bs-btn-hover-border-color: var(--brand-danger-hover);
    --bs-btn-active-bg: var(--brand-danger-hover);
    --bs-btn-active-border-color: var(--brand-danger-hover);
    --bs-btn-focus-shadow-rgb: 253, 41, 0;
}

/* Outline — the default everywhere else: shouldn't visually compete with
 * the primary action. */
.btn-outline-danger {
    --bs-btn-color: var(--brand-danger-hover);
    --bs-btn-border-color: var(--brand-danger-border);
    --bs-btn-hover-color: var(--brand-danger-hover);
    --bs-btn-hover-bg: var(--brand-danger-soft);
    --bs-btn-hover-border-color: var(--brand-danger);
    --bs-btn-active-color: var(--brand-danger-hover);
    --bs-btn-active-bg: var(--brand-danger-soft);
    --bs-btn-active-border-color: var(--brand-danger);
    --bs-btn-focus-shadow-rgb: 253, 41, 0;
}

/* Bootstrap hardcodes its own blue for the focus ring on form fields
 * (border-color/box-shadow, not a variable it exposes) — restated here with
 * the brand color instead. */
.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary-border);
    box-shadow: 0 0 0 .25rem rgba(19, 80, 157, .25);
}

/* ---- Button sizing/spacing ---------------------------------------------
 * Bootstrap's own .btn sizing is close but this panel runs slightly
 * tighter/smaller than the admin screens.
 */
.btn {
    white-space: nowrap;   /* keep the label from wrapping onto 2 lines */
    font-weight: 600;
    padding: 8px;
    font-size: 0.95rem;
    /* Some browsers don't inherit line-height on <button> like they do on
     * <a> (it falls back to the font's own "normal" metric instead), so a
     * <button> and an <a role=button> next to each other end up different
     * heights even with identical padding/font-size. Pin it explicitly so
     * both compute to the same box height.
     */
    line-height: var(--brand-line-height);
    margin-top: 20px;
}

/* Bootstrap has no automatic busy/loading state for a plain .btn (Pico used
 * to render one for aria-busy="true") — partials/interactions.twig already
 * sets that attribute on submit, this is just the spinner to go with it. */
.btn[aria-busy="true"] {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn[aria-busy="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    /* --bs-btn-color is the button's own intended foreground color (white
     * for a solid .btn-primary, brand blue for .btn-outline-primary, ...) —
     * read directly instead of currentColor, since the button's own `color`
     * is transparent right above (that's what hides the label). */
    border: 2px solid var(--bs-btn-color);
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ---- Subscription status card (customer-panel.twig) -----------------
 * Three flush white sections separated by a hairline, kept white all the
 * way through (no tinted header/footer band).
 */
.subscription-card {
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: var(--brand-shadow);
    overflow: hidden;
    padding: 25px;
}

.subscription-card > * + * { border-top: 1px solid var(--brand-line-soft); }
.subscription-card-header  { padding: 15px; }
.subscription-card-actions { padding: 15px; }

.subscription-card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.subscription-card-title    { margin: 0 0 6px; font-size: 29px; font-weight: 800; color: var(--brand-heading); letter-spacing: -.02em; }
.subscription-card-subtitle { font-size: 15px; color: var(--brand-body); }

/* ---- Gateway branding (mp-checkout.twig, new-subscription-mp.twig) ----
 * Small trust badge above an embedded checkout form, so the customer sees
 * whose form they're entering card details into.
 */
.gateway-logo {
    display: block;
    height: 28px;
    width: auto;
    margin-bottom: 16px;
    margin-top: 50px;
}

/* ---- Bottom "need help before you go" card (customer-panel.twig) ---- */
.contact-card {
    margin-top: 20px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.contact-card-title { font-size: 15px; font-weight: 600; color: var(--brand-heading); }
.contact-card-body  { font-size: 14px; color: var(--brand-body); margin-top: 2px; }
.contact-card-actions { display: flex; gap: 10px; }

/* ---- Customer panel visual hierarchy ---------------------------------
 * The main account view has several dense sections. Soft blue surfaces make
 * their boundaries clear without turning subscription data into decoration.
 * Scoped to .panel-container so checkout, cancellation and plan pages keep
 * their intentionally quieter layout.
 */
body:has(.panel-container) {
    background: var(--brand-page-bg);
}

.panel-container {
    padding-block: 1.75rem 3rem;
}

.panel-container .subscription-card {
    border-color: var(--brand-primary-border);
    box-shadow: 0 12px 30px rgba(19, 33, 47, .07);
}

.panel-container .subscription-card-header {
    background: #fcfcfc;
    border: 1px solid var(--brand-line-soft);
    border-radius: var(--brand-radius);
}

.panel-container .contact-card {
    padding: 1.25rem 1.375rem;
    border-color: var(--brand-primary-border);
    border-left: 4px solid var(--brand-primary);
    box-shadow: 0 8px 22px rgba(19, 33, 47, .05);
}

[dir="rtl"] .panel-container .contact-card {
    border-left: 1px solid var(--brand-primary-border);
    border-right: 4px solid var(--brand-primary);
}

@media (max-width: 575.98px) {
    .panel-container {
        padding-block: 1rem 2rem;
    }

    .panel-container .subscription-card {
        padding: 14px;
    }

    .panel-container .contact-card-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .panel-container .contact-card-actions .btn,
    .panel-container .contact-card-actions form {
        flex: 1 1 100%;
    }
}

/* ---- "or enter your card details" divider (paddle-checkout.twig) ---- */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--brand-muted);
    font-size: 13px;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--brand-line-soft);
}

/* ---- Scrollable dialog body (cancellation's choice lists) ---- */
.dialog-scroll-body {
    padding: 20px 26px;
    max-height: 46vh;
    overflow: auto;
}

#confirmPlanChangeDialog h2 { font-size:1.35rem; }

/* ---- Field validation state (paddle-checkout.twig card form) ---- */
.field-hint--error {
    display: block;
    font-size: 13px;
    color: var(--brand-danger-hover);
    margin-top: 6px;
}

.form-control.has-error {
    border-color: var(--brand-danger-border);
}

.form-control.has-error:focus {
    border-color: var(--brand-danger);
    box-shadow: 0 0 0 .25rem rgba(253, 41, 0, .12);
}

/* ---- Processing overlay ------------------------------------------------
 * Covers the whole viewport (topbar included) while a payment step runs, so
 * nothing else can be clicked. `position: fixed` + flex centering keeps the
 * box inside the viewport at any size, with no page scroll needed to see it.
 */
.processing-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .6);
}

/* `display: flex` above would otherwise beat the UA rule behind [hidden]. */
.processing-overlay[hidden] {
    display: none;
}

.processing-box {
    max-width: 360px;
    padding: 28px 24px;
    text-align: center;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

.processing-title {
    margin: 16px 0 6px;
    font-size: 18px;
    font-weight: 600;
}

.processing-body {
    margin: 0;
    color: #555;
}

/* ---- Legal links + modal (terms/privacy shown over the checkout) ------- */
.legal-links {
    margin: 1.5rem 0 0;
    text-align: center;
    font-size: .875rem;
}

/* Wider than the default 480px dialog, and capped to the viewport height so
 * it never forces a page-level scroll — the iframe scrolls on its own. */
dialog.legal-dialog {
    width: min(92vw, 800px);
    max-width: none;
    max-height: 90vh;
    overflow: hidden;
}

dialog.legal-dialog[open] { display: flex; }

dialog.legal-dialog > article {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
}

dialog.legal-dialog iframe {
    flex: 1 1 auto;
    width: 100%;
    height: 70vh;
    min-height: 0;
    padding: 0;
    border: 0;
}
