/* --- ESTILOS COMPLETOS Y AUTÓNOMOS PARA EL MODAL DE COMPRA --- */

/* 1. CONFIGURACIÓN BASE Y VARIABLES */
:root {
    --pm-primary: #E11D48;
    --pm-success: #10b981; /* Verde para éxito */
    --pm-bg: #ffffff;
    --pm-text: #1a1a1a;
    --pm-border: #e5e5e5;
    --pm-muted: #666666;
    --pm-accent: #f9fafb;
    --pm-radius: 0.75rem;
}

html.dark {
    --pm-bg: #1f1f1f;
    --pm-text: #ffffff;
    --pm-border: #383838;
    --pm-muted: #a3a3a3;
    --pm-accent: #2a2a2a;
}

/* 2. OVERLAY Y CONTENEDOR PRINCIPAL */
#purchase-modal.modal-overlay,
#confirmation-modal.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#purchase-modal[style*="display: flex"],
#confirmation-modal[style*="display: flex"] {
    opacity: 1;
    pointer-events: auto;
}

#purchase-modal .modal-content {
    background-color: var(--pm-bg);
    color: var(--pm-text);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: pmSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'Poppins', sans-serif;
    padding: 2rem;
    box-sizing: border-box;
}

@keyframes pmSlideUp {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* 3. BOTÓN DE CERRAR */
#purchase-modal .close-purchase-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0,0,0,0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--pm-muted);
    transition: all 0.2s;
    z-index: 20;
    font-size: 1.2rem;
}
html.dark #purchase-modal .close-purchase-btn { background: rgba(255,255,255,0.1); }
#purchase-modal .close-purchase-btn:hover {
    background-color: var(--pm-primary);
    color: white;
    transform: rotate(90deg);
}

/* 4. UTILIDADES DE LAYOUT */
#purchase-modal .flex { display: flex; }
#purchase-modal .justify-between { justify-content: space-between; }
#purchase-modal .items-center { align-items: center; }
#purchase-modal .text-center { text-align: center; }
#purchase-modal .hidden { display: none; }
#purchase-modal .mb-4 { margin-bottom: 1rem; }
#purchase-modal .mr-1 { margin-right: 0.25rem; }
#purchase-modal .mr-2 { margin-right: 0.5rem; }
#purchase-modal .mt-2 { margin-top: 0.5rem; }
#purchase-modal .pt-2 { padding-top: 0.5rem; }
#purchase-modal .space-y-4 > * + * { margin-top: 1rem; }
#purchase-modal .space-y-2 > * + * { margin-top: 0.5rem; }

/* 5. TIPOGRAFÍA */
#purchase-modal h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.5rem; color: var(--pm-text); line-height: 1.2; }
#purchase-modal .font-bold { font-weight: 700; }
#purchase-modal .font-semibold { font-weight: 600; }
#purchase-modal .text-xl { font-size: 1.25rem; }
#purchase-modal .text-2xl { font-size: 1.5rem; }
#purchase-modal .text-lg { font-size: 1.125rem; }
#purchase-modal .text-primary { color: var(--pm-primary); }

/* 6. COMPONENTES ESPECÍFICOS */
#purchase-modal .product-showcase { background-color: var(--pm-accent); border: 1px solid var(--pm-border); border-radius: var(--pm-radius); padding: 1rem; margin-bottom: 1.5rem; position: relative; }
#purchase-modal .product-header-row { display: flex; align-items: center; gap: 1rem; }
#purchase-modal .product-img-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 0.5rem; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
#purchase-modal .product-title-info { flex: 1; }
#purchase-modal .product-title-info h3 { display: flex; align-items: center; font-size: 1.1rem; font-weight: 700; margin: 0 0 0.25rem 0; line-height: 1.2; }
#purchase-modal .product-title-info .product-desc { font-size: 0.85rem; color: var(--pm-muted); margin: 0.25rem 0 0 0; }
#purchase-modal .product-price-display { text-align: right; }
#purchase-modal .price-label { font-size: 0.8rem; color: var(--pm-muted); display: block; }
#purchase-modal .price-value { font-size: 1.5rem; font-weight: 800; color: var(--pm-primary); display: block; line-height: 1; }
#purchase-modal .input-group { margin-bottom: 1rem; }
#purchase-modal .input-group label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--pm-text); }
#purchase-modal .input-group input { width: 100%; padding: 0.8rem 1rem; border: 1px solid var(--pm-border); border-radius: var(--pm-radius); font-size: 1rem; background-color: var(--pm-bg); color: var(--pm-text); box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s; }
#purchase-modal .input-group input:focus { outline: none; border-color: var(--pm-primary); box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15); }
#purchase-modal .upsell-container { display: flex; align-items: center; gap: 1rem; background-color: rgba(225, 29, 72, 0.05); border: 1px solid rgba(225, 29, 72, 0.2); border-radius: var(--pm-radius); padding: 0.75rem; margin-top: 1.5rem; cursor: pointer; transition: background-color 0.2s; }
#purchase-modal .upsell-check-wrapper { padding: 0.5rem; }
#purchase-modal #upsell-checkbox { display: none; } /* Ocultar el checkbox nativo */
#purchase-modal .upsell-image { width: 48px; height: 48px; object-fit: cover; border-radius: 0.375rem; }
#purchase-modal .upsell-content { flex: 1; }
#purchase-modal .upsell-title { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; color: var(--pm-primary); display: flex; align-items: center; }
#purchase-modal .upsell-desc { display: block; font-size: 0.9rem; margin-bottom: 0.5rem; }
#purchase-modal .select-wrapper { position: relative; }
#purchase-modal .upsell-dropdown { width: 100%; padding: 0.5rem; border-radius: 0.375rem; border: 1px solid var(--pm-border); background-color: var(--pm-bg); color: var(--pm-text); font-weight: 600; appearance: none; -webkit-appearance: none; padding-right: 2rem; }
#purchase-modal .select-icon { position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--pm-muted); }

/* Checkbox Personalizado Mejorado */
.custom-checkbox {
    position: relative;
    display: inline-block;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 24px;
    width: 24px;
    background-color: transparent;
    border: 2px solid var(--pm-primary); /* Borde rojo por defecto */
    border-radius: 50%; /* Redondo */
    transition: all 0.2s ease;
}

/* Estado Hover */
.upsell-container:hover .checkmark {
    background-color: rgba(225, 29, 72, 0.1);
}

/* Estado Seleccionado */
#purchase-modal #upsell-checkbox:checked + .checkmark {
    background-color: var(--pm-success); /* Fondo verde */
    border-color: var(--pm-success); /* Borde verde */
}

/* Icono de Check (Palomita) */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 8px;
    top: 4px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

#purchase-modal #upsell-checkbox:checked + .checkmark:after {
    display: block;
}

/* Resumen */
#purchase-modal .order-summary { background-color: var(--pm-accent); border-radius: var(--pm-radius); padding: 1.25rem; margin-top: 1.5rem; border: 1px solid var(--pm-border); }
#purchase-modal .order-summary h4 { font-size: 1rem; font-weight: 700; margin: 0 0 1rem 0; color: var(--pm-text); display: flex; align-items: center; }
#purchase-modal .order-summary .border-t { border-top: 1px solid var(--pm-border); }

/* Info de Pago Centrada */
.payment-info {
    text-align: center;
    margin: 1.5rem 0 0.5rem;
    font-size: 0.9rem;
    color: var(--pm-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.payment-info p {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
}

/* Botón Finalizar */
#purchase-modal .submit-button { width: 100%; background: linear-gradient(135deg, #25D366 0%, #128C7E 100%); color: white; font-weight: 700; font-size: 1.1rem; padding: 1rem; border: none; border-radius: var(--pm-radius); cursor: pointer; margin-top: 1.5rem; display: flex; align-items: center; justify-content: center; gap: 0.5rem; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3); }
#purchase-modal .submit-button:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(37, 211, 102, 0.4); }

/* 8. MODAL DE ÉXITO ELEGANTE */
#confirmation-modal .success-elegant-content { background: none; border: none; box-shadow: none; color: white; text-align: center; padding: 2rem; max-width: 500px; display: flex; flex-direction: column; align-items: center; justify-content: center; animation: pm-fade-in 0.5s ease-out; }
.success-icon-wrapper { font-size: 5rem; color: var(--pm-success); margin-bottom: 1.5rem; line-height: 1; --fa-primary-color: #ffffff; --fa-secondary-color: var(--pm-success); --fa-secondary-opacity: 1; animation: pm-icon-pop 0.6s cubic-bezier(0.25, 0.25, 0.25, 1.25) 0.2s both; }
@keyframes pm-icon-pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-title { font-size: 2rem; font-weight: 700; margin: 0 0 0.5rem 0; }
.success-message { font-size: 1rem; color: rgba(255, 255, 255, 0.8); margin-bottom: 2rem; max-width: 400px; line-height: 1.6; }
.success-elegant-content .btn-close-success { min-width: 200px; border: 3px solid var(--pm-success); color: var(--pm-success); background-color: rgba(255, 255, 255, 0.1); backdrop-filter: blur(5px); padding: 12px 24px; border-radius: 50px; font-weight: 700; font-size: 1rem; transition: all 0.3s ease; cursor: pointer; }
.success-elegant-content .btn-close-success:hover { background-color: var(--pm-success); color: white; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
