/* --- public/css/components.css --- */

/* 1. CONTENEDOR GRID RESPONSIVE */
.product-grid-container {
    display: grid;
    /* Escritorio: Rellena con tantas columnas como quepan (mínimo 180px) */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 10px 0;
    width: 100%;
}

/* 2. TARJETA DE PRODUCTO */
.product-card {
    background: white;
    border-radius: 8px; /* Bordes un poco menos redondos en móvil se ven mejor */
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #f0f0f0;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Hover solo en PC (en móvil el hover a veces molesta) */
@media (min-width: 769px) {
    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 16px rgba(0,0,0,0.1);
        border-color: #ff0000;
    }
}

/* Link envolvente */
.card-link-wrapper {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* 3. IMAGEN */
.card-image-wrapper {
    width: 100%;
    height: 180px; /* Altura base para escritorio */
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-bottom: 1px solid #f9f9f9;
}

.card-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* 4. INFO Y PRECIOS */
.card-info {
    padding: 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-title {
    font-size: 0.9rem;
    color: #333;
    margin: 0 0 8px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Cortar texto en 2 líneas */
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.4em; /* Fija la altura para alinear tarjetas */
}

/* Precios */
.price-container {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.85rem;
}

.current-price {
    font-size: 1.1rem;
    font-weight: 800;
    color: #ff0000;
}

/* 5. BOTÓN FLOTANTE */
.btn-quick-add {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #ff0000;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    font-size: 1.2rem;
    z-index: 2;
    transition: transform 0.2s;
}

.btn-quick-add:active {
    transform: scale(0.9);
}

.loader {
    text-align: center;
    padding: 20px;
    width: 100%;
    display: none;
    color: #888;
    font-weight: 600;
}

/* =========================================
   AQUÍ ESTÁ LA MAGIA PARA MÓVILES (< 600px)
   ========================================= */
@media (max-width: 600px) {
    .product-grid-container {
        /* Forzamos 2 columnas exactas */
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px; /* Menos espacio entre tarjetas */
       
    }

    .card-image-wrapper {
        height: 150px; /* Imagen más pequeña para ahorrar espacio */
        padding: 5px;
    }

    .card-info {
        padding: 8px; /* Menos relleno interno */
    }

    .card-title {
        font-size: 0.8rem; /* Texto más pequeño */
    }

    .current-price {
        font-size: 1rem; /* Precio ajustado */
    }

    .original-price {
        font-size: 0.75rem;
    }

    /* Ajustar botón para que no tape el precio */
    .btn-quick-add {
        width: 28px;
        height: 28px;
        font-size: 1rem;
        bottom: 6px;
        right: 6px;
    }
}

/* --- AGREGAR AL FINAL DE public/css/components.css --- */

/* A. CONTENEDOR DE IMAGEN (Para posicionar badges) */
.card-image-wrapper {
    position: relative; /* Vital para que los badges no se salgan */
}

/* B. ETIQUETA DE DESCUENTO (Rojo TITI) */
.discount-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background-color: #ff0000;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 3px 6px;
    border-radius: 4px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* C. ETIQUETAS DE ESTADO (Abajo de la imagen) */
.status-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 3px 0;
    z-index: 9;
    letter-spacing: 0.5px;
}

.status-badge.warning {
    background: rgba(255, 140, 0, 0.9); /* Naranja alerta */
    color: #fff;
}

.status-badge.new {
    background: rgba(40, 167, 69, 0.9); /* Verde éxito */
    color: #fff;
}

/* D. ANIMACIÓN DE PULSO PARA EL BOTÓN (+) */
@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(255, 0, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}

.btn-quick-add {
    /* Agregamos la animación al botón existente */
    animation: pulse-red 2s infinite;
}

/* Ajuste sutil para que el pulse no moleste al hacer click */
.btn-quick-add:active {
    animation: none;
    transform: scale(0.9);
}

/* --- AGREGAR AL FINAL DE public/css/components.css --- */

/* 1. ESTRELLAS DE VALORACIÓN */
.rating-container {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: #ffc107; /* Amarillo dorado */
    margin-bottom: 5px;
    line-height: 1;
}
.rating-text {
    color: #999;
    margin-left: 4px;
    font-size: 0.7rem;
}

/* 2. BOTÓN DE FAVORITOS (Corazón) */
.btn-wishlist {
    position: absolute;
    top: 30px;
    right: 8px; /* Esquina opuesta al descuento */
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    color: #ccc; /* Gris por defecto */
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-size: 1.1rem;
    padding: 0;
    line-height: 0;
}

.btn-wishlist:hover {
    color: #ff0000;
    transform: scale(1.1);
}

/* Clase para cuando le den click (se pone rojo) */
.btn-wishlist.active {
    color: #ff0000; 
}