/* =======================================================
   ESTILOS GENERALES Y FUENTES
   ======================================================= */

@font-face {
    font-family: 'Aclonica';
    src: url("../fuentes/Aclonica/Aclonica-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* --- Punto 3.2: Imagen de fondo y configuración del body --- */
body,
html {
    margin: 0;
    padding: 0;
    background-image: url("../imagenes/patron/pokeballs.jpg");
    background-size: 128px 128px;
    background-repeat: repeat;
    /* Fijamos el fondo para que el patrón se quede quieto al hacer scroll */
    background-attachment: fixed;
}

/* --- Punto 3.3: Contenedor Principal --- */
#main-container {
    width: 90%;
    /* Aseguramos que ocupe al menos toda la altura de la pantalla */
    min-height: 100vh;
    background-color: white;
    /* Flexbox para mantener el pie de página siempre abajo si falta contenido */
    display: flex;
    flex-direction: column;
}

/* =======================================================
   CABECERA Y NAVEGACIÓN
   ======================================================= */

/* --- Punto 3.4: Cabecera (Header) --- */
header {
    margin-top: 0;
    width: 100%;
    background-color: crimson;
}

#header-pokeball {
    width: 80px;
    height: auto;
}

h1 {
    padding: 10px;
    margin-bottom: 0;
    font-family: 'Aclonica';
    color: white;
}

/* --- Punto 3.5: Barra de Navegación --- */
nav {
    width: 100%;
}

nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    /* Quitamos las viñetas por defecto */
}

.nav-link {
    color: white !important;
    transition: color 0.2s ease;
}

/* Efecto visual al pasar el ratón por los enlaces */
.nav-link:hover {
    color: #e7e6a8 !important;
}

/* =======================================================
   GRID DE PRODUCTOS Y TARJETAS
   ======================================================= */

/* --- Punto 3.6 y 3.6.1: Listado de Productos --- */

.product-card {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid rgba(0, 0, 0, 0.125);
    position: relative;
    /* Necesario para posicionar los botones flotantes dentro */
}

/* Efecto "levitación" y borde rojo suave al pasar el ratón */
.product-card:hover {
    background-color: #ffe5e5;
    border-color: #ff9999;
    transform: translateY(-3px);
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15) !important;
}

/* Limitamos el título a 2 líneas y ponemos puntos suspensivos si se pasa */
.card-title {
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.1rem;
}

/* Lo mismo para la descripción, pero a 3 líneas */
.card-text {
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Posicionamiento del botón del carrito flotante */
.btn-cart-float,
.floating-button {
    position: absolute;
    top: 10px;
    right: 10px;
    border-radius: 50%;
    z-index: 10;
}

/* =======================================================
   BARRA DE HERRAMIENTAS (FILTROS Y BUSCADOR)
   ======================================================= */

/* Sacado de https://uiverse.io/Maximinodotpy/thin-sheep-13 */
/* Estilos para el input de búsqueda animado */
.search-container {
    font-family: 'Segoe UI', sans-serif;
    margin: 1em 0;
    max-width: 190px;
    position: relative;
}

.search-container input {
    font-size: 100%;
    padding: 0.8em;
    outline: none;
    border: 2px solid rgb(200, 200, 200);
    background-color: transparent;
    border-radius: 20px;
    width: 100%;
}

.search-container label {
    font-size: 100%;
    position: absolute;
    left: 0;
    padding: 0.8em;
    margin-left: 0.5em;
    pointer-events: none;
    transition: all 0.3s ease;
    color: rgb(100, 100, 100);
}

/* Animación: mueve el label arriba cuando escribimos o hacemos click */
.search-container :is(input:focus, input:valid)~label {
    transform: translateY(-50%) scale(.9);
    margin: 0;
    margin-left: 1.3em;
    padding: 0.4em;
    background-color: white;
}

.search-container :is(input:focus, input:valid) {
    border-color: rgb(150, 150, 200);
}

/* --- Slider de Rango Doble (Precio) --- */
.range-slider {
    position: relative;
    width: 100%;
    height: 5px;
    background: #ddd;
    border-radius: 5px;
    margin-top: 10px;
}

/* Barra roja que conecta los dos puntos del slider */
.range-selected {
    height: 100%;
    left: 0%;
    right: 0%;
    position: absolute;
    border-radius: 5px;
    background: crimson;
}

.range-input {
    position: relative;
}

.range-input input {
    position: absolute;
    width: 100%;
    height: 5px;
    top: -7px;
    background: none;
    pointer-events: none;
    /* Permite hacer clic a través de la barra transparente */
    -webkit-appearance: none;
    appearance: none;
}

/* Estilos para la "bola" del slider */
.range-input input::-webkit-slider-thumb {
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: crimson;
    border: 2px solid white;
    pointer-events: auto;
    /* Reactivamos los eventos para poder arrastrar la bola */
    -webkit-appearance: none;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

/* Estilos para la "bola" del slider */
.range-input input::-moz-range-thumb {
    height: 18px;
    width: 18px;
    border: none;
    border-radius: 50%;
    background: crimson;
    pointer-events: auto;
    -moz-appearance: none;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

/* Botón circular para limpiar filtros */
.filter-btn-container {
    height: 55px;
    width: 55px;
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.filter-btn-container:active {
    transform: scale(0.9);
    /* Efecto de pulsación */
}

.filter-icon {
    box-sizing: border-box;
    width: 48px;
    height: 48px;
    background-color: white;
    border: 2px solid rgb(200, 200, 200);
    border-radius: 30%;
    padding: 8px;
    object-fit: contain;
}

/* =======================================================
   FORMULARIO LATERAL
   ======================================================= */

/* --- Punto 3.6.2: Aside (Barra lateral) --- */
.sidebar-sticky {
    top: 20px;
    /* Margen superior al quedarse pegado */
    z-index: 1000;
}

.submit {
    background-color: crimson;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    height: 50px;
}

/* --- Punto 5.3: Zona de Drag & Drop --- */
#drop-zone {
    border-style: dashed !important;
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Clase que JS añade cuando arrastramos un archivo encima */
.dragover {
    background-color: #e9ecef !important;
    border-color: #0d6efd !important;
    border-style: solid !important;
    border-width: 2px !important;
    color: #0d6efd;
    transform: scale(1.02);
    /* Pequeño zoom para dar feedback */
}

/* También aplicamos estilos si el ID tiene la clase (doble seguridad) */
#drop-zone.dragover {
    background-color: #e9ecef;
    border-color: #0d6efd !important;
    border-width: 2px !important;
}

.alert-custom {
    padding: 10px;
    border-radius: 5px;
    font-size: 0.9rem;
    text-align: center;
}

/* =======================================================
   MODAL DE DETALLES
   ======================================================= */

/* --- Punto 3.9: Ventana Modal --- */
.modal-title-custom {
    color: #333;
    font-family: 'Aclonica', sans-serif;
    border-bottom: 2px solid crimson;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-img-container {
    min-height: 400px;
    background-color: #f8f9fa;
}

/* Aseguramos el Aspect Ratio de la imagen en el modal */
#modal-product-img,
.product-modal-img {
    max-height: 400px;
    width: auto;
    object-fit: contain;
    background-color: white;
    border-radius: 8px;
}

.product-details-scroll {
    max-height: 450px;
    overflow-y: auto;
    /* Scroll si el texto es muy largo */
    padding-right: 1rem;
}

/* Botón animado del modal */
.btn-add-cart {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-width: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Estado verde cuando se añade al carrito */
.btn-added {
    background-color: #198754 !important;
    border-color: #198754 !important;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.3);
}

/* =======================================================
   CARRITO DE COMPRA (OFFCANVAS)
   ======================================================= */

/* --- Estilos correspondientes al Punto 3.8 y funcionalidad del 5.4 --- */

#offcanvasLabel {
    font-family: 'Aclonica', sans-serif;
    letter-spacing: 1px;
}

.offcanvas-header {
    background-color: crimson;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.offcanvas-body {
    background-color: #f8f9fa;
    padding: 1rem;
}

/* Estilo de la "tarjeta" dentro del carrito */
.cart-item-container-grid {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-right: 5px;
    /* Margen de seguridad para evitar scroll horizontal */

    /* Grid para mejorar el espacio: 40px para imagen, input estrecho y más sitio para el total */
    display: grid;
    grid-template-columns: 40px 40px 1fr 0.7fr 1.3fr;
    grid-template-rows: auto auto;
    column-gap: 5px;
    row-gap: 5px;
    align-items: center;
}

.cart-item-container-grid:hover {
    transform: translateY(3px);
    /* Efecto levitación hacia abajo */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: #ff9999;
}

/* Imagen del producto en el carrito */
.cart-item-pic {
    grid-area: 1 / 1 / 3 / 3;
    /* Ocupa las 2 primeras columnas */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    border-radius: 8px;
    padding: 2px;
    /* Reducido para ganar espacio */
}

.cart-item-pic img {
    max-height: 70px;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

.cart-item-name {
    grid-area: 1 / 3 / 2 / 6;
    font-weight: 700;
    color: #333;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Puntos suspensivos... */
    margin-bottom: 4px;
}

.cart-item-price {
    grid-area: 2 / 3 / 3 / 4;
    font-size: 0.85rem;
    color: #6c757d;
    white-space: nowrap;
}

.cart-item-price::after {
    content: " /ud";
    font-size: 0.7rem;
}

.cart-item-cant {
    grid-area: 2 / 4 / 3 / 5;
    display: flex;
    justify-content: center;
}

.cart-item-cant input {
    width: 50px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    color: #333;
    background-color: #fff;
    padding: 2px;
    outline: none;
    transition: border-color 0.2s;
}

.cart-item-cant input:focus {
    border-color: crimson;
    box-shadow: 0 0 0 2px rgba(220, 20, 60, 0.1);
}

.cart-item-total {
    grid-area: 2 / 5 / 3 / 6;
    font-weight: bold;
    color: crimson;
    text-align: right;
    font-size: 1.1rem;
    white-space: nowrap;
    /* Evita que el precio salte de línea */
    letter-spacing: -0.5px;
}

/* Pie del carrito: Total General */
.offcanvas-body .border-top {
    border-top: 2px dashed #dee2e6 !important;
}

h4.bg-secondary {
    background-color: white !important;
    color: #333 !important;
    text-align: right !important;
    padding: 10px 0 !important;
    font-family: 'Aclonica', sans-serif;
    border-radius: 8px;
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h4.bg-secondary::before {
    content: "Total a pagar:";
    font-size: 1.2rem;
    color: #666;
    font-family: system-ui, -apple-system, sans-serif;
}

#cart-total {
    color: crimson;
    font-size: 1.8rem;
    font-weight: bold;
}

/* Scrollbar personalizado para la lista del carrito */
#cart-items::-webkit-scrollbar {
    width: 6px;
}

#cart-items::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#cart-items::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

#cart-items::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Estilos para el cupón */
#coupon-toggle:hover {
    color: crimson !important;
}

#coupon-form input:focus {
    border-color: crimson;
    box-shadow: 0 0 0 0.2rem rgba(220, 20, 60, 0.25);
}

/* =========================================
   ESTILOS CARRITO 3x2 Y BUNDLES
   ========================================= */

/* Ajuste del grid para que quepa la papelera bien */
.cart-grid-custom {
    grid-template-columns: 40px 1fr 0.7fr 40px 1.2fr !important;
}

/* Etiqueta gris del tipo de producto (Carta, Videojuego...) */
.badge-cat {
    background-color: #6c757d;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    margin-left: 5px;
    vertical-align: middle;
}

/* Etiqueta verde de oferta 3x2 */
.badge-offer {
    background-color: #198754;
    /* Verde éxito */
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    margin-left: 5px;
    vertical-align: middle;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.2);
}

/* Precio tachado */
.price-strikethrough {
    text-decoration: line-through;
    color: #6c757d;
    /* Gris */
    font-size: 0.9em;
}

/* Botón papelera */
.trash-btn {
    transition: transform 0.2s;
}

.trash-btn:hover {
    transform: scale(1.2);
}

/* Forzamos que los elementos se coloquen en orden automático (1 fila) */
.cart-grid-custom .cart-item-pic,
.cart-grid-custom .cart-item-name,
.cart-grid-custom .cart-item-price,
.cart-grid-custom .cart-item-cant,
.cart-grid-custom .cart-item-total {
    grid-area: auto !important;
}

/* Evitamos que se corte el texto o las etiquetas */
.cart-grid-custom .cart-item-name {
    white-space: normal !important;
    overflow: visible !important;
    margin-bottom: 0 !important;
}

/* Ajuste vertical para que todo quede centrado */
.cart-grid-custom {
    align-items: center;
    grid-template-rows: auto !important;
    padding: 10px 5px !important;
}

/* --- Estilo para el error de límite de cantidad (Punto 5) --- */
.cart-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    text-align: center;
    font-size: 0.9rem;
    width: 100%;
    animation: fadeIn 0.3s;
}

/* =========================================
   ESTILOS CUPÓN
   ========================================= */

#coupon-toggle {
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

#coupon-toggle:hover {
    color: crimson !important;
}

/* =========================================
   ESTILOS BANNER MODAL
   ========================================= */

/* Imagen del Banner */
.banner-img-custom {
    max-height: 60vh;
    /* Límite de altura para el zoom */
    width: auto;
    /* El ancho se ajusta solo */
    border: 6px solid #FFD700;
    /* Borde dorado */
    image-rendering: pixelated;
    /* Para que el pixel art se vea nítido */
    object-fit: contain;
}

/* Botón de Cerrar (X Roja flotante) */
.banner-close-btn {
    background-color: #dc3545;
    /* Rojo intenso */
    opacity: 1;
    padding: 1rem;
    border: 4px solid white;
    /* Icono de la X en blanco (SVG codificado) */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");
}

/* Botón de Acción (Copiar Código) */
#btn-copy-promo {
    font-family: sans-serif;
    font-size: 1.3rem;
    border: 4px solid #FFD700;
    /* Borde dorado a juego */
    box-shadow: 0 6px 0 #b30000;
    /* Sombra 3D roja oscura */
    transition: all 0.1s;
}

/* Efecto click botón del banner (se hunde) */
#btn-copy-promo:active {
    transform: translateY(6px) !important;
    box-shadow: none !important;
}

/* =======================================================
   UTILIDADES Y ANIMACIONES EXTRA
   ======================================================= */

@keyframes show {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* =========================================
   POKEBALL ANIMADA
   ========================================= */

.promo-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    background: transparent;
    /* El fondo lo pone la pokeball */
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.3s ease;
    /* Solo animamos la escala de la burbuja entera */
    display: flex;
    align-items: center;
    justify-content: center;

    /* Animación de entrada inicial */
    opacity: 0;
    transform: translateY(100px);
}

.promo-bubble.show-bubble {
    opacity: 1;
    transform: translateY(0);
}

.promo-bubble:hover {
    transform: scale(1.1) !important;
    /* Crece un poco al pasar el ratón */
}

/* --- Estructura interna --- */

.pokeball-container {
    position: relative;
    width: 100%;
    height: 100%;
    border: 3px solid #333;
    /* Borde exterior */
    border-radius: 50%;
    overflow: hidden;
    background-color: #333;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Parte superior (Roja) */
.poke-top {
    position: absolute;
    top: 0;
    width: 100%;
    height: 50%;
    background-color: #ff1f1f;
    border-bottom: 2px solid #333;
    transform-origin: bottom center;
    z-index: 2;
    /* AL CERRAR: Transición suave sin rebote */
    transition: transform 0.3s ease-out;
}

/* Parte inferior (Blanca) */
.poke-bottom {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 50%;
    background-color: #f1f1f1;
    border-top: 2px solid #333;
    transform-origin: top center;
    z-index: 2;
    /* AL CERRAR: Transición suave sin rebote */
    transition: transform 0.3s ease-out;
}

/* El botón central / Regalo */
.poke-center-gift {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background-color: white;
    border: 4px solid #333;
    /* Borde grueso para simular el botón */
    border-radius: 50%;
    z-index: 3;

    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    /* Ocultamos el icono del regalo inicialmente */
    transition: all 0.3s ease;
}

/* --- Animación de APERTURA (HOVER) --- */

/* Al abrir, usamos el rebote (cubic-bezier) */
.promo-bubble:hover .poke-top {
    transform: translateY(-16px) rotate(-10deg);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.promo-bubble:hover .poke-bottom {
    transform: translateY(16px) rotate(10deg);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Transformación del botón en regalo */
.promo-bubble:hover .poke-center-gift {
    width: 30px;
    height: 30px;
    border: none;
    /* Quitamos el borde negro */
    background-color: transparent;
    /* Quitamos el fondo blanco */
    font-size: 24px;
    /* Aparece el icono */
    z-index: 1;
    /* Se va detrás de las tapas para que parezca que sale de dentro */
    transform: translate(-50%, -50%) scale(1.2);
}