/* Overlay del modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    overflow-y: auto;
}

.modal-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { 
        opacity: 0;
    }
    to { 
        opacity: 1;
    }
}

/* Contenedor del modal */
.modal-container {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    height: auto;
    overflow: visible;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    margin: 20px auto;
    transform: translate3d(0, -20px, 0);
    transition: transform 0.3s cubic-bezier(0.1, 0, 0.7, 1), height 0.5s ease-out;
    font-family: "Poppins", Sans-serif;
}

.modal-overlay.active .modal-container {
    transform: translate3d(0, 0, 0);
}

/* Estado de procesamiento */
.modal-container.processing {
    height: 200px;
    overflow: hidden;
}

.modal-container.processing .modal-header,
.modal-container.processing .modal-content,
.modal-container.processing .guarantee-section {
    display: none;
}

.modal-container.processing .loader-overlay {
    position: relative;
    height: 200px;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Header del modal */
.modal-header {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.modal-header-icon::before {
    content: '🛒';
    font-size: 14px;
}

.modal-title {
    flex: 1;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

/* Contenido del modal */
.modal-content {
    padding: 20px;
}

/* Ofertas */
.offers-section {
    margin-bottom: 20px;
}

.offer-item {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    background: white;
}

.offer-item:hover {
    border-color: #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.offer-item.selected {
    border-color: #ff5722;
    background: #fff5f2;
}

.offer-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.offer-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

.offer-details {
    flex: 1;
}

.offer-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.offer-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    background: #4CAF50;
    margin-top: 4px;
}

.offer-price {
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.offer-original-price {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
    margin-bottom: 4px;
    text-align: right;
}

/* Variaciones dentro de ofertas */
.offer-variations {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.variation-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.variation-number {
    font-size: 18px;
}

.variation-select-offer {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    color: #333;
    background: white;
    transition: border-color 0.3s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.variation-select-offer:focus {
    outline: none;
    border-color: #4CAF50;
}

.variation-select-offer.error {
    border-color: #ff5722;
}

/* Descuento aplicado */
.discount-banner {
    background: #fff9c4;
    border: 1px solid #f9a825;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    display: none;
    animation: fadeIn 0.5s ease;
}

.discount-banner.show {
    display: flex;
    align-items: center;
    gap: 10px;
}

.discount-banner-text {
    flex: 1;
    font-weight: 500;
    color: #f57c00;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.discount-banner.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

/* Totales */
.totals-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.total-row.discount {
    color: #f57c00;
    font-weight: 600;
}

.total-row.main {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    padding-top: 8px;
    border-top: 1px solid #ddd;
    margin-top: 8px;
}

.delivery-info {
    color: #4CAF50;
    font-weight: 600;
}

/* Formulario */
.form-section {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.form-group label .required {
    color: #ff5722;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    color: #333;
    transition: border-color 0.3s;
}

.form-group select {
    background: white;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4CAF50;
}

.form-group input.error,
.form-group select.error {
    border-color: #ff5722;
}

.validation-message {
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.validation-message.show {
    display: block;
}

.validation-message.success {
    color: #0f834d;
}

.validation-message.error {
    color: #a82626;
}

.validation-message.loading {
    color: #666;
}

/* Animación de borde */
@keyframes borderDashMove {
    0% {
        background-position: 0 0, 100% 100%, 0 100%, 100% 0;
    }
    100% {
        background-position: 13px 0, calc(100% - 13px) 100%, 0 calc(100% - 13px), 100% 13px;
    }
}

/* Upsell */
.upsell-section {
    background-color: rgb(250, 250, 250);
    background-image: 
        linear-gradient(90deg, rgb(255, 152, 0) 50%, transparent 50%), 
        linear-gradient(90deg, rgb(255, 152, 0) 50%, transparent 50%), 
        linear-gradient(0deg, rgb(255, 152, 0) 50%, transparent 50%), 
        linear-gradient(0deg, rgb(255, 152, 0) 50%, transparent 50%);
    background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
    background-size: 13px 3px, 13px 3px, 3px 13px, 3px 13px;
    background-position: left top, right bottom, left bottom, right top;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    transition: background-color 0.3s ease;
    animation: borderDashMove 0.5s linear infinite;
}

.upsell-section.selected {
    background-color: linear-gradient(to right, rgb(240, 255, 244), rgb(250, 250, 250));
    background-image: 
        linear-gradient(90deg, rgb(76, 175, 80) 50%, transparent 50%), 
        linear-gradient(90deg, rgb(76, 175, 80) 50%, transparent 50%), 
        linear-gradient(0deg, rgb(76, 175, 80) 50%, transparent 50%), 
        linear-gradient(0deg, rgb(76, 175, 80) 50%, transparent 50%),
        linear-gradient(to right, rgb(240, 255, 244), rgb(250, 250, 250));
}

.upsell-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.upsell-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.upsell-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}

.upsell-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* Envío prioritario */
.priority-shipping {
    background-color: rgb(250, 250, 250);
    background-image: 
        linear-gradient(90deg, rgb(255, 152, 0) 50%, transparent 50%), 
        linear-gradient(90deg, rgb(255, 152, 0) 50%, transparent 50%), 
        linear-gradient(0deg, rgb(255, 152, 0) 50%, transparent 50%), 
        linear-gradient(0deg, rgb(255, 152, 0) 50%, transparent 50%);
    background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
    background-size: 13px 3px, 13px 3px, 3px 13px, 3px 13px;
    background-position: left top, right bottom, left bottom, right top;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: none;
    transition: background-color 0.3s ease;
    cursor: pointer;
    animation: borderDashMove 0.5s linear infinite;
}

.priority-shipping.show {
    display: block;
}

.priority-shipping.selected {
    background-color: linear-gradient(to right, rgb(240, 255, 244), rgb(250, 250, 250));
    background-image: 
        linear-gradient(90deg, rgb(76, 175, 80) 50%, transparent 50%), 
        linear-gradient(90deg, rgb(76, 175, 80) 50%, transparent 50%), 
        linear-gradient(0deg, rgb(76, 175, 80) 50%, transparent 50%), 
        linear-gradient(0deg, rgb(76, 175, 80) 50%, transparent 50%),
        linear-gradient(to right, rgb(240, 255, 244), rgb(250, 250, 250));
}

.priority-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.priority-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.priority-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* Botones de pago */
.payment-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-payment {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    display: block;
    text-align: center;
    line-height: 1.3;
    min-height: 50px;
    text-align: center;
}

.btn-cod {
    background: #4CAF50;
    color: white;
}

.btn-cod:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-cod:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-card {
    background: #2196F3;
    color: white;
}

.btn-card:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-card .discount {
    font-size: 18px;
}

/* Modal de descuento */
.discount-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.discount-modal.active {
    display: flex;
}

.discount-modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    position: relative;
}

.discount-modal h2 {
    font-size: 28px;
    color: #333;
    margin-bottom: 15px;
}

.discount-modal p {
    font-size: 18px;
    color: #666;
    margin-bottom: 25px;
}

.discount-badge-large {
    width: 150px;
    height: 150px;
    margin: 20px auto;
    background: linear-gradient(135deg, #667eea 0%, #f093fb 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    font-weight: bold;
    position: relative;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.discount-badge-large::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    filter: blur(20px);
    opacity: 0.5;
    z-index: -1;
}

.discount-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #666;
    margin: 20px 0;
}

.discount-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}

.btn-apply-discount {
    background: linear-gradient(135deg, #667eea 0%, #f093fb 100%);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s;
}

.btn-apply-discount:hover {
    transform: scale(1.05);
}

.btn-skip-discount {
    background: none;
    border: 2px solid #333;
    color: #333;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-skip-discount:hover {
    background: #f5f5f5;
}

/* Modal de sin cobertura */
.no-coverage-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10002;
    align-items: center;
    justify-content: center;
}

.no-coverage-modal.active {
    display: flex;
}

.no-coverage-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.no-coverage-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.no-coverage-title {
    font-size: 24px;
    color: #333;
    margin-bottom: 15px;
}

.no-coverage-text {
    font-size: 16px;
    color: #666;
    margin-bottom: 25px;
}

.btn-pay-card-only {
    background: #2196F3;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

/* Garantía */
.guarantee-section {
    text-align: center;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

.guarantee-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.guarantee-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.guarantee-stars {
    color: #FFD700;
    font-size: 20px;
}

/* Loader */
.loader-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loader-overlay.show {
    display: flex;
}

.loader {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    margin-top: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #4CAF50;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.open-modal-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

/* Responsivo */
@media (max-width: 480px) {
    .modal-overlay {
        padding-top: 3%;
        padding-bottom: 3%;
    }
    
    .modal-container {
        height: auto;
        max-width: 95%;
        border-radius: 8px;
        margin: 10px auto;
        overflow: visible;
    }
    
    .modal-header {
        border-radius: 8px 8px 0 0;
    }

    .discount-modal-content,
    .no-coverage-content {
        width: 95%;
        padding: 25px 20px;
    }
}