/* Sistema de Modales Elegantes */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.modal-active {
    display: block !important;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-white);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

/* Modal específico del carrito */
#cart-modal .modal-content {
    width: 100%;
    max-width: 600px;
    min-height: 400px;
}

#cart-modal .modal-body {
    min-height: 300px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(117, 2, 56, 0.1);
}

.modal-title {
    color: var(--color-accent);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(220, 53, 69, 0.1);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--color-danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(220, 53, 69, 0.2);
    transform: scale(1.1);
    color: #c82333;
}

.modal-close:active {
    transform: scale(0.9);
    background: rgba(220, 53, 69, 0.3);
}

.modal-body {
    margin-bottom: 2rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(117, 2, 56, 0.1);
}

/* Modal de Producto */
.product-modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.product-modal-image {
    width: 100%;
    border-radius: var(--border-radius);
    aspect-ratio: 1;
    object-fit: cover;
}

.product-modal-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.product-modal-name {
    font-size: 1.5rem;
    color: var(--color-accent);
    font-weight: 600;
}

.product-modal-description {
    color: var(--color-text);
    line-height: 1.6;
}

.product-modal-price {
    font-size: 1.5rem;
    color: var(--color-secondary);
    font-weight: 700;
}

.quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(117, 2, 56, 0.05);
    border-radius: var(--border-radius-lg);
}

.quantity-btn {
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.quantity-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.quantity-btn:hover {
    background: var(--color-secondary);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(117, 2, 56, 0.4);
}

.quantity-btn:active {
    transform: scale(0.9);
    background: var(--color-accent);
}

.quantity-btn:active::before {
    width: 100%;
    height: 100%;
}

.quantity-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.quantity-display {
    background: var(--color-white);
    border: 3px solid var(--color-accent);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-lg);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-accent);
    min-width: 80px;
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(117, 2, 56, 0.1);
    touch-action: manipulation;
}

/* Modal de Confirmación */
.confirmation-modal .modal-content {
    text-align: center;
    max-width: 400px;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--color-success), #20c997);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.5rem;
    color: var(--color-white);
    box-shadow: 0 8px 32px rgba(40, 167, 69, 0.3);
    animation: successPulse 2s infinite;
}

.order-number {
    font-size: 2rem;
    color: var(--color-accent);
    font-weight: 700;
    margin: 1rem 0;
}

.estimated-time {
    background: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: inline-block;
    margin: 1rem 0;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 32px rgba(40, 167, 69, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 40px rgba(40, 167, 69, 0.4);
    }
}

/* Mejoras para botones de modal */
.modal-footer .btn {
    min-height: 48px;
    min-width: 120px;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius-lg);
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.modal-footer .btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.modal-footer .btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.modal-footer .btn:active {
    transform: translateY(-1px);
}

.modal-footer .btn:active::before {
    width: 200%;
    height: 200%;
}

.modal-footer .btn-primary {
    background: linear-gradient(135deg, var(--color-accent), var(--color-secondary));
    border: none;
    color: var(--color-white);
}

.modal-footer .btn-primary:hover {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-accent));
}

.modal-footer .btn-secondary {
    background: var(--color-gray-light);
    border: 2px solid var(--color-accent);
    color: var(--color-accent);
}

.modal-footer .btn-secondary:hover {
    background: var(--color-accent);
    color: var(--color-white);
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
    
    .product-modal-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .quantity-selector {
        gap: 1.5rem;
        padding: 1.5rem;
        margin: 2rem 0;
    }
    
    .quantity-btn {
        width: 56px;
        height: 56px;
        font-size: 1.8rem;
    }
    
    .quantity-display {
        padding: 1.25rem 2rem;
        font-size: 1.8rem;
        min-width: 100px;
        min-height: 56px;
    }
    
    .modal-footer .btn {
        min-height: 56px;
        padding: 1.25rem 2.5rem;
        font-size: 1.1rem;
        min-width: 140px;
    }
    
    .modal-close {
        width: 48px;
        height: 48px;
        font-size: 1.6rem;
        top: 0.75rem;
        right: 0.75rem;
    }
    
    .success-icon {
        width: 100px;
        height: 100px;
        font-size: 3rem;
    }
}

/* Mejoras para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    .quantity-btn:hover,
    .modal-footer .btn:hover,
    .modal-close:hover {
        transform: none;
        box-shadow: none;
    }
    
    .quantity-btn:active {
        transform: scale(0.85);
        background: var(--color-secondary);
    }
    
    .modal-footer .btn:active {
        transform: scale(0.95);
    }
    
    .modal-close:active {
        transform: scale(0.85);
        background: rgba(220, 53, 69, 0.4);
    }
    
    .success-icon {
        animation: none;
    }
}