/* ==========================================================================
   Tienda Online - Checkout y Mis pedidos
   Extiende las variables definidas en main.css (:root)
   ========================================================================== */

.checkout-title {
    font-size: 1.9rem;
    margin: 0 0 20px;
}

/* --------------------------------------------------------------------------
   Layout: pasos + resumen sticky (2 columnas, 1 en móvil)
   -------------------------------------------------------------------------- */
.checkout-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 28px;
    align-items: start;
}

.checkout-main {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.checkout-aside {
    position: sticky;
    top: 88px;
}

/* --------------------------------------------------------------------------
   Paso
   -------------------------------------------------------------------------- */
.checkout-step {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px 22px;
}

.checkout-step-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.checkout-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    flex: none;
}

.checkout-step-head h2 {
    font-size: 1.1rem;
    margin: 0;
}

.checkout-step-note {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0 0 12px;
}

/* --------------------------------------------------------------------------
   Opciones (dirección / envío / pago)
   -------------------------------------------------------------------------- */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.option-card:hover {
    border-color: var(--primary);
    background: #f8fafc;
}

.option-card:has(input:checked) {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 1px var(--primary) inset;
}

.option-card input[type="radio"] {
    margin-top: 4px;
    flex: none;
}

.option-card-body {
    min-width: 0;
}

.option-card-title {
    font-weight: 600;
    margin: 0 0 2px;
}

.option-card-meta {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-line;
}

.option-card-price {
    margin-left: auto;
    font-weight: 700;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Cupón
   -------------------------------------------------------------------------- */
.coupon-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.coupon-row input {
    flex: 1;
}

.coupon-applied {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border: 1px dashed var(--success);
    background: #f0fdf4;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.coupon-applied strong {
    color: var(--success);
}

/* --------------------------------------------------------------------------
   Resumen (aside)
   -------------------------------------------------------------------------- */
.checkout-summary {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px;
}

.checkout-summary h2 {
    font-size: 1.15rem;
    margin: 0 0 16px;
}

.checkout-items {
    list-style: none;
    margin: 0 0 14px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkout-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
}

.checkout-item-name {
    color: var(--dark);
    min-width: 0;
}

.checkout-item-qty {
    color: var(--muted);
}

.checkout-item-total {
    font-weight: 600;
    white-space: nowrap;
}

.checkout-totals {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.checkout-total-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.95rem;
}

.checkout-total-row .is-free {
    color: var(--success);
    font-weight: 600;
}

.checkout-total-grand {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    font-size: 1.05rem;
}

.checkout-total-grand strong {
    font-size: 1.35rem;
}

.checkout-errors {
    margin-bottom: 14px;
}

.checkout-errors ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

/* --------------------------------------------------------------------------
   Confirmación y pago
   -------------------------------------------------------------------------- */
.checkout-confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 999px;
    background: #dcfce7;
    color: var(--success);
    font-size: 2rem;
    margin-bottom: 10px;
}

.bank-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.bank-box dl {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
}

.bank-box dt {
    color: var(--muted);
    font-size: 0.85rem;
}

.bank-box dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.bank-instructions {
    white-space: pre-line;
    color: #475569;
    line-height: 1.55;
    margin: 12px 0 0;
}

/* --------------------------------------------------------------------------
   Pedidos (Mis pedidos)
   -------------------------------------------------------------------------- */
.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.orders-table th,
.orders-table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.orders-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.orders-table tbody tr:hover {
    background: #f8fafc;
}

.orders-table .order-number {
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
}

.order-detail-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.order-meta {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
}

.order-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.order-info-block h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin: 0 0 6px;
}

.order-info-block p {
    margin: 0;
    white-space: pre-line;
    line-height: 1.5;
}

.order-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.order-items-table th,
.order-items-table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}

.order-items-table td.is-num,
.order-items-table th.is-num {
    text-align: right;
    white-space: nowrap;
}

.order-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 320px;
    margin-left: auto;
}

.order-summary .checkout-total-row {
    font-size: 0.92rem;
}

/* --------------------------------------------------------------------------
   Timeline de estados
   -------------------------------------------------------------------------- */
.order-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.order-timeline li {
    position: relative;
    padding: 0 0 16px 22px;
    border-left: 2px solid var(--border);
}

.order-timeline li:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.order-timeline li::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--primary);
    border: 2px solid var(--white);
}

.order-timeline .timeline-date {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 2px;
}

.order-timeline .timeline-reason {
    font-size: 0.85rem;
    color: #475569;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .checkout-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .checkout-aside {
        position: static;
    }
}

@media (max-width: 640px) {
    .orders-table thead {
        display: none;
    }

    .orders-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 8px 12px;
    }

    .orders-table td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        border-bottom: 0;
        padding: 6px 0;
    }

    .orders-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        font-size: 0.8rem;
    }
}
