/* ============================================================
   CHECKOUT — Estilos específicos de la página de carrito/pago
   Depende de global.css (tokens, .container, fuentes)
============================================================ */

/* Variables adicionales no presentes en global.css */
:root {
    --co-success: #2E7D32;
    --co-error:   #D32F2F;
    --co-bg:      #F5F5F7;
}

/* Fondo de página */
.checkout-wrap,
.progress-wrapper {
    background: transparent;
}

body.page-template-page-checkout-php {
    background: var(--co-bg);
    padding-bottom: 60px;
}

/* ---- PROGRESS BAR ---- */
.progress-wrapper {
    padding: 28px 0;
    max-width: 580px;
    margin: 0 auto;
}

.co-progress-bar {
    display: flex;
    justify-content: space-between;
    position: relative;
}

.co-progress-bar::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--line);
    z-index: 1;
}

.co-progress-line {
    position: absolute;
    top: 12px;
    left: 10%;
    height: 2px;
    background: var(--primary);
    z-index: 2;
    transition: width .4s ease;
    width: 0%;
}

.co-step {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.co-step-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-soft);
    transition: all .2s ease;
}

.co-step.active   .co-step-circle { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px var(--bg-alt); }
.co-step.completed .co-step-circle { background: var(--primary); border-color: var(--primary); color: #fff; }

.co-step-label { font-size: .78rem; font-weight: 500; color: var(--text-soft); }
.co-step.active .co-step-label { color: var(--primary); font-weight: 600; }

/* ---- ESTADOS (app state machine) ---- */
.app-state { display: none; animation: coFadeIn .35s ease; }
.app-state.active { display: block; }

@keyframes coFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- LAYOUT 2 COLUMNAS ---- */
.co-layout {
    display: grid;
    grid-template-columns: 1.8fr 1fr;
    gap: 40px;
    align-items: start;
}

/* ---- TARJETAS ---- */
.co-card {
    background: #fff;
    border-radius: var(--r-card);
    padding: 24px;
    box-shadow: 0 2px 6px rgba(0,0,0,.04);
    border: 1px solid #EAEAEA;
}

.co-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid #F0F0F0;
}

.co-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Nunito', sans-serif;
    margin: 0;
}

.co-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-alt);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---- ITEMS DE CARRITO ---- */
.cart-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }

.cart-item {
    display: flex;
    gap: 20px;
    padding: 18px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--line);
    position: relative;
}

.item-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    flex-shrink: 0;
    object-fit: cover;
}

.item-details { flex: 1; min-width: 0; }

.item-title { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }

.pills-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }

.mini-pill {
    font-size: .73rem;
    padding: 2px 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--text-soft);
    font-weight: 500;
}

.item-dedication {
    font-size: .83rem;
    color: var(--text-soft);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

.item-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    min-width: 100px;
}

.item-price { font-size: 1.15rem; font-weight: 800; color: var(--primary); }

.qty-selector {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: var(--r-pill);
    border: 1px solid var(--line);
    overflow: hidden;
}

.qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: background .15s;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

.qty-btn:hover { background: #e0e0e0; }

.qty-val { width: 30px; text-align: center; font-size: .9rem; font-weight: 600; }

.btn-remove {
    position: absolute;
    top: 14px;
    right: 14px;
    color: #aaa;
    font-size: 1.2rem;
    transition: color .15s;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    line-height: 1;
}

.btn-remove:hover { color: var(--co-error); }

.back-link {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: var(--text-soft);
    font-size: .9rem;
    margin-top: 14px;
    transition: color .15s;
    text-decoration: none;
}

.back-link:hover { color: var(--primary); }

/* ---- CUPÓN ---- */
.coupon-box {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.coupon-label { font-size: .88rem; font-weight: 600; margin-bottom: 8px; display: block; }

.coupon-input-group { display: flex; gap: 8px; }

.coupon-input {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
}

.coupon-input:focus { border-color: var(--primary); outline: none; }

.co-btn-outline {
    padding: 11px 18px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: 8px;
    font-weight: 600;
    font-size: .9rem;
    transition: background .15s;
    cursor: pointer;
    font-family: inherit;
}

.co-btn-outline:hover { background: var(--bg-alt); }

.coupon-msg { font-size: .82rem; margin-top: 6px; display: none; }
.coupon-msg.success { color: var(--co-success); display: block; }
.coupon-msg.error   { color: var(--co-error);   display: block; }

/* ---- SIDEBAR RESUMEN ---- */
.co-sidebar { position: sticky; top: 24px; }

.summary-card {
    background: var(--bg-alt);
    border-radius: var(--r-card);
    padding: 24px;
    border: 1px solid #E6DDF8;
}

.summary-card h2 {
    font-size: 1.2rem;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(124,92,191,.1);
    font-family: 'Nunito', sans-serif;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: .9rem;
    color: var(--text-soft);
}

.summary-row.shipping-free { color: var(--co-success); font-weight: 500; }

.summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px dashed rgba(124,92,191,.3);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
}

.total-price { font-size: 1.5rem; }

/* ---- TRACKER ENVÍO GRATIS ---- */
.free-shipping-tracker {
    margin-bottom: 20px;
    background: #fff;
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--line);
}

.fst-text { font-size: .82rem; font-weight: 600; margin-bottom: 7px; }

.fst-bar-bg {
    width: 100%;
    height: 7px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.fst-bar-fill { height: 100%; background: var(--primary); width: 0%; transition: width .5s ease; }

.fst-success {
    color: var(--co-success);
    font-weight: 700;
    font-size: .85rem;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* ---- BOTÓN PRIMARIO (sobreescribe global para esta página) ---- */
.app-state .btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--r-pill);
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    display: block;
    margin-top: 20px;
    transition: background .2s, transform .2s, box-shadow .2s;
    box-shadow: 0 4px 12px rgba(124,92,191,.2);
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.app-state .btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(124,92,191,.3);
}

.app-state .btn-primary:disabled { background: #b0b0c0; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- BADGES DE CONFIANZA ---- */
.trust-badges-sm { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }

.tb-item { display: flex; align-items: center; gap: 8px; font-size: .83rem; color: var(--text-soft); }
.tb-icon { color: var(--primary); }

.co-payment-icons { display: flex; justify-content: center; gap: 10px; margin-top: 16px; opacity: .6; }
.co-payment-icons span { font-weight: 700; font-size: 11px; }

/* ---- FORMULARIOS ---- */
.checkout-blocks { display: flex; flex-direction: column; gap: 22px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.col-span-2 { grid-column: span 2; }

.input-group { position: relative; margin-bottom: 14px; }

.floating-input {
    width: 100%;
    padding: 19px 14px 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: .95rem;
    color: var(--text);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
}

.floating-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,92,191,.1);
    outline: none;
}

.floating-input.error { border-color: var(--co-error); }
.floating-input.valid { border-color: var(--co-success); }

.floating-label {
    position: absolute;
    left: 14px;
    top: 13px;
    font-size: .9rem;
    color: var(--text-soft);
    pointer-events: none;
    transition: all .2s ease;
    transform-origin: left top;
}

.floating-input:focus ~ .floating-label,
.floating-input:not(:placeholder-shown) ~ .floating-label {
    transform: translateY(-7px) scale(.75);
    color: var(--primary);
}

.floating-input.error ~ .floating-label { color: var(--co-error); }

.error-msg { font-size: .73rem; color: var(--co-error); margin-top: 3px; margin-left: 4px; display: none; }

select.floating-input {
    padding: 13px 14px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666680' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 15px;
}

select.floating-input ~ .floating-label { display: none; }

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
}

.checkbox-group input[type="checkbox"] {
    margin-top: 2px;
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label { font-size: .88rem; cursor: pointer; user-select: none; }
.checkbox-label a { color: var(--primary); text-decoration: underline; }

/* ---- RADIO CARDS (envío/pago) ---- */
.radio-cards { display: grid; gap: 10px; margin-bottom: 16px; }

.radio-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
    background: #fff;
}

.radio-card:hover { border-color: #b0a0d0; background: var(--bg); }

.radio-card input[type="radio"] { width: 17px; height: 17px; accent-color: var(--primary); flex-shrink: 0; }

.radio-card.selected {
    border-color: var(--primary);
    background: var(--bg-alt);
    box-shadow: 0 3px 10px rgba(124,92,191,.08);
}

.rc-content { flex: 1; }
.rc-title { font-weight: 600; font-size: .95rem; display: flex; align-items: center; gap: 7px; }
.rc-desc  { font-size: .82rem; color: var(--text-soft); margin-top: 2px; }
.rc-price { font-weight: 700; font-size: .95rem; }

.rc-badge {
    font-size: .68rem;
    background: var(--secondary);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ---- TARJETA REGALO ---- */
.gift-box {
    display: none;
    margin-top: 14px;
    padding: 14px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px dashed var(--line);
}

.gift-box.visible { display: block; animation: coFadeIn .3s ease; }

.gift-preview {
    background: #fff;
    padding: 18px;
    text-align: center;
    border-radius: 8px;
    font-family: 'Nunito', sans-serif;
    font-style: italic;
    color: var(--primary);
    box-shadow: 0 2px 6px rgba(0,0,0,.04);
    margin-top: 10px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
}

/* ---- FORMULARIO TARJETA (simulado) ---- */
.card-form { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.card-form.visible { display: block; animation: coFadeIn .3s ease; }

/* ---- ESTADO CONFIRMACIÓN ---- */
.success-box {
    text-align: center;
    max-width: 580px;
    margin: 56px auto;
    padding: 40px;
    background: #fff;
    border-radius: var(--r-card);
    box-shadow: 0 2px 6px rgba(0,0,0,.04);
    border: 1px solid var(--line);
}

.success-icon {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #E8F5E9;
    color: var(--co-success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 22px;
}

.success-box h1 { font-size: 2rem; margin-bottom: 8px; }
.order-number { font-size: 1rem; color: var(--text-soft); margin-bottom: 28px; }

.timeline {
    text-align: left;
    background: var(--bg);
    padding: 22px;
    border-radius: 10px;
    margin-bottom: 28px;
}

.tl-item {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
    position: relative;
}

.tl-item:last-child { margin-bottom: 0; }

.tl-item::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 24px;
    bottom: -18px;
    width: 2px;
    background: #e0e0e0;
}

.tl-item:last-child::before { display: none; }

.tl-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    font-size: 11px;
    flex-shrink: 0;
}

.tl-item.done .tl-icon  { background: var(--co-success); border-color: var(--co-success); color: #fff; }
.tl-item.done::before   { background: var(--co-success); }

.tl-content { padding-top: 2px; }
.tl-title { font-weight: 600; font-size: .9rem; }
.tl-desc  { font-size: .83rem; color: var(--text-soft); }

.btn-group { display: flex; gap: 14px; justify-content: center; margin-bottom: 20px; flex-wrap: wrap; }

.co-btn-sec {
    padding: 13px 22px;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: var(--r-pill);
    font-weight: 700;
    font-size: .9rem;
    transition: background .15s;
    cursor: pointer;
    background: none;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
}

.co-btn-sec:hover { background: var(--bg-alt); }

/* ---- MINI CARRITO (sidebar checkout) ---- */
.mini-cart-item {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0,0,0,.05);
}

.mini-img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; }
.mini-details { flex: 1; }
.mini-title { font-size: .88rem; font-weight: 600; line-height: 1.2; margin-bottom: 4px; }
.mini-price { font-size: .88rem; font-weight: 700; color: var(--primary); }

.edit-cart-link {
    display: inline-block;
    font-size: .83rem;
    color: var(--primary);
    font-weight: 600;
    margin-top: 14px;
    text-decoration: underline;
    cursor: pointer;
}

/* ---- MOBILE TOGGLE RESUMEN ---- */
.mobile-summary-toggle { display: none; }

/* ---- RESPONSIVE ---- */
@media (max-width: 992px) {
    .co-layout { grid-template-columns: 1fr; gap: 22px; }
    .co-sidebar { position: static; }
    .order-2-mobile { order: 2; }
    .order-1-mobile { order: 1; }

    .mobile-summary-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 20px;
        background: var(--bg-alt);
        border-bottom: 1px solid var(--line);
        font-weight: 600;
        cursor: pointer;
        color: var(--primary);
        font-size: .95rem;
    }

    .desktop-summary { display: none; }
    .desktop-summary.expanded { display: block; }
}

@media (min-width: 993px) {
    .mobile-summary-toggle { display: none !important; }
    .desktop-summary { display: block !important; }
}

@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
    .col-span-2 { grid-column: span 1; }
    .cart-item { flex-direction: column; }
    .item-controls { flex-direction: row; align-items: center; width: 100%; margin-top: 10px; }
    .co-step-label { display: none; }
}

/* ---- Selector de provincia ---- */
.floating-label-static {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 6px;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.co-select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: border-color .2s;
}

.co-select:focus {
    outline: none;
    border-color: var(--primary);
}
