/* =============================================
   SISTEMA DE CARRITO DE COMPRAS FUNCIONAL
   Estilos para modales, formularios y funcionalidad e-commerce
   Incluye autenticación, checkout y notificaciones
   ============================================= */

/* =============================================
   SISTEMA DE MODALES PARA CARRITO
   Ventanas emergentes para diferentes funcionalidades
   ============================================= */
/* Overlay de fondo para modales */
.modal-overlay {
    display: none;                      /* Oculto por defecto */
    position: fixed;                    /* Posición fija en viewport */
    top: 0;
    left: 0;
    width: 100%;                        /* Cobertura completa */
    height: 100%;
    background: rgba(0, 0, 0, 0.5);     /* Fondo semitransparente oscuro */
    z-index: 9999;                      /* Capa superior */
    align-items: center;                /* Centrado vertical */
    justify-content: center;            /* Centrado horizontal */
}

/* Contenido principal del modal */
.modal-content {
    background: white;                          /* Fondo blanco */
    border-radius: 8px;                         /* Bordes redondeados */
    max-width: 90%;                             /* Ancho máximo responsivo */
    max-height: 90%;                            /* Alto máximo responsivo */
    overflow-y: auto;                           /* Scroll vertical si es necesario */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);  /* Sombra profunda */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

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

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* =============================================
   MODAL ESPECÍFICO DEL CARRITO DE COMPRAS
   Visualización y gestión de productos seleccionados
   ============================================= */
/* Ancho específico del modal de carrito */
.carrito-modal {
    width: 600px;  /* Ancho fijo para desktop */
}

.carrito-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.carrito-item:last-child {
    border-bottom: none;
}

.carrito-item-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.carrito-item-info {
    flex: 1;
}

.carrito-item-info h5 {
    margin: 0 0 5px 0;
    font-size: 16px;
}

.carrito-item-info p {
    margin: 0 0 10px 0;
    color: #666;
    font-weight: bold;
}

.cantidad-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cantidad-controls button {
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cantidad-controls button:hover {
    background: #f5f5f5;
}

.cantidad-controls span {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
}

.btn-remove {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-remove:hover {
    background: #c82333;
}

.carrito-total {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
}

/* Modal de Autenticación */
.auth-modal {
    width: 450px;
}

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

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.w-100 {
    width: 100%;
}

.text-center {
    text-align: center;
}

.mt-3 {
    margin-top: 1rem;
}

/* Modal de Checkout */
.checkout-modal {
    width: 700px;
}

.checkout-steps {
    min-height: 400px;
}

.checkout-step {
    display: none;
}

.checkout-step.active {
    display: block;
}

.checkout-step h4 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.checkout-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.checkout-total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #007bff;
    font-size: 18px;
    text-align: right;
}

.checkout-nav {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
}

/* Botones */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.2s;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #1e7e34;
}

/* Carrito flotante mejorado */
.carrito-flotante {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #007bff;
    color: white;
    padding: 15px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    transition: all 0.3s;
    z-index: 1000;
}

.carrito-flotante:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.6);
}

.carrito-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
}

.carrito-count {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    min-width: 24px;
}

/* Toast notifications */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.toast-notification.show {
    transform: translateX(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-content i {
    font-size: 18px;
}

.text-success {
    color: #28a745;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95%;
    }
    
    .carrito-modal,
    .auth-modal,
    .checkout-modal {
        width: 100%;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .checkout-nav {
        flex-direction: column;
        gap: 10px;
    }
    
    .carrito-flotante {
        bottom: 10px;
        right: 10px;
        padding: 12px;
    }
}

/* Estados de loading */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Validación de formularios */
.form-group input:invalid {
    border-color: #dc3545;
}

.form-group input:valid {
    border-color: #28a745;
}

.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

.success-message {
    color: #28a745;
    font-size: 12px;
    margin-top: 5px;
}
