/* ===== TP Cupones - Frontend Styles ===== */

/* ── OVERLAY ─────────────────────────────────────────────────────── */
.tp-cupones-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tp-cupones-overlay.tp-cupones-overlay--visible {
    opacity: 1;
}

.tp-cupones-overlay[hidden] {
    display: none !important;
}

/* ── MODAL ───────────────────────────────────────────────────────── */
.tp-cupones-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.tp-cupones-overlay--visible .tp-cupones-modal {
    transform: translateY(0);
}

/* Cerrar */
.tp-cupones-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: background 0.2s, color 0.2s;
    z-index: 1;
}
.tp-cupones-modal__close:hover {
    background: #e5e7eb;
    color: #111;
}

/* Cabecera */
.tp-cupones-modal__head {
    padding: 28px 24px 16px;
    text-align: center;
    border-bottom: 1px solid #f3f4f6;
}
.tp-cupones-modal__emoji {
    font-size: 36px;
    display: block;
    margin-bottom: 8px;
}
.tp-cupones-modal__head h2 {
    font-size: 18px;
    font-weight: 700;
    color: #111;
    margin: 0 0 4px;
}
.tp-cupones-modal__head p {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

/* Lista scrollable */
.tp-cupones-modal__list,
.tp-cupones-modal__detail {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
}

/* Footer */
.tp-cupones-modal__footer {
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    padding: 12px 16px;
    border-top: 1px solid #f3f4f6;
    margin: 0;
}

/* ── ITEM DE CUPÓN ───────────────────────────────────────────────── */
.tp-coupon-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.tp-coupon-item:last-child {
    margin-bottom: 0;
}
.tp-coupon-item:hover {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}
.tp-coupon-item__icon {
    font-size: 28px;
    flex-shrink: 0;
}
.tp-coupon-item__body {
    flex: 1;
    min-width: 0;
}
.tp-coupon-item__title {
    font-weight: 700;
    font-size: 14px;
    color: #111;
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tp-coupon-item__desc {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 6px;
}
.tp-coupon-item__available {
    font-size: 11px;
    color: #6b7280;
}
.tp-coupon-item__see-more {
    font-size: 12px;
    font-weight: 600;
    color: #6366f1;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

/* ── DETALLE ─────────────────────────────────────────────────────── */
.tp-cupones-back {
    background: none;
    border: none;
    font-size: 13px;
    color: #6366f1;
    cursor: pointer;
    padding: 0 0 14px;
    font-weight: 600;
    display: block;
}
.tp-cupones-detail-inner {
    text-align: center;
}
.tp-cupones-detail-inner .tp-detail-emoji {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}
.tp-cupones-detail-inner .tp-detail-badge {
    display: inline-block;
    background: #fce7f3;
    color: #be185d;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
}
.tp-cupones-detail-inner .tp-detail-code {
    font-size: 22px;
    font-weight: 800;
    color: #111;
    letter-spacing: 2px;
    margin: 0 0 8px;
}
.tp-cupones-detail-inner .tp-detail-desc {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 16px;
}
.tp-cupones-available-box {
    background: #f0fdf4;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    color: #166534;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}
.tp-cupones-rules {
    text-align: left;
    margin-bottom: 20px;
}
.tp-cupones-rules h4 {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin: 0 0 8px;
}
.tp-cupones-rules ul {
    list-style: disc;
    padding-left: 18px;
    margin: 0;
}
.tp-cupones-rules ul li {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
}
.tp-copy-btn {
    width: 100%;
    padding: 14px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.tp-copy-btn:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}
.tp-copy-btn:active {
    transform: translateY(0);
}
.tp-copy-btn--copied {
    background: #10b981 !important;
}

.tp-coupon-item__applied {
    font-size: 11px;
    font-weight: 700;
    color: #10b981;
}

.tp-cupones-applied-box {
    background: #f0fdf4;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    color: #166534;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.tp-detail-actions {
    display: flex;
    gap: 10px;
}

.tp-apply-btn {
    flex: 1;
    padding: 14px;
    background: #10b981;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.tp-apply-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}
.tp-apply-btn:active {
    transform: translateY(0);
}
.tp-apply-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.tp-cart-coupons-link .tp-coupon-see-more--cart {
    background: none;
    border: none;
    font-size: 13px;
    color: #6366f1;
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: color 0.2s;
}
.tp-cart-coupons-link .tp-coupon-see-more--cart:hover {
    color: #4f46e5;
}

/* ── BADGE EN PRODUCTO ───────────────────────────────────────────── */
.tp-coupon-badge {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 12px;
    padding: 0;
}

.tp-coupon-badge__label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1d4ed8;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
}
.tp-coupon-badge__label:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

.tp-coupon-badge__checkbox {
    width: 15px;
    height: 15px;
    accent-color: #1d4ed8;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

.tp-coupon-badge__icon {
    flex-shrink: 0;
    color: #1d4ed8;
}

.tp-coupon-badge__discount {
    background: #1d4ed8;
    color: #fff;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.tp-coupon-badge__saving {
    font-size: 12px;
    color: #059669;
    font-weight: 600;
}

.tp-coupon-badge__see-more {
    background: none;
    border: none;
    font-size: 12px;
    color: #6366f1;
    cursor: pointer;
    padding: 0;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: dotted;
}

/* Label cuando está checked (Aplicado o Standby) */
.tp-coupon-badge__label:has(.tp-coupon-badge__checkbox:checked) {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}
.tp-coupon-badge__label:has(.tp-coupon-badge__checkbox:checked) .tp-coupon-badge__icon {
    color: #166534;
}
.tp-coupon-badge__label:has(.tp-coupon-badge__checkbox:checked) .tp-coupon-badge__discount {
    background: #166534;
}

/* Transición suave para el mensaje */
.tp-coupon-badge__saving {
    display: block;
    width: 100%;
    margin-top: 4px;
    font-size: 12px;
    color: #059669;
    font-weight: 600;
    animation: tp-fade-in 0.3s ease forwards;
}

@keyframes tp-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Estilos para las filas de descuento en standby en Checkout/Cart */
.tp-discount-row--standby {
    border-left: 3px solid #059669;
    padding-left: 10px !important;
    background: #f0fdf4;
    margin-top: 5px;
    border-radius: 4px;
}
.tp-discount-row--standby .tp-discount-row__label {
    font-weight: 600;
}

/* ── LOADING / NO COUPONS ────────────────────────────────────────── */
.tp-cupones-loading {
    display: flex;
    justify-content: center;
    padding: 30px 0;
}
.tp-cupones-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: tp-spin 0.7s linear infinite;
    display: block;
}
@keyframes tp-spin { to { transform: rotate(360deg); } }

.tp-cupones-empty {
    text-align: center;
    padding: 30px 16px;
    color: #9ca3af;
    font-size: 14px;
}

/* ── Campo de cupón del mini-carrito (offcanvas) ────────────────────
   Mismo look que "Medios de envío" (order-shipping.css) para consistencia
   visual dentro del mini-carrito. */

.tp-cart-coupon-block {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border, #eee);
}

.tp-cart-coupon-heading {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-muted, #666);
    margin-bottom: 10px;
}

.tp-cart-coupon-heading svg {
    flex-shrink: 0;
}

.tp-cart-coupon-form {
    display: flex;
    gap: 6px;
}

.tp-cart-coupon-input {
    flex: 1;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 7px;
    background: #faf9f7;
    padding: 0 12px;
    height: 38px;
    font-size: 13px;
    color: #1a1a1a;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.tp-cart-coupon-apply-btn {
    border: none;
    background: #1a1a1a;
    color: #fff;
    border-radius: 7px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.tp-cart-coupon-apply-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.tp-cart-coupon-msg {
    font-size: 11px;
    margin: 8px 0 0;
}

.tp-cart-coupon-msg.is-error {
    color: #c0392b;
}

.tp-cart-coupon-msg.is-success {
    color: #2e7d32;
}

/* ── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .tp-cupones-modal {
        border-radius: 12px 12px 0 0;
        max-height: 90vh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
    }
    .tp-cupones-overlay {
        align-items: flex-end;
        padding: 0;
    }
}
