/* ==========================================================================
   checkout.css — progreso de compra compartido (carrito, envío y pago)
   Incluye el stepper de 3 pasos, el aviso de envío gratis del carrito y
   utilidades de accesibilidad usadas por el partial.
   ========================================================================== */

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   Stepper: 1 Carrito · 2 Envío · 3 Pago
   -------------------------------------------------------------------------- */

.checkout-steps {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0 0 20px;
    padding: 16px 22px;
    background-color: #ffffff;
    border: 1px solid #e6edf3;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.checkout-step {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: #64748b;
}

.checkout-step a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.checkout-step a:hover,
.checkout-step a:focus-visible {
    color: #0284c7;
}

.checkout-step__number {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    background-color: #f1f5f9;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* línea conectora entre pasos */
.checkout-step:not(:last-child)::after {
    content: '';
    flex: 1 1 auto;
    height: 2px;
    margin: 0 14px;
    border-radius: 2px;
    background-color: #e2e8f0;
}

.checkout-step.is-active {
    color: #0f172a;
}

.checkout-step.is-active .checkout-step__number {
    border-color: #0ea5e9;
    background-color: #0ea5e9;
    color: #ffffff;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.14);
}

.checkout-step.is-complete {
    color: #15803d;
}

.checkout-step.is-complete .checkout-step__number {
    border-color: #16a34a;
    background-color: #16a34a;
    color: #ffffff;
}

.checkout-step.is-complete:not(:last-child)::after {
    background-color: #bbf7d0;
}

.checkout-step.is-pending {
    color: #94a3b8;
}

/* --------------------------------------------------------------------------
   Aviso de envío gratis (solo carrito)
   -------------------------------------------------------------------------- */

.free-shipping-notice {
    margin: 0 0 16px;
    padding: 14px 16px;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    background-color: #f0f9ff;
    color: #0c4a6e;
}

.free-shipping-notice p {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.5;
}

.free-shipping-notice p:last-child {
    margin-bottom: 0;
}

.free-shipping-notice strong {
    color: #0369a1;
    font-weight: 700;
}

.free-shipping-progress {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background-color: #e0f2fe;
}

.free-shipping-progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background-image: linear-gradient(90deg, #0ea5e9, #38bdf8);
    transition: width 0.35s ease;
}

.free-shipping-notice.is-reached {
    border-color: #bbf7d0;
    background-color: #f0fdf4;
    color: #166534;
}

.free-shipping-notice.is-reached strong {
    color: #15803d;
}

.free-shipping-notice.is-reached .free-shipping-progress {
    background-color: #dcfce7;
}

.free-shipping-notice.is-reached .free-shipping-progress > span {
    background-image: linear-gradient(90deg, #16a34a, #22c55e);
}

.checkout-shipping-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    font-size: 13px;
    line-height: 1.5;
    color: #64748b;
}

.checkout-shipping-note::before {
    content: '\f0d1';
    flex: none;
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    color: #0ea5e9;
}

/* --------------------------------------------------------------------------
   Responsive: en pantallas pequeñas se oculta la línea conectora
   -------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
    .checkout-steps {
        padding: 13px 14px;
    }

    .checkout-step {
        gap: 7px;
        font-size: 12.5px;
    }

    .checkout-step a {
        gap: 7px;
    }

    .checkout-step__number {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }

    .checkout-step:not(:last-child)::after {
        display: none;
    }

    .free-shipping-notice {
        padding: 12px 14px;
    }

    .free-shipping-notice p {
        font-size: 13.5px;
    }
}

@media (max-width: 400px) {
    .checkout-step {
        font-size: 11.5px;
    }
}

/* --------------------------------------------------------------------------
   Paso 2: layout, panel de dirección y resumen
   -------------------------------------------------------------------------- */

.checkout-panel {
    padding: 22px;
}

.checkout-panel__header {
    margin-bottom: 18px;
}

.checkout-panel__subtitle {
    font-size: 14px;
    line-height: 1.5;
}

.checkout-panel__action {
    white-space: nowrap;
}

.checkout-panel__note {
    margin: 18px 0 0;
    font-size: 13px;
    line-height: 1.55;
}

.checkout-empty-state {
    padding: 30px 20px;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    background-color: #f8fafc;
}

.checkout-empty-state i {
    display: block;
    margin-bottom: 10px;
    color: #0ea5e9;
    font-size: 26px;
}

.checkout-empty-state__hint {
    font-size: 13px;
    line-height: 1.5;
}

.checkout-address-card {
    display: block;
    height: 100%;
    margin-top: 0;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background-color: #ffffff;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.checkout-address-card:hover {
    border-color: #7dd3fc;
}

.checkout-address-card:has(input:checked) {
    border-color: #0ea5e9;
    background-color: #f8fcff;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.checkout-address-card.is-selected {
    border-color: #0ea5e9;
    background-color: #f8fcff;
}

.checkout-address-card .form-check {
    margin: 0 0 10px;
    padding: 5px 5px 5px 30px;
    background-color: #f1f5f9;
}

.checkout-address-card__details {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.checkout-address-card__details li {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 5px;
    color: #475569;
    font-size: 14px;
    line-height: 1.45;
    text-transform: none;
}

.checkout-address-card__details li span {
    flex: none;
    width: 92px;
    color: #0b2c3d;
    font-size: 13px;
    font-weight: 600;
}

.checkout-address-card__badge {
    display: inline-flex;
    align-items: center;
    margin: 0 0 10px;
    padding: 5px 10px;
    border-radius: 999px;
    background-color: #dcfce7;
    color: #166534;
    font-size: 12px;
    font-weight: 600;
}

.checkout-address-card__edit {
    margin-top: 14px;
    padding: 6px 14px;
    font-size: 12px;
}

.checkout-address-form__hint {
    margin: 14px 0 0;
    font-size: 12.5px;
    line-height: 1.5;
}

.checkout-summary {
    position: sticky;
    top: 20px;
}

.checkout-summary__title {
    margin: 0 0 16px;
    color: #0b2c3d;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.checkout-summary__totals p {
    font-size: 14px;
}

.checkout-summary__total {
    align-items: baseline;
    padding-top: 4px;
}

.checkout-summary__total span {
    color: #0b2c3d;
    font-size: 20px;
    line-height: 1.2;
}

.checkout-summary__next-step {
    margin: 12px 0 0;
    font-size: 12.5px;
    line-height: 1.5;
}

/* El CTA vive fuera de #checkout_summary_details para que la barra inferior
   móvil muestre siempre el total (toggle) y el botón de compra. */
.checkout-summary__actions {
    margin-top: 4px;
}

.checkout-error {
    margin: 0 0 12px;
    color: #b91c1c;
    font-size: 13.5px;
    line-height: 1.5;
}

.checkout-error:empty {
    display: none;
}

.checkout-error__retry {
    display: inline;
    margin-left: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: #0369a1;
    font-size: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.checkout-error__retry:hover,
.checkout-error__retry:focus-visible {
    color: #075985;
}

.checkout-summary__toggle {
    display: none;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    border: 0;
    border-radius: 14px 14px 0 0;
    background-color: #ffffff;
    color: #0b2c3d;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

/* style.purge.min.css fuerza `button:focus { outline: none !important }`;
   el anillo se dibuja con un box-shadow interior para que no lo recorte
   el scroll del resumen abierto. */
.checkout-summary__toggle:focus-visible {
    outline: none !important;
    box-shadow: inset 0 0 0 3px rgba(14, 165, 233, 0.65) !important;
}

.checkout-summary__toggle-label {
    flex: 1 1 auto;
    color: inherit;
}

.checkout-summary__toggle-total {
    flex: none;
    color: #0b2c3d;
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.checkout-summary__toggle i {
    flex: none;
    color: #64748b;
    font-size: 12px;
    transition: transform 0.2s ease;
}

.checkout-summary.is-open .checkout-summary__toggle i {
    transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   Métodos de envío
   -------------------------------------------------------------------------- */

.checkout-shipping-hint {
    margin: 0 0 8px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

.checkout-shipping-empty {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #fde68a;
    border-radius: 10px;
    background-color: #fffbeb;
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
}

#shipping_methods_container {
    padding-top: 10px;
}

#shipping_methods_container.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.wsus__shipping_option {
    position: relative;
}

/* El radio sigue siendo enfocable con teclado aunque no se vea.
   `display: block` es imprescindible: style.css/style.purge.min.css traen
   `display: none` para este selector y, sin el override, el input no recibe
   foco y el anillo de :focus-visible nunca aparece. */
.wsus__shipping_option input[type="radio"] {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    opacity: 0;
    white-space: nowrap;
    border: 0;
}

.wsus__shipping_option input[type="radio"]:focus-visible + .wsus__shipping_card {
    outline: 3px solid rgba(14, 165, 233, 0.35);
    outline-offset: 2px;
}

.shipping-recommended-badge {
    position: absolute;
    top: -8px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background-color: #dcfce7;
    color: #166534;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.5;
    text-transform: uppercase;
}

.shipping-recommended-badge[hidden] {
    display: none;
}

/* --------------------------------------------------------------------------
   Pago (Task 9): tarjetas de métodos de pago
   -------------------------------------------------------------------------- */

.payment-panel__title {
    margin: 0 0 4px;
    color: #0b2c3d;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

.payment-methods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin: 16px 0 0;
}

/* Con una sola pasarela habilitada la tarjeta no debe estirarse a todo el panel. */
.payment-methods-grid--single {
    grid-template-columns: minmax(0, 1fr);
    max-width: 460px;
}

.payment-method-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background-color: #ffffff;
    color: #0b2c3d;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.payment-method-card:hover {
    border-color: #7dd3fc;
}

.payment-method-card.active,
.payment-method-card.active:hover {
    border-color: #0ea5e9;
    background-color: #f8fcff;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.payment-method-card:focus-visible {
    outline: 3px solid rgba(14, 165, 233, 0.45);
    outline-offset: 2px;
}

.payment-method-card img {
    width: auto;
    max-height: 28px;
}

.payment-method-card__icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background-color: #f1f5f9;
    color: #0ea5e9;
    font-size: 17px;
}

.payment-method-card.active .payment-method-card__icon {
    background-color: #e0f2fe;
    color: #0284c7;
}

.payment-method-card__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.payment-method-card__label {
    color: #0b2c3d;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.payment-method-card__description {
    color: #64748b;
    font-size: 12.5px;
    line-height: 1.4;
}

.payment-method-card__brands {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
    margin-top: 6px;
}

.payment-method-card__brands img {
    display: block;
    width: 32px;
    height: 20px;
    max-height: 20px;
    border-radius: 3px;
}

.payment-methods-content {
    margin-top: 20px;
    padding-top: 22px;
    border-top: 1px solid #e6edf3;
}

.payment-brands {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}

.payment-brands img {
    display: block;
    width: 38px;
    height: 24px;
    border-radius: 3px;
}

.payment-empty-state {
    margin: 0;
}

.payment-summary {
    position: sticky;
    top: 20px;
}

.payment-summary p {
    text-transform: none;
}

.payment-summary h5 {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e6edf3;
    color: #0b2c3d;
    font-size: 18px;
    font-weight: 700;
}

.payment-summary h6 {
    border-top: 1px solid #e6edf3;
    text-transform: none;
}

.payment-summary__ship {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #eef2f6;
}

.payment-summary p.payment-summary__ship-title {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 0 0 6px;
    color: #0b2c3d;
    font-size: 13px;
    font-weight: 700;
}

.payment-summary__ship-title i {
    color: #0ea5e9;
}

.payment-summary p.payment-summary__ship-detail {
    display: block;
    margin: 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.55;
}

.payment-summary__ship-detail strong {
    color: #0b2c3d;
    font-weight: 600;
}

.payment-summary__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 18px;
    color: #0369a1;
    font-size: 13px;
    font-weight: 600;
}

.payment-summary__back:hover,
.payment-summary__back:focus-visible {
    color: #075985;
    text-decoration: underline;
    text-underline-offset: 2px;
}

@media (max-width: 991.98px) {
    .payment-summary {
        position: static;
        margin-top: 24px;
    }
}

/* --------------------------------------------------------------------------
   Responsive: resumen colapsable y sticky inferior
   -------------------------------------------------------------------------- */

@media (max-width: 991.98px) {
    .checkout-panel {
        padding: 18px;
    }

    .checkout-layout {
        padding-bottom: 72px;
    }

    /* La columna es el elemento sticky: así el resumen se pega al borde
       inferior de la ventana mientras se recorre el formulario. */
    .checkout-layout > .col-xl-4 {
        position: sticky;
        bottom: 0;
        z-index: 1020;
    }

    .checkout-summary {
        position: static;
        margin-top: 24px;
        padding: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.14);
    }

    .checkout-summary__toggle {
        display: flex;
        border-radius: 16px 16px 0 0;
    }

    .checkout-summary__details {
        display: none;
        padding: 0 18px;
    }

    /* CTA y error siempre visibles: no dependen de .is-open. */
    .checkout-summary__actions {
        margin-top: 0;
        padding: 14px 18px 18px;
    }

    /* Con el resumen abierto el CTA continúa el flujo del contenido. */
    .checkout-summary.is-open .checkout-summary__actions {
        padding-top: 0;
    }

    /* La barra colapsada prioriza total + CTA; la nota se lee al expandir. */
    .checkout-summary:not(.is-open) .checkout-summary__next-step {
        display: none;
    }

    .checkout-summary.is-open .checkout-summary__details {
        display: block;
    }

    .checkout-summary.is-open {
        max-height: calc(100vh - 16px);
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 16px 16px 0 0;
    }

    .checkout-address-card__details li {
        flex-wrap: wrap;
        gap: 2px 8px;
    }

    .checkout-address-card__details li span {
        width: 100%;
    }
}

@media (min-width: 992px) {
    .checkout-summary {
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .checkout-summary__details {
        display: block;
    }
}

@media (prefers-reduced-motion: reduce) {
    .checkout-step a,
    .checkout-step__number,
    .free-shipping-progress > span,
    .checkout-address-card,
    .checkout-summary__toggle i,
    .wsus__shipping_card,
    .payment-method-card {
        transition: none;
    }
}
