/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: #ffffff;
}

/* === HEADER Y NAVEGACIÓN === */
.navbar {
    background-color: #1f1f1f;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    letter-spacing: 1px;
}

.logo span {
    color: var(--primary-color);
}

/* === BOTONES GLOBALES === */
.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 15px var(--primary-color);
}

button, .btn-primary {
    transition: all 0.2s ease;
}

button:active {
    transform: scale(0.98);
}

/* === GRILLA DE PRODUCTOS (Estilo G2A) === */
.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
}

.game-card {
    background-color: #1f1f1f;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid transparent;
}

/* El efecto G2A al pasar el cursor */
.game-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5), 0 0 10px var(--primary-color) inset;
}

.product-card {
    background: #1f1f1f;
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #333;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5), 0 0 10px var(--primary-color);
    border-color: var(--primary-color);
}

.game-cover {
    width: 100%;
    height: 300px;
    object-fit: cover;
}

.game-info {
    padding: 15px;
}

.game-title {
    font-size: 16px;
    margin-bottom: 10px;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

/* === CARRUSEL NATIVO DE CATEGORÍAS === */
.categories-carousel {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 15px; /* Espacio para la barra de desplazamiento */
    /* Ocultar scrollbar en navegadores webkit pero permitir el scroll */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) #1f1f1f;
}
.categories-carousel::-webkit-scrollbar {
    height: 8px;
}
.categories-carousel::-webkit-scrollbar-track {
    background: #1f1f1f;
    border-radius: 4px;
}
.categories-carousel::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 4px;
}

.category-item {
    scroll-snap-align: start;
    flex: 0 0 auto;
    background: #1f1f1f; 
    border: 1px solid #333; 
    border-radius: 8px; 
    padding: 20px; 
    text-align: center; 
    text-decoration: none; 
    color: white; 
    transition: all 0.3s ease; 
    display: flex; 
    flex-direction: column; 
    align-items: center;
    justify-content: center;
    /* Por defecto (Pantallas grandes/PC): 5 elementos */
    width: calc((100% - 80px) / 5);
}
.category-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
}

/* === CARRITO === */
.cart-sidebar {
    position: fixed; top: 0; right: -350px;
    width: 350px; height: 100%; background: #1f1f1f;
    transition: 0.3s ease-in-out; z-index: 9999;
    padding: 20px; border-left: 2px solid var(--primary-color);
}
.cart-sidebar.open { right: 0; }

/* =========================================
   DISEÑO RESPONSIVO (Tablets y Móviles)
   ========================================= */

/* Ajuste para Tablets / Laptops Pequeñas */
@media (max-width: 1024px) {
    .category-item { 
        /* 3 elementos en Tablet */
        width: calc((100% - 40px) / 3); 
    }
}

/* Ajuste principal Móvil/Tablet pequeña */
@media (max-width: 768px) {
    /* Navbar / Header */
    .navbar {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
    }
    
    .user-actions {
        width: 100%;
        justify-content: center;
        gap: 10px;
    }

    .currency-selector {
        margin-right: 0;
        width: 100%;
        max-width: 150px;
    }

    /* Grilla de productos en Home */
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
    
    .game-cover {
        height: 200px; /* Portadas más pequeñas en móvil */
    }

    .game-title {
        font-size: 14px;
    }

    .game-price {
        font-size: 16px;
    }

    /* Carrusel de Categorías Móvil */
    .category-item { 
        /* 2 elementos en móvil */
        width: calc((100% - 20px) / 2); 
    }

    /* Detalle del producto (product-single.php) */
    .product-single {
        padding: 20px !important;
        gap: 20px !important;
    }

    .product-single h1 {
        font-size: 28px !important;
    }

    /* Checkout */
    div[style*="max-width: 900px"] {
        margin: 20px 10px !important;
    }
    
    /* Forzar que los flex hijos tomen el 100% en móvil */
    .product-single > div,
    div[style*="max-width: 900px"] > div {
        min-width: 100% !important;
    }
}

/* Ajustes adicionales para pantallas muy pequeñas (Ej. iPhone SE) */
@media (max-width: 600px) {
    .cart-sidebar { width: 100%; right: -100%; }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: 1fr; /* Una sola columna */
    }
    .game-cover {
        height: 250px;
    }
}

/* Carrusel de Categorías */
.categories-carousel {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 15px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Suavidad en móviles */
}

.category-item {
    flex: 0 0 auto; /* No permite que se encojan */
    background: #1f1f1f; 
    border: 1px solid #333; 
    border-radius: 8px; 
    padding: 20px; 
    text-align: center; 
    text-decoration: none !important; 
    color: white !important; 
    display: flex; 
    flex-direction: column; 
    align-items: center;
}

/* Reglas de tamaño (ancho por ítem) */
@media (min-width: 1024px) {
    .category-item { width: calc(20% - 16px); } /* 5 en PC */
}
@media (min-width: 768px) and (max-width: 1023px) {
    .category-item { width: calc(33.33% - 14px); } /* 3 en Tablet */
}
@media (max-width: 767px) {
    .category-item { width: calc(50% - 10px); } /* 2 en Móvil */
}

/* Corrección de salto estético en categorías */
.category-item {
    border: 2px solid transparent !important; /* Borde invisible inicial */
    box-sizing: border-box;
}
.category-item:hover, .category-item.active {
    border: 2px solid var(--primary-color) !important;
}
/* Forzar altura constante para que no salten */
.categories-carousel a {
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Forzar el color de fondo oscuro en los campos de filtro */
.filter-bar input[type="text"], 
.filter-bar select {
    background-color: #141414 !important;
    color: #ffffff !important;
    border: 1px solid #444 !important;
}

/* Asegurar que el placeholder también se vea bien */
.filter-bar input[type="text"]::placeholder {
    color: #888 !important;
}