/**
 * CSS Global para el Carrito Flotante y Sistema de Niveles
 * Archivo: carrito-global.css
 */

/* ================================
   CARRITO FLOTANTE - ESTRUCTURA GLOBAL
   ================================ */

/* Overlay para cerrar el carrito */
.carrito-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.carrito-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Panel lateral del carrito */
.carrito-panel-lateral {
    position: fixed;
    top: 0;
    right: -450px;
    width: 420px;
    height: 100vh;
    background: #ffffff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.carrito-panel-lateral.active {
    right: 0;
}

/* Header del carrito */
.carrito-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.carrito-titulo {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.carrito-cerrar {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    color: #6c757d;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.carrito-cerrar:hover {
    background: #e9ecef;
    color: #495057;
}

/* Contenido scrolleable del carrito */
.carrito-contenido {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.carrito-productos-scroll {
    padding: 0 1.5rem;
}

/* ================================
   PRODUCTOS EN EL CARRITO
   ================================ */

.carrito-producto-item {
    border-bottom: 1px dotted #ddd;
    padding: 1rem 0;
    position: relative;
}

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

/* Layout principal: imagen a la izquierda, info a la derecha */
.producto-layout {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.producto-imagen-mini {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    background: #f8f9fa;
}

.producto-imagen-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Contenedor de toda la información del producto */
.producto-info-completa {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Primera línea: nombre + botón eliminar */
.producto-linea-principal {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.producto-nombre {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    margin: 0;
    line-height: 1.3;
    flex: 1;
}

.producto-eliminar {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.producto-eliminar:hover {
    background: #dc3545;
    color: white;
    transform: scale(1.1);
}

/* Segunda línea: SKU + Cantidad */
.producto-linea-secundaria {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #666;
}

.producto-sku {
    display: flex;
    gap: 0.25rem;
}

.sku-label {
    font-weight: 500;
}

.sku-valor {
    color: #495057;
    font-weight: 400;
}

.producto-cantidad {
    display: flex;
    gap: 0.25rem;
}

.cantidad-label {
    font-weight: 500;
}

.cantidad-valor {
    color: #495057;
    font-weight: 600;
}

/* ================================
   SISTEMA DE NIVELES
   ================================ */

.carrito-niveles-widget {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 1.5rem;
    border-left: 4px solid #FF8000;
}

/* Nivel actual */
.nivel-actual {
    margin-bottom: 1rem;
}

.nivel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.nivel-icono {
    font-size: 1.2rem;
}

.nivel-nombre {
    font-weight: 600;
    font-size: 1rem;
}

.nivel-total {
    font-size: 0.9rem;
    color: #495057;
}

/* Siguiente nivel */
.siguiente-nivel {
    border-top: 1px solid #dee2e6;
    padding-top: 1rem;
}

.nivel-objetivo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.objetivo-icono {
    font-size: 1rem;
}

.objetivo-nombre {
    font-size: 0.9rem;
    font-weight: 500;
}

.nivel-faltante {
    font-size: 0.85rem;
    color: #495057;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

/* Barra de progreso */
.nivel-progreso {
    margin-top: 0.75rem;
}

.progreso-barra {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progreso-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progreso-texto {
    text-align: center;
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
}

/* Nivel máximo */
.nivel-maximo {
    text-align: center;
    border-top: 1px solid #dee2e6;
    padding-top: 1rem;
}

.felicitaciones {
    color: #28a745;
    font-weight: 500;
    font-size: 0.9rem;
}

/* ================================
   CARRITO VACÍO
   ================================ */

.carrito-vacio {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #6c757d;
}

.carrito-vacio-icono {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.carrito-vacio p {
    margin: 0.5rem 0;
}

.carrito-vacio-texto {
    font-size: 0.9rem;
    color: #adb5bd;
}

/* ================================
   FOOTER DEL CARRITO
   ================================ */

.carrito-footer {
    border-top: 1px solid #e9ecef;
    padding: 1.5rem;
    background: #f8f9fa;
}

.carrito-contador-sub {
    margin-bottom: 1rem;
}

.carrito-resumen-linea {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    color: #495057;
}

.carrito-total-linea {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-top: 1px solid #dee2e6;
    font-size: 1rem;
}

.carrito-nota {
    font-size: 0.8rem;
    color: #6c757d;
    text-align: center;
    margin: 0.5rem 0 0 0;
    font-style: italic;
}

/* Botones de acción */
.carrito-acciones {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-resumen,
.btn-cotizar {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

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

.btn-resumen:hover {
    background: #5a6268;
    color: white;
    text-decoration: none;
}

.btn-cotizar {
    background: #FF8000;
    color: white;
}

.btn-cotizar:hover {
    background: #e67300;
    color: white;
    text-decoration: none;
}

/* ================================
   BOTÓN TRIGGER DEL CARRITO
   ================================ */

.carrito-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #FF8000;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(255, 128, 0, 0.3);
    cursor: pointer;
    z-index: 9997;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.carrito-trigger:hover {
    background: #e67300;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 128, 0, 0.4);
}

.carrito-trigger a {
    color: white;
    text-decoration: none;
    margin-left: 0.5rem;
}

.carrito-trigger a:hover {
    color: white;
    text-decoration: underline;
}

/* ================================
   CONTADOR DEL CARRITO
   ================================ */

#carrito-contador {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    top: -2px;
}

#carrito-contador.oculto {
    display: none;
}

/* ================================
   RESPONSIVE
   ================================ */

@media (max-width: 768px) {
    .carrito-panel-lateral {
        width: 100vw;
        right: -100vw;
    }
    
    .carrito-trigger {
        bottom: 15px;
        right: 15px;
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }
    
    .carrito-niveles-widget {
        margin: 1rem;
    }
    
    .carrito-acciones {
        flex-direction: column;
    }
    
    .producto-nombre {
        max-width: 150px;
    }
}

/* ================================
   ESTADOS DE CARGA
   ================================ */

.carrito-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    color: #6c757d;
}

.carrito-loading::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #FF8000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

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

/* ================================
   PREVENCIÓN DE SCROLL
   ================================ */

body.carrito-abierto {
    overflow: hidden;
}

/* ================================
   ANIMACIONES
   ================================ */

.carrito-producto-item {
    animation: slideInFromRight 0.3s ease;
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nivel-progreso .progreso-fill {
    animation: progressFill 0.5s ease-out;
}

@keyframes progressFill {
    from {
        width: 0;
    }
}

/* ================================
   MEJORAS VISUALES
   ================================ */

.carrito-panel-lateral {
    backdrop-filter: blur(10px);
}

.carrito-trigger {
    backdrop-filter: blur(10px);
}

/* Sombras mejoradas */
.carrito-panel-lateral.active {
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
}

/* Estados hover mejorados */
.carrito-producto-item:hover {
    background: rgba(248, 249, 250, 0.5);
    border-radius: 6px;
    margin: 0 -0.5rem;
    padding: 1rem 0.5rem;
    transition: all 0.2s ease;
}
