/* Reset inicial */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', sans-serif;
}

/* Contenedor */
main {
    padding: 20px;
    background-color: #f5f5f5;
}

/* ===== Header ===== */
header {
    background-color: #444;
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}

.nav-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.login-container {
    display: flex;
    gap: 10px;
}

.btn-login {
    background: #ff9800;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.btn-login:hover {
    background: #fb8c00;
}

.user-info {
    display: none;
    align-items: center;
    gap: 15px;
}

#user-email {
    color: #ffcc00;
    font-weight: bold;
    font-size: 0.9rem;
}

.btn-logout {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.2s ease;
}

.btn-logout:hover {
    background: #c82333;
}

.icono {
    background: none;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;           
}

.icono img {
    width: 28px;
    height: 28px;
    display: block;
}

/* contador del carrito */
.contador-carrito {
    position: absolute;
    top: -6px;
    right: -8px;
    background: #ffcc00;
    color: #222;
    font-weight: 700;
    font-size: 0.75rem;
    line-height: 18px;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    text-align: center;
}

/* ===== Grid de productos ===== */
#contenedor-productos {
    max-width: 1200px;
    margin: 32px auto;
    padding: 16px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* Card del producto */
.imagen-productos {
    background-color: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    width: 100%;             
    min-height: 480px;       
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    transition: transform 0.3s ease;
}

.imagen-productos:hover {
    transform: scale(1.02);
}

/* Imagen del producto */
.imagen-productos img {
    width: 100%;
    height: 200px;          
    border-radius: 8px;
    object-fit: cover;
}

.imagen-productos h2 {
    font-size: 1.2rem;
    margin-top: 10px;
    color: #333;
}

.categoria {
    font-size: 0.9rem;
    color: #666;
    background-color: #f0f0f0;
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-block;
    margin: 5px 0;
}

.stock {
    font-size: 0.85rem;
    color: #28a745;
    font-weight: 500;
    margin: 5px 0;
}

.precio {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2e7d32;
    margin: 10px 0;
}

.imagen-productos button {
    background-color: #ff9800;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.25s ease, transform 0.1s ease;
}

.imagen-productos button:hover {
    background-color: #fb8c00;
}

.imagen-productos button:active {
    transform: translateY(1px);
}

/* ===== Carrito lateral ===== */
.carrito {
    position: fixed;
    top: 20%;
    right: -320px;
    width: 300px;
    height: 60%;
    background: rgb(165, 172, 215);
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    transition: right .3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-radius: 8px 0 0 8px;
}

.mostrar-carrito {
    right: 0;
}

#cerrar-carrito {
    position: absolute;
    top: .8rem;
    right: .8rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
}

#cerrar-carrito:hover {
    color: #d33;
}

#carrito-dinamico-interno {
    margin-top: .5rem;
    overflow: auto;
    flex: 1;
    padding-right: .5rem;
}

/* Estilos para items del carrito */
.item-carrito {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.imagen-carrito {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
}

.info-producto {
    flex: 1;
}

.info-producto h4 {
    font-size: 0.9rem;
    margin: 0 0 5px 0;
    color: #333;
}

.precio-carrito {
    font-size: 0.85rem;
    font-weight: bold;
    color: #2e7d32;
    margin: 0 0 5px 0;
}

.controles-cantidad {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-cantidad {
    background: #f0f0f0;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    color: #333;
    transition: background-color 0.2s ease;
}

.btn-cantidad:hover {
    background: #e0e0e0;
}

.cantidad {
    font-weight: bold;
    color: #333;
    min-width: 20px;
    text-align: center;
}

.btn-eliminar {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.btn-eliminar:hover {
    background: #ffebee;
}

/* Total y botón finalizar */
.total {
    margin-top: .6rem;
    font-weight: bold;
    color: #444;
    text-align: right;
    font-size: 1.1rem;
}

#finalizar-compra {
    background: #28a745;
    color: #fff;
    border: none;
    width: 100%;
    padding: .7rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-top: .8rem;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

#finalizar-compra:hover {
    background: #218838;
}

#finalizar-compra:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.5;
}

#finalizar-compra:disabled:hover {
    background: #6c757d;
}

/* Footer */
footer {
    background: #444;
    color: #fff;
    text-align: center;
    padding: 1rem 0;
}

/* ===== Filtros y búsqueda ===== */
.filtros {
    max-width: 1200px;
    margin: 0 auto 20px auto;
    padding: 0 24px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filtro-categoria {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.filtro-categoria:hover,
.filtro-categoria.activo {
    background: #ff9800;
    color: white;
    border-color: #ff9800;
}

.busqueda {
    flex: 1;
    min-width: 200px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.busqueda:focus {
    outline: none;
    border-color: #ff9800;
}

/* ===== Media Queries ===== */

@media (min-width: 1440px) {
    #contenedor-productos {
        max-width: 1320px;
        margin: 40px auto;
        padding: 20px 32px;
        gap: 28px;
    }
    
    .filtros {
        max-width: 1320px;
        padding: 0 32px;
    }
}

@media (max-width: 480px) {
    #contenedor-productos {
        margin: 20px auto;
        padding: 12px 12px;
        gap: 16px;
    }
    
    .filtros {
        padding: 0 12px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .login-container {
        flex-direction: column;
        gap: 5px;
    }
    
    .user-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .carrito {
        width: 100%;
        right: -100%;
        height: 80%;
        top: 10%;
    }
    
    .item-carrito {
        flex-direction: column;
        text-align: center;
    }
    
    .controles-cantidad {
        justify-content: center;
    }
}