/* ══════════════════════════════════════════════════════════════
   Checkout — styles on top of cart.css
   Matches the visual design from the old checkout.css
   ══════════════════════════════════════════════════════════════ */

/* ── Body ─────────────────────────────────────────────────────── */
body.page-checkout {
    background: var(--cart-cream, #faf9f7);
    height: auto;
    overflow: auto;
}
body.page-checkout > main {
    padding: 0;
    max-width: 100%;
    height: auto;
    overflow: visible;
}

/* ══════════════════════════════════════════════════════════════
   Layout
   ══════════════════════════════════════════════════════════════ */
.checkout {
    display: flex;
    min-height: 100vh;
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    align-items: flex-start;
}

/* ── Topbar (right-aligned content within left half) ─────────── */
.checkout__topbar {
    display: flex;
    align-items: center;
    padding: 55px 56px 1rem 2rem;
    background: #fff;
    position: relative;
    flex-shrink: 0;
    max-width: 100%;
    width: 100%;
    justify-content: flex-end;
    box-sizing: border-box;
}
/* Desktop: topbar content right-aligned within left column */
.checkout__layout > .checkout__topbar {
    max-width: 100%;
}
.checkout__logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    text-decoration: none;
}
.checkout__logo img {
    height: 38px;
    width: auto;
    display: block;
}
.checkout__cart-link {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--cart-accent);
    text-decoration: none;
    font-size: 0.875rem;
    position: relative;
    transition: opacity 0.2s;
}
.checkout__cart-link:hover { opacity: 0.7; }
.checkout__cart-link .material-symbols-rounded { font-size: 1.75rem; }
.checkout__cart-badge {
    position: absolute;
    top: -5px;
    right: -9px;
    background: var(--cart-accent);
    color: #fff;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    animation: badge-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── 2-column layout (CSS Grid, full viewport) ──────────────── */
.checkout__layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Desktop: topbar sits in left column area */
.checkout__layout > .checkout__topbar {
    grid-column: 1;
    grid-row: 1;
    background: #fff;
}

/* ── Left column (form) ───────────────────────────────────────── */
.checkout__left {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    overflow-y: visible;
    display: flex;
    flex-direction: column;
    background: #fff;
    margin: 0;
}

/* Inner content: right-aligned within left column, ~60% max-width */
.checkout__left-inner {
    flex: 1;
    padding: 2rem 56px 2rem 2rem;
    max-width: 60%;
    margin-left: auto;
    width: 100%;
    box-sizing: border-box;
}

/* ── Right column (summary) — sticky, takes 50% ──────────────── */
.checkout__right {
    grid-column: 2;
    grid-row: 1 / -1;
    background: var(--cart-cream, #faf9f7);
    border-left: 1px solid #e5e7eb;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

/* Right inner: left-aligned content within right column */
#section-cart-summary {
    padding: var(--topbar-h, 1.5rem) 2rem 1.5rem 56px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    max-width: 60%;
}
.checkout__right h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: none;
    padding: var(--topbar-h, 55px) 2rem 0.75rem 56px;
    margin: 0 0 0;
    flex-shrink: 0;
    max-width: 60%;
    box-sizing: border-box;
}

/* Scrollable items area */
.checkout__right-items {
    flex-shrink: 1;
    max-height: 400px;
    overflow-y: auto;
    min-height: 0;
}

/* ── Sections ─────────────────────────────────────────────────── */
.checkout__section {
    border-bottom: 1px solid var(--cart-border);
    padding: 24px 0;
}
.checkout__section:first-child { padding-top: 0; }

/* ── Pay button ───────────────────────────────────────────────── */
.checkout__pay-btn {
    width: 100% !important;
    background: var(--cart-accent) !important;
    color: white !important;
    border: 1px solid var(--cart-accent) !important;
    border-radius: 999px !important;
    padding: 14px !important;
    font-size: 16px !important;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-top: 16px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}
.checkout__pay-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transform: skewX(-20deg);
    transition: left 0.5s ease;
    pointer-events: none;
}
.checkout__pay-btn:hover {
    background: #000 !important;
    border-color: #000 !important;
    color: white !important;
}
.checkout__pay-btn:hover::after { left: 150%; }

/* ── Payment form container ───────────────────────────────────── */
.checkout__payment-form { margin-top: 16px; }

/* ── Register page ────────────────────────────────────────────── */
.checkout__register {
    max-width: 600px;
    margin: 40px auto;
    padding: 0 16px;
}


/* ══════════════════════════════════════════════════════════════
   Form styles (checkout-specific)
   ══════════════════════════════════════════════════════════════ */

/* Inputs */
.checkout input[type="text"],
.checkout input[type="email"],
.checkout input[type="tel"],
.checkout input[type="password"],
.checkout input[type="number"],
.checkout select,
.checkout textarea {
    width: 100%;
    padding: 10px 12px;
    /* #cecece nomes dona ~1.57:1, cal 3:1 en el contorn d'un camp (1.4.11) */
    border: 1px solid #8a8f98;
    border-radius: var(--bs-border-radius, 8px);
    font-size: 14px;
    margin-bottom: 10px;
    box-sizing: border-box;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.checkout select { appearance: auto; }
.checkout textarea { min-height: 80px; resize: vertical; }
.checkout input:focus,
.checkout select:focus,
.checkout textarea:focus {
    border-color: #111;
}
.checkout input:focus-visible,
.checkout select:focus-visible,
.checkout textarea:focus-visible {
    outline: 2px solid #111;
    outline-offset: 1px;
}
.checkout input[readonly] {
    background: rgba(206, 206, 206, 0.5);
    color: var(--cart-muted);
    cursor: default;
}

/* ── Form section ─────────────────────────────────────────────── */
.form-section { margin-bottom: 1.75rem; }
.form-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.85rem;
    flex-wrap: wrap;
}
.form-section__title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}
.form-section__header a {
    font-size: 0.85rem;
    color: #111;
    text-decoration: underline;
    margin-left: auto;
}
.form-section__header a:hover { color: var(--cart-accent); }

/* ── Form rows ────────────────────────────────────────────────── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.form-row--thirds {
    grid-template-columns: 1fr 1fr 1fr;
}
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cecece;
    border-radius: var(--bs-border-radius, 8px);
    font-size: 14px;
    font-family: inherit;
}

/* ── Checkboxes ───────────────────────────────────────────────── */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 10px 0;
    font-size: 14px;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    margin-top: 3px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}
.form-check label a { color: var(--cart-accent); text-decoration: underline; }

/* ── Card-style radios ────────────────────────────────────────── */
.form-radios {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.form-radio {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--cart-border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
/* Bàner "paga en X terminis" (PayPal V2, sempre visible): segona línia dins l'opció,
   alineat sota el títol (amplada del radio 18px + gap 10px). */
.fp-paylater-inline {
    flex-basis: 100%;
    margin-left: 28px;
}
.fp-paylater-inline .sb-paypalv2-paylater {
    margin-top: 2px !important;
}
.form-radio:has(input:checked) {
    background: #fafafa;
}
.form-radio input[type="radio"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.form-radio__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex: 1;
    cursor: pointer;
}
.form-radio__name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.form-radio__price {
    font-weight: 700;
    white-space: nowrap;
    color: var(--cart-accent);
}
.form-radio__img {
    width: 80px;
    height: 25px;
    object-fit: contain;
    object-position: left;
    flex-shrink: 0;
    display: block;
    margin-left: auto;
}
.fp-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}
.fp-badge--surcharge {
    background: #fff3e0;
    color: #e65100;
}
.fp-badge--discount {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ── Notice / Success ─────────────────────────────────────────── */
.form-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #f9f9f7;
    border: 1px solid #ececec;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 8px 0;
    font-size: 0.875rem;
    color: #4b5563;
    line-height: 1.4;
}
.form-notice .material-symbols-rounded {
    font-size: 1.15rem;
    color: var(--cart-muted);
    flex-shrink: 0;
    margin-top: 1px;
}
.form-success {
    background-color: #c9ebb9;
    display: inline-block;
    padding: 10px 15px;
    margin-bottom: 15px;
    color: #52a12b;
    width: 100%;
    text-align: center;
    border-radius: 8px;
}

/* ── Details / Accordion ──────────────────────────────────────── */
.form-details {}
.form-details summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.form-details summary::-webkit-details-marker { display: none; }
.form-details summary::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid #6b7280;
    border-bottom: 2px solid #6b7280;
    transform: rotate(-45deg);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.form-details[open] summary::after {
    transform: rotate(45deg);
}

/* ── Collapsible ──────────────────────────────────────────────── */
.form-collapsible {
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.3s ease;
}


/* ══════════════════════════════════════════════════════════════
   Login popup
   ══════════════════════════════════════════════════════════════ */
.login-popup {
    overflow: hidden;
    font-size: 14px;
    width: 90%;
    background: white;
    padding: 24px;
    margin: 0 auto;
    max-width: 440px;
    border-radius: 12px;
    position: relative;
}
.login-popup h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 16px;
    margin: 0 0 24px;
}
.login-popup__fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}
.login-popup__fields input {
    /* #d1d5db dona ~1.4:1, cal 3:1 en el contorn d'un camp (1.4.11) */
    border: 1px solid #8a8f98;
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 0.95rem;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.login-popup__fields input:focus { border-color: #111; }
.login-popup__fields input:focus-visible { outline: 2px solid #111; outline-offset: 1px; }

.login-popup__form.hide {
    display: none;
}

/* Slide transitions (login ↔ recovery) */
.login-popup__form {
    transition: transform 0.4s ease, opacity 0.35s ease;
    transform: translate(0);
    opacity: 1;
}
.login-popup__form.slide-out {
    transform: translate(-40px, 0);
    opacity: 0;
    pointer-events: none;
}
.login-popup__form--recovery {
    transition: transform 0.4s ease, opacity 0.35s ease;
    position: absolute;
    top: 0;
    left: 0;
    padding: 24px;
    transform: translate(40px, 0);
    opacity: 0;
    width: 100%;
    box-sizing: border-box;
    pointer-events: none;
}
.login-popup__form--recovery.active {
    transform: translate(0, 0);
    opacity: 1;
    pointer-events: auto;
}

.login-popup__msg {
    padding: 10px;
    border-radius: var(--cart-radius);
    margin-bottom: 12px;
    font-size: 14px;
}
.login-popup__msg--error {
    background: #fef2f2;
    color: var(--cart-danger);
}
.login-popup__msg--success {
    background: #f0fdf4;
    color: var(--cart-success);
}
.login-popup__msg--info {
    background: #f0f9ff;
    color: #0369a1;
}

.login-popup__actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}
.login-popup__actions .btn-primary {
    width: 100%;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.login-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--cart-muted);
    padding: 4px;
    line-height: 1;
    transition: color 0.15s;
}
.login-popup__close:hover { color: var(--cart-accent); }


/* ══════════════════════════════════════════════════════════════
   Mobile footer (hidden on desktop)
   ══════════════════════════════════════════════════════════════ */
.checkout__mobile-footer { display: none; }

/* Progress bar: hidden on desktop */
.checkout__progress { display: none; }

/* Summary toggle button: hidden on desktop */
.checkout__topbar-resum { display: none; }


/* ══════════════════════════════════════════════════════════════
   Responsive: mobile (<=900px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    body.page-checkout {
        height: auto;
        overflow: auto;
    }

    /* ── Progress bar: fixed top ──────────────────────────────── */
    .checkout__progress {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        margin: 0;
        padding: 0;
        background: transparent;
        z-index: 200;
        pointer-events: none;
    }
    .checkout__progress-bar {
        height: 100%;
        width: 0%;
        background: var(--cart-accent);
        transition: width 0.12s linear;
        border-radius: 999px;
    }

    /* ── Single column layout ─────────────────────────────────── */
    .checkout {
        display: block;
        min-height: auto;
    }
    .checkout__layout {
        display: flex;
        flex-direction: column;
        min-height: auto;
    }

    /* ── Order: topbar(1) → right/summary(2) → left/form(3) ── */
    .checkout__layout > .checkout__topbar { order: 1; }
    .checkout__right { order: 2; }
    .checkout__left { order: 3; }

    /* ── Topbar: simplified ───────────────────────────────────── */
    .checkout__topbar,
    .checkout__layout > .checkout__topbar {
        position: relative;
        top: auto;
        z-index: auto;
        background: #fff;
        padding: 12px 16px;
        padding-left: 16px;
        max-width: 100%;
        margin-left: 0;
        border-bottom: 1px solid #ececec;
        justify-content: space-between;
        flex-wrap: nowrap;
    }
    .checkout__logo {
        position: static !important;
        transform: none !important;
    }
    .checkout__logo img { height: 28px; }
    .checkout__cart-link { font-size: 0; }
    .checkout__cart-link .material-symbols-rounded { font-size: 1.4rem; }

    /* Summary toggle */
    .checkout__topbar-resum {
        display: flex;
        align-items: center;
        gap: 6px;
        background: none;
        border: none;
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        color: #111;
        padding: 4px 8px;
    }
    .checkout__topbar-resum-arrow {
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }
    .checkout__topbar-resum.open .checkout__topbar-resum-arrow {
        transform: rotate(180deg);
    }

    /* ── Right column: collapsible, in-flow ───────────────────── */
    .checkout__right {
        grid-column: auto;
        grid-row: auto;
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        z-index: auto;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease;
        background: var(--cart-cream, #faf9f7);
        border-left: none;
        border-bottom: 1px solid #ececec;
        width: 100%;
        height: auto;
    }
    .checkout__right.open {
        max-height: 2000px;
        overflow-y: visible;
    }
    .checkout__right h2 {
        max-width: 100%;
        padding: 16px 16px 8px;
    }
    #section-cart-summary {
        max-width: 100%;
        padding: 0 16px 16px;
    }
    .checkout__right-items {
        max-height: none;
    }

    /* ── Left column ──────────────────────────────────────────── */
    .checkout__left {
        padding-top: 0;
        overflow-y: visible;
        height: auto;
        width: 100%;
    }
    .checkout__left-inner {
        padding: 16px;
        max-width: 100%;
        margin-left: 0;
        margin-bottom: 80px;
    }

    /* Hide desktop pay button, show mobile footer instead */
    .checkout__pay-btn--desktop { display: none !important; }

    /* ── Sticky footer: total + pay button ────────────────────── */
    .checkout__mobile-footer {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 95;
        background: #fff;
        border-top: 1px solid #ececec;
        padding: 12px 16px;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.06);
    }
    .checkout__mobile-total {
        display: flex;
        flex-direction: column;
        line-height: 1.1;
        min-width: 0;
    }
    .checkout__mobile-total-amount {
        font-weight: 700;
        font-size: 1.25rem;
        color: #111;
        white-space: nowrap;
    }
    .checkout__mobile-total-note {
        font-size: 0.7rem;
        color: var(--cart-muted);
        margin-top: 2px;
    }
    .checkout__mobile-btn {
        flex: 1 1 auto;
        max-width: 60%;
        margin-top: 0 !important;
    }

    /* ── Form layout: single column on mobile ─────────────────── */
    .form-row {
        grid-template-columns: 1fr;
    }
    .form-row--thirds {
        grid-template-columns: 1fr;
    }

    /* ── Form sections: tighter spacing ───────────────────────── */
    .checkout__section {
        padding: 16px 0;
    }

    /* ── Checkboxes: better wrapping ──────────────────────────── */
    .form-check {
        font-size: 13px;
    }
    .form-check label {
        line-height: 1.4;
    }

    /* ── Payment radios: full width ───────────────────────────── */
    .form-radio {
        padding: 10px 4px;
    }
    .form-radio__name {
        white-space: normal;
        font-size: 13px;
    }
    .form-radio__img {
        width: 60px;
        height: 22px;
    }

    /* ── Form details / accordion ─────────────────────────────── */
    .form-section__title {
        font-size: 15px;
    }
}

/* ── Recovery page (/recovery) ───────────────────────────────── */
.checkout__recovery { display: flex; flex-direction: column; align-items: center; }
.checkout__recovery .checkout__recovery-logo { position: static; transform: none; margin-bottom: 24px; }
.checkout__recovery .login-popup { width: 100%; }
.checkout__recovery .login-popup__close { display: none; }
