/* ============================================================
  TITULOS Y TEXTO EN PAGES
============================================================ */
.search-hero {
    /* Variables de color para este componente */
    --hero-tag-color: #111827;       /* Negro muy oscuro para el título */
    --hero-text-secondary: #6b7280;  /* Gris para textos pequeños */
    --hero-accent-line: #3b82f6;     /* Azul del indicador vertical */
    
    /* Layout y Alineación (Pegado a la izquierda) */
    width: 100%;
    margin: 0 0 32px 0;
    padding: 0;
    display: block; /* Asegura que ocupe todo el ancho */
}

/* --- 2. DEFINICIÓN DE COLORES (MODO OSCURO ACTIVO) --- */
/* Esto detecta si el sistema o navegador está en modo oscuro */
@media (prefers-color-scheme: dark) {
    .search-hero {
        /* REDEFINIMOS LAS VARIABLES: El título AHORA SERÁ BLANCO */
        --hero-tag-color: #f3f4f6 !important; /* Gris muy claro/blanco */
        --hero-text-secondary: #9ca3af !important; /* Gris claro */
        /* El azul lo mantenemos igual porque resalta bien */
    }
}

/* --- 3. ESTILOS DE LOS ELEMENTOS (USANDO LAS VARIABLES) --- */

.search-container {
    display: flex;
    align-items: center; /* Alineación vertical central */
    gap: 12px; /* Espacio entre "Explorando..." y el bloque azul */
    flex-wrap: wrap; /* Ajuste para móviles */
    justify-content: flex-start; /* Todo a la izquierda */
}

/* Texto: "Explorando por color" */
.search-label {
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0;
    /* Usamos la variable secundaria */
    color: var(--hero-text-secondary);
    white-space: nowrap;
}

/* El bloque con la línea azul */
.search-content {
    display: flex;
    align-items: center;
    gap: 12px;
    /* La línea azul vertical */
    border-left: 4px solid var(--hero-accent-line);
    padding-left: 14px;
    line-height: 1.1;
}

.search-tag {
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;

    /* 🔥 FIX REAL */
    color: var(--hero-main);
}

/* Texto: "X fonditos encontrados" */
.search-count {
    font-size: 0.95rem;
    margin: 0;
    /* Variable secundaria */
    color: var(--hero-text-secondary);
    align-self: flex-end; /* Alinea abajo con el texto grande */
    padding-bottom: 4px;
}

/* --- 4. RESPONSIVE (MÓVILES) --- */
@media (max-width: 600px) {
    .search-tag {
        font-size: 1.7rem; /* Texto más pequeño en móvil */
    }
    
    .search-container {
        gap: 8px;
    }
    
    .search-label {
        width: 100%; /* La etiqueta salta arriba */
        margin-bottom: 4px;
    }

    .search-content {
        padding-left: 10px;
    }
}


/* ============================================================
   SEARCH COMO EDGE-CONTENT (MISMO LAYOUT DEL HOME)
============================================================ */


.page-wrapper.page-search {
    padding: 0 5% 40px 5% !important;
}



/* ============================================================
   GRID PHONE — IGUAL AL HOME
============================================================ */

#tab-phone .search-grid-phone {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    width: 100%;
}

/* ============================================================
   GRID PC — IGUAL AL HOME
============================================================ */

#tab-pc .search-grid-pc {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    width: 100%;
}

/* ============================================================
   BREAKPOINTS EXACTOS DEL HOME
============================================================ */

/* MÓVIL */
@media (max-width: 649px) {

    #tab-phone .search-grid-phone {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 0 !important;
    }

    #tab-pc .search-grid-pc {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        padding: 0 !important;
    }
}

/* TABLET */
@media (min-width: 650px) and (max-width: 1023px) {

    #tab-phone .search-grid-phone {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }

    #tab-pc .search-grid-pc {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
}

/* DESKTOP */
@media (min-width: 1024px) {

    #tab-pc .search-grid-pc {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)) !important;
        gap: 25px;
    }
}

/* ============================================================
   IMÁGENES — IGUAL AL HOME
============================================================ */

/* PHONE = 11/16 */
#tab-phone .vertical-img {
    width: 100%;
    aspect-ratio: 11 / 16 !important;
    object-fit: cover;
    border-radius: 20px;
}

/* PC = 16/9 */
#tab-pc .horizontal-img {
    width: 100%;
    aspect-ratio: 16 / 9 !important;
    object-fit: cover;
    border-radius: 20px;
}

/* ============================================================
   TARJETAS — IGUAL AL HOME
============================================================ */

.search-card {
    position: relative;
    background-color: var(--bg-card) !important;
    border: 1px solid var(--bg-card-border);
    border-radius: 20px;
    overflow: hidden;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.2, 1, 0.3, 1), box-shadow 0.4s ease;
}

.search-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}

/* META */
.search-meta {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    color: #fff;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}



/* META — versión pastilla, sin desbordes */
.search-meta {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: auto;                          /* 🔥 ya no ocupa todo el ancho */

    max-width: calc(100% - 20px);         /* 🔒 nunca se sale de la tarjeta */

    padding: 6px 10px;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    color: #fff;
    border-radius: 999px;                 /* 🔵 pastilla redonda */
    font-size: 0.8rem;
    font-weight: 500;

    display: inline-flex;                 /* 🔥 se ajusta al texto */
    align-items: center;
    box-sizing: border-box;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   TABS (NO TOCAR, MUY IMPORTANTE
============================================================ */

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   SAFARI iPhone — Reducir margen lateral, y altura, NO TOCAR 
============================================================ */


@supports (-webkit-touch-callout: none) {

    .page-wrapper.page-search {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

/* 1. LIMPIEZA TOTAL: Evita que se sume espacio al Bloque Maestro */
.page-wrapper.page-search .edge-content,
.page-wrapper.page-color .edge-content,
.page-wrapper.page-tags .edge-content {
    padding-top: 0 !important; 
}

/* 2. EL MARGEN DE ESCRITORIO (Tus 10px de pelitos) */
.page-wrapper.page-search .tag-scroller,
.page-wrapper.page-color .tag-scroller,
.page-wrapper.page-tags .tag-scroller {
    margin-top: 0px !important; /* <--- Este es el que manda en PC */
    margin-bottom: 20px;
}

/* 3. MANTENER EL NIVEL EN MÓVIL */
@media (max-width: 649px) {
    .page-wrapper.page-search .tag-scroller,
    .page-wrapper.page-color .tag-scroller,
    .page-wrapper.page-tags .tag-scroller {
        margin-top: 0px !important; /* En móvil lo pegamos al header de 70px */
    }
}

/* ============================================================
     Efecto borroso igual al Home */
============================================================ */
img.lazy {
    filter: blur(20px);
    opacity: 0.3;
    transition: filter .3s ease, opacity .3s ease;
}

img.lazy.loaded {
    filter: blur(0);
    opacity: 1;
}



/* ============================================================
   PÁGINAS SECUNDARIAS (Color, Categorías, Search, Tags)
============================================================ */

.page-wrapper.page-color,
.page-wrapper.page-category,
.page-wrapper.page-search,
.page-wrapper.page-tags {
    padding: 0 5% 40px 5% !important;
}

/* Safari iPhone — corrección universal */
@supports (-webkit-touch-callout: none) {
    .page-wrapper.page-color,
    .page-wrapper.page-category,
    .page-wrapper.page-search,
    .page-wrapper.page-tags {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}


/* ============================================================
   SUGERENCIAS DEL SEARCH
============================================================ */

.search-bar-wrapper .search-bar {
    /* Usamos tus variables de tarjeta y texto */
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--bg-card-border) !important;

    /* Mantenemos el look premium de Apple */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);

    /* --- AJUSTES PARA RESPONSIVE Y CENTRADO --- */
    width: 100%;
    max-width: 100%;       /* Asegura que no sobrepase el padre */
    box-sizing: border-box; /* Crucial: el padding ya no suma al ancho total */
    margin: 0 auto;        /* Centra el elemento horizontalmente */
    
    height: 54px;
    padding: 0 20px 0 50px;
    font-size: 16px !important;
    border-radius: 18px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-appearance: none;
}

/* --- 2. FOCO AZUL (AZUL FONDITOS) --- */

.search-bar-wrapper .search-bar:focus {
    border-color: #007aff !important;
    /* Reducimos el transform en móvil para evitar saltos visuales de overflow */
    transform: translateY(-2px);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

/* --- 3. ICONO DE LUPA --- */

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-main);
    opacity: 0.5;
    z-index: 5;
    pointer-events: none;
}
/* ============================
   4. CONTENEDOR DE RESULTADOS
============================ */

.live-results-container {
    /* Mantenemos tu estilo Premium */
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--bg-card-border) !important;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: var(--shadow-soft);
    
    /* Nueva lógica de posicionamiento */
    position: absolute;
    top: 54px;      /* La altura exacta de tu search-bar */
    left: 0;        /* Alineado al borde izquierdo del input */
    right: 0;       /* Alineado al borde derecho del input */
    margin-top: 8px; /* Un pequeño espacio elegante entre el input y la lista */
    
    /* Estructura */
    border-radius: 18px;
    padding: 10px;
    z-index: 9999;
    display: none;
    box-sizing: border-box; /* Evita que el padding rompa el ancho del 100% */

    /* Scroll y límites */
    min-height: 50px;
    max-height: 450px;
    overflow-y: auto;
}

/* 1. Aseguramos que el contenedor se muestre cuando JS añade .is-active */
.live-results-container.is-active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* Un z-index alto para que flote sobre todo lo demás */
    z-index: 99999 !important;
}

/* 4. Por si el JS usa otra clase para mostrarlo, cubrimos ambas */
.live-results-container:not([style*="display: none"]) {
    z-index: 99999;
}

/* ============================
   5. TARJETAS Y TEXTOS
============================ */

.live-result-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 15px;
    text-decoration: none;
    color: var(--text-main) !important;
    transition: background 0.2s ease;
}

/* 2. Fix para que el texto sea visible (usando tus variables) */
.live-results-container .live-result-item {
    display: flex !important;
    color: var(--text-main) !important;
}

.live-result-item:hover {
    background: var(--hover-bg) !important;
}

.result-thumb {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
    margin-right: 15px;
    background-size: cover;
    background-position: center;
    background-color: var(--hover-bg);
    flex-shrink: 0;
}

.tag-icon {
    /* Un toque de color azul para los tags */
    background-color: rgba(0, 122, 255, 0.1) !important;
    color: #007aff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.result-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 2. Fix para que el texto sea visible (usando tus variables) */
.live-results-container .result-title {
    color: var(--text-main) !important;
    font-size: 15px;
    font-weight: 600;
}

.result-type {
    font-size: 11px;
    opacity: 0.6;
    text-transform: uppercase;
}

/* ============================
   6. SOPORTE DE DISEÑO
============================ */

.search-bar-wrapper {
    position: relative;
    width: 100%;
    max-width: 550px;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

.search-bar-note {
    display: block;     /* Ocupa toda la línea */
    width: 100%;        /* Se estira al ancho total del wrapper */
    text-align: center; /* Centrado real en Chrome/Safari */
    margin-top: 15px;   /* Separa el texto del buscador */
}


.categories-page {
    padding-top: 60px !important;
}

@media (max-width: 600px) {
    .categories-page {
        padding-top: 40px !important;
    }
}


/* ============================================================
   MENÚ DE COLORES FLOTANTE
============================================================ */

/* Contenedor principal - Mantiene la posición exacta */
.search-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Menú de colores */
.color-dropdown {
    display: flex;
    gap: 8px;
}

/* Chips mini con acabado de GEMA */
.color-chip-mini {
    /* Tamaños fluidos originales respetados */
    width: clamp(16px, 4vw, 22px);
    height: clamp(16px, 4vw, 22px);
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex-shrink: 1;
    
    /* Variable de color */
    background-color: var(--chip-color);
    
    /* MEJORA 1: Iluminación 3D (Brillo a las 10 en punto) */
    background-image: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.3) 0%, transparent 60%);
    
    /* MEJORA 2: Borde óptico y profundidad */
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.15), 
        inset 0 -2px 3px rgba(0, 0, 0, 0.2);
    
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* HOVER: Glow dinámico y elevación */
.color-chip-mini:hover {
    transform: translateY(-2px) scale(1.15);
    /* MEJORA 3: El brillo proyecta el color del propio chip */
    box-shadow: 
        0 6px 12px -2px rgba(0, 0, 0, 0.2),
        0 0 12px var(--chip-color);
    z-index: 10;
}

/* ESTADO ACTIVO: El "Anillo de Aire" estilo Apple */
.color-chip-mini.active {
    border-color: rgba(255, 255, 255, 0.9);
    /* El primer shadow crea un anillo del color del fondo para separar el chip del borde */
    box-shadow: 
        0 0 0 2px var(--bg-main), 
        0 0 0 4px var(--chip-color);
}

/* Punto central del activo */
.color-chip-mini.active::after {
    content: "";
    position: absolute;
    inset: 5px; /* Más fino y elegante */
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* Soporte para chips muy claros o blancos */
.color-chip-mini[style*="#ffffff"]::after,
.color-chip-mini[style*="white"]::after {
    background: #1a1a1a;
}

/* Soporte para modo oscuro cuando el chip es negro */
html.system-dark .color-chip-mini[style*="black"],
html.system-dark .color-chip-mini[style*="#000000"] {
    border: 1px solid rgba(255,255,255,0.3);
}