/* Paleta de Colores y Estilos Personalizados */
:root {
    --primary-blue: #3B82F6;
    --dark-blue: #1E293B;
    --bg-gray: #F8FAFC;
    --success-green: #10B981;
    --text-gray: #4B5563;
    --accent-gold: #F59E0B;
    --card-radius: 18px;
}

body {
    background-color: var(--bg-gray);
    color: var(--dark-blue);
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
}

/* Respeta preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

html {
    scroll-behavior: smooth;
}

/* ======================================================
   PARTE 1: TARJETAS PREMIUM
   ====================================================== */

.tool-card {
    position: relative;
    border-radius: var(--card-radius);
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #E2E8F0;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.35s ease;
    will-change: transform;
}

/* Halo de gradiente que aparece detrás de la tarjeta al hacer hover */
.tool-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--card-radius);
    background: linear-gradient(135deg, var(--primary-blue), var(--success-green));
    opacity: 0;
    z-index: -1;
    transition: opacity 0.35s ease;
}

.tool-card:hover {
    transform: translateY(-8px) scale(1.015);
    box-shadow: 0 20px 35px -10px rgba(59, 130, 246, 0.25), 0 8px 16px -8px rgba(0, 0, 0, 0.1);
    border-color: transparent;
}

.tool-card:hover::before {
    opacity: 1;
}

/* Contenedor interno para que el halo no tape el contenido */
.tool-card-inner {
    background: #ffffff;
    border-radius: calc(var(--card-radius) - 1px);
    height: 100%;
    padding: 1.5rem;
    position: relative;
}

/* Icono dentro de un círculo con fondo de color, con leve animación al hover */
.tool-icon-badge {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    border-radius: 14px;
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
    margin-bottom: 1rem;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.4s ease;
}

.tool-card:hover .tool-icon-badge {
    transform: rotate(-8deg) scale(1.12);
    background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
}

/* Botón "Probar" rediseñado, con flecha animada */
.tool-try-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--primary-blue);
    padding: 0.5rem 0;
    position: relative;
}

.tool-try-btn .arrow {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tool-card:hover .tool-try-btn .arrow {
    transform: translateX(5px);
}

.tool-try-btn::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: var(--primary-blue);
    transition: width 0.3s ease;
}

.tool-card:hover .tool-try-btn::after {
    width: 100%;
}

/* Badge PRO con brillo animado */
.badge-pro {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: linear-gradient(110deg, #F59E0B, #FBBF24, #F59E0B);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    box-shadow: 0 4px 10px -2px rgba(245, 158, 11, 0.5);
    overflow: hidden;
}

.badge-pro::after {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.65), transparent);
    transform: skewX(-20deg);
    animation: badgeShine 2.6s ease-in-out infinite;
}

@keyframes badgeShine {
    0% { left: -75%; }
    35% { left: 130%; }
    100% { left: 130%; }
}

/* Estrella de favoritos mejorada */
.fav-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.fav-btn:hover {
    transform: scale(1.15);
}

.fav-btn.is-fav {
    animation: favPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes favPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.4) rotate(-10deg); }
    70% { transform: scale(0.9) rotate(5deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Animación Fade-In */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* ======================================================
   PARTE 2: MICROINTERACCIONES
   ====================================================== */

/* Aparición al hacer scroll (controlada por IntersectionObserver en script.js) */
.scroll-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.scroll-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Estilo para los botones de categoría activos */
.category-btn.active {
    background-color: var(--primary-blue);
    color: white;
}

.category-btn {
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.category-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px -6px rgba(59, 130, 246, 0.35);
}

.category-btn:active {
    transform: translateY(-1px) scale(0.97);
}

/* Buscador con efecto glow al enfocar */
#search-input {
    transition: box-shadow 0.4s ease, transform 0.2s ease;
}

#search-input:focus {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35), 0 0 28px 4px rgba(59, 130, 246, 0.55);
    transform: translateY(-1px);
}

/* Animación general de "press" para botones principales */
.btn-press {
    transition: transform 0.15s ease, box-shadow 0.25s ease;
}

.btn-press:active {
    transform: scale(0.95);
}

/* Chips de historial de búsqueda */
.history-chip {
    animation: chipIn 0.3s ease-out;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.history-chip:hover {
    transform: translateY(-2px);
}

@keyframes chipIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

/* Optimización para móviles (Mobile-First) */
@media (max-width: 640px) {
    h1 {
        font-size: 2.5rem;
    }
    .category-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* Estilos para el banner de AdSense */
.adsense-placeholder {
    border: 2px dashed #CBD5E1;
    background-color: #F1F5F9;
}

/* Estilos para Modo Oscuro */
body.dark-mode {
    background-color: #0F172A;
    color: #F1F5F9;
}

.dark-mode .bg-white {
    background-color: #1E293B;
}

.dark-mode .text-gray-800, 
.dark-mode .text-gray-700, 
.dark-mode .text-gray-600 {
    color: #E2E8F0;
}

.dark-mode .shadow-md, 
.dark-mode .shadow-sm {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

.dark-mode .border-gray-100 {
    border-color: #334155;
}

.dark-mode .bg-gray-200 {
    background-color: #334155;
    color: #F1F5F9;
}

.dark-mode .bg-gray-100 {
    background-color: #0F172A;
}

.dark-mode .category-btn:not(.bg-blue-500) {
    background-color: #334155;
    color: #E2E8F0;
}

.dark-mode .category-btn:hover:not(.bg-blue-500) {
    background-color: #475569;
}

.dark-mode .adsense-placeholder {
    background-color: #334155;
    border-color: #475569;
    color: #CBD5E1;
}

/* Estilos para la Sección de Sugerencias */
#suggestion-section {
    transition: all 0.5s ease-in-out;
}

#suggestion-section.hidden {
    display: none;
    opacity: 0;
    max-height: 0;
}

#suggestion-section:not(.hidden) {
    display: block;
    opacity: 1;
    max-height: 2000px; /* Suficiente para el formulario */
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ajustes de Modo Oscuro para la Sección de Sugerencias */
.dark-mode #suggestion-section {
    background-color: #1E293B;
    border-color: #334155;
}

.dark-mode .form-container {
    background-color: #0F172A;
}

/* Estilos para el Acordeón FAQ */
.faq-question.active .faq-icon {
    transform: rotate(180deg);
}

.faq-answer:not(.hidden) {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.dark-mode .faq-item {
    background-color: #1E293B;
    border-color: #334155;
}

.dark-mode .faq-question {
    color: #F1F5F9;
}

.dark-mode .faq-question:hover {
    background-color: #334155;
}

.dark-mode .faq-answer {
    color: #CBD5E1;
    border-color: #334155;
}

/* Sección Hero Principal con Imagen */
.hero-header {
    width: 100%;
    min-height: 500px; /* Ajusta según el alto que desees */
    background-image: url('images/hero-2026.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: white;
    text-align: center;
    padding: 2rem;
}

/* Capa con gradiente para que el texto sea legible sobre la imagen */
.hero-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.78) 0%, rgba(30, 64, 175, 0.55) 55%, rgba(15, 23, 42, 0.82) 100%);
    z-index: 1;
}

/* Brillo ambiental sutil detrás del contenido del hero */
.hero-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(59, 130, 246, 0.35), transparent 70%);
    z-index: 1;
    pointer-events: none;
}

/* Canvas de red de nodos/líneas animadas (estilo Vercel/OpenAI).
   Va arriba de la imagen de fondo pero abajo del overlay oscuro y del texto. */
.hero-network-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
    pointer-events: none;
}

/* Asegurar que el contenido del hero esté sobre la capa oscura
   (el canvas queda excluido a propósito, ya tiene su propio z-index más bajo arriba) */
.hero-header > *:not(.hero-network-canvas) {
    position: relative;
    z-index: 2;
}

/* Ajuste para móviles */
@media (max-width: 640px) {
    .hero-header {
        min-height: 350px;
    }
}

/* --- Estilos para el Chatbot --- */
#chat-input {
    background-color: #ffffff !important;
    color: #1f2937 !important;
    border: 1px solid #d1d5db;
}

#chat-response {
    color: #0a58df;
}

/* ======================================================
   PARTE 3: ACABADO PREMIUM
   ====================================================== */

/* --- Navbar sticky --- */
.sticky-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateY(-100%);
    transition: transform 0.35s ease;
}

.sticky-nav.is-visible {
    transform: translateY(0);
}

.sticky-nav .nav-link {
    color: #CBD5E1;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.sticky-nav .nav-link:hover,
.sticky-nav .nav-link.active {
    color: #ffffff;
}

.sticky-nav .nav-logo {
    color: #ffffff;
    font-weight: 800;
    font-size: 1.05rem;
}

.nav-toggle-btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.nav-toggle-btn:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background-color: rgba(255, 255, 255, 0.08);
}

/* --- Hero badge moderno --- */
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    margin-bottom: 1.25rem;
    animation: fadeIn 0.6s ease-out;
}

.hero-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-green);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* --- Historial de búsqueda (chips bajo el buscador) --- */
.history-chip {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    cursor: pointer;
}

.history-chip:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* --- Sección Tendencias --- */
.trend-card {
    flex: 0 0 auto;
    width: 230px;
    scroll-snap-align: start;
}

.trend-rank {
    font-size: 2.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-blue), #93C5FD);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1;
}

.trend-scroller {
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
}

/* Truncado de texto a 3 líneas (line-clamp no está disponible en Tailwind 2.x) */
.clamp-3-lines {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Sección Favoritos --- */
#favorites-section.is-empty .favorites-empty-msg {
    display: block;
}

.favorites-empty-msg {
    display: none;
}

/* --- Footer ampliado --- */
.site-footer {
    background: var(--dark-blue);
    color: #CBD5E1;
}

.site-footer h4 {
    color: #ffffff;
    font-weight: 700;
    margin-bottom: 0.9rem;
}

.site-footer a {
    color: #CBD5E1;
    transition: color 0.2s ease, padding-left 0.2s ease;
    display: inline-block;
}

.site-footer a:hover {
    color: #ffffff;
    padding-left: 4px;
}

.site-footer .footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.social-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.25s ease, transform 0.25s ease;
}

.social-icon:hover {
    background: var(--primary-blue);
    transform: translateY(-3px);
}

/* --- Soporte Modo Oscuro para elementos nuevos --- */
.dark-mode .tool-card {
    background: #1E293B;
    border-color: #334155;
}

.dark-mode .tool-card-inner {
    background: #1E293B;
}

.dark-mode .tool-icon-badge {
    background: linear-gradient(135deg, #334155, #1E293B);
}

.dark-mode .fav-btn {
    background: rgba(30, 41, 59, 0.85);
}

.dark-mode .trend-card .tool-card,
.dark-mode .site-footer {
    background: #0F172A;
}

.dark-mode #search-input {
    background-color: #1E293B;
    color: #F1F5F9;
}

/* ======================================================
   PARTE 4: BADGES, COLOR POR CATEGORÍA, AUTOCOMPLETADO,
   CONTADORES Y FAVORITOS REFINADOS
   ====================================================== */

/* --- Badge Gratis / Freemium --- */
.badge-pricing {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    text-transform: uppercase;
}

.badge-pricing.is-free {
    background: #DCFCE7;
    color: #15803D;
}

.badge-pricing.is-freemium {
    background: #F3E8FF;
    color: #7E22CE;
}

/* Si ya hay un badge PRO en la misma tarjeta, el de precio se corre debajo */
.tool-card .badge-pro + .badge-pricing,
.tool-card .badge-pricing + .badge-pro {
    top: 48px;
}

.dark-mode .badge-pricing.is-free {
    background: rgba(21, 128, 61, 0.25);
    color: #4ADE80;
}

.dark-mode .badge-pricing.is-freemium {
    background: #581C87;
    color: #E9D5FF;
}

/* --- Sistema de colores por categoría --- */
/* Cada categoría define su propio color de acento vía variable CSS,
   aplicada al borde izquierdo del ícono y al halo de hover de la tarjeta. */
.tool-card[data-category-color="remoto"] .tool-icon-badge { background: linear-gradient(135deg, #EFF6FF, #BFDBFE); }
.tool-card[data-category-color="remoto"]::before { background: linear-gradient(135deg, #3B82F6, #1D4ED8); }

.tool-card[data-category-color="educacion"] .tool-icon-badge { background: linear-gradient(135deg, #F0FDF4, #BBF7D0); }
.tool-card[data-category-color="educacion"]::before { background: linear-gradient(135deg, #10B981, #047857); }

.tool-card[data-category-color="hogar"] .tool-icon-badge { background: linear-gradient(135deg, #FFF7ED, #FED7AA); }
.tool-card[data-category-color="hogar"]::before { background: linear-gradient(135deg, #F59E0B, #C2410C); }

.tool-card[data-category-color="creatividad"] .tool-icon-badge { background: linear-gradient(135deg, #FDF4FF, #F5D0FE); }
.tool-card[data-category-color="creatividad"]::before { background: linear-gradient(135deg, #D946EF, #A21CAF); }

.tool-card[data-category-color="tramites"] .tool-icon-badge { background: linear-gradient(135deg, #F0F9FF, #BAE6FD); }
.tool-card[data-category-color="tramites"]::before { background: linear-gradient(135deg, #0EA5E9, #0369A1); }

.tool-card[data-category-color="avanzada"] .tool-icon-badge { background: linear-gradient(135deg, #FEF2F2, #FECACA); }
.tool-card[data-category-color="avanzada"]::before { background: linear-gradient(135deg, #EF4444, #B91C1C); }

/* Pequeña etiqueta de categoría con su color, dentro de la tarjeta */
.category-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    margin-bottom: 0.5rem;
}

.tool-card[data-category-color="remoto"] .category-tag { background: #DBEAFE; color: #1D4ED8; }
.tool-card[data-category-color="educacion"] .category-tag { background: #D1FAE5; color: #047857; }
.tool-card[data-category-color="hogar"] .category-tag { background: #FFEDD5; color: #C2410C; }
.tool-card[data-category-color="creatividad"] .category-tag { background: #FAE8FF; color: #A21CAF; }
.tool-card[data-category-color="tramites"] .category-tag { background: #E0F2FE; color: #0369A1; }
.tool-card[data-category-color="avanzada"] .category-tag { background: #FEE2E2; color: #B91C1C; }

.dark-mode .tool-card[data-category-color="remoto"] .category-tag { background: rgba(29, 78, 216, 0.25); color: #93C5FD; }
.dark-mode .tool-card[data-category-color="educacion"] .category-tag { background: rgba(4, 120, 87, 0.25); color: #6EE7B7; }
.dark-mode .tool-card[data-category-color="hogar"] .category-tag { background: rgba(194, 65, 12, 0.25); color: #FDBA74; }
.dark-mode .tool-card[data-category-color="creatividad"] .category-tag { background: rgba(162, 28, 175, 0.25); color: #F0ABFC; }
.dark-mode .tool-card[data-category-color="tramites"] .category-tag { background: rgba(3, 105, 161, 0.25); color: #7DD3FC; }
.dark-mode .tool-card[data-category-color="avanzada"] .category-tag { background: rgba(185, 28, 28, 0.25); color: #FCA5A5; }

/* --- Animación refinada de favoritos --- */
/* Reemplaza el "pop" simple por un latido más suave + partículas de brillo */
.fav-btn.is-fav {
    animation: favHeartbeat 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes favHeartbeat {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.3); }
    50%  { transform: scale(0.95); }
    70%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Destello radial que se expande y desaparece al marcar como favorito */
.fav-btn {
    overflow: visible;
}

.fav-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
}

.fav-btn.is-fav::after {
    animation: favBurst 0.6s ease-out;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.55) 0%, transparent 70%);
}

@keyframes favBurst {
    0%   { transform: scale(0.6); opacity: 0.9; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* --- Autocompletado del buscador --- */
.search-wrapper {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 18px 30px -8px rgba(15, 23, 42, 0.25);
    overflow: hidden;
    z-index: 30;
    text-align: left;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.autocomplete-list.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    color: #1E293B;
    font-size: 0.92rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.autocomplete-item:hover,
.autocomplete-item.is-active {
    background-color: #EFF6FF;
}

.autocomplete-item .ac-icon {
    font-size: 1.1rem;
}

.autocomplete-item .ac-cat {
    margin-left: auto;
    font-size: 0.72rem;
    color: #94A3B8;
}

.dark-mode .autocomplete-list {
    background: #1E293B;
}

.dark-mode .autocomplete-item {
    color: #F1F5F9;
}

.dark-mode .autocomplete-item:hover,
.dark-mode .autocomplete-item.is-active {
    background-color: #334155;
}

/* --- Contadores animados en el hero --- */
.hero-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2.5rem;
    margin-top: 1.75rem;
}

.hero-stat {
    text-align: center;
}

.hero-stat-number {
    font-size: 2.1rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.hero-stat-label {
    font-size: 0.8rem;
    color: #CBD5E1;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

@media (max-width: 640px) {
    .hero-stats {
        gap: 1.5rem;
    }
    .hero-stat-number {
        font-size: 1.6rem;
    }
}

/* ======================================================
   PARTE 5: ASISTENTE DEL DIRECTORIO (CHATBOT MEJORADO)
   ====================================================== */

#chat-window {
    animation: chatWindowIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes chatWindowIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tamaño y posición del chat en MOBILE: márgenes simétricos a ambos lados
   (en vez de un ancho fijo anclado solo a la derecha, que en pantallas chicas
   quedaba desproporcionado y pegado hacia un costado) */
.chat-window-mobile {
    bottom: 5.5rem !important;
    left: 1rem !important;
    right: 1rem !important;
    width: auto !important;
    max-height: min(75vh, 560px) !important;
}

.chat-messages-area {
    max-height: 50vh;
}

/* Desde tablets/desktop en adelante, volvemos al comportamiento de ventana
   flotante clásica con ancho fijo anclada a la esquina inferior derecha.
   Fijamos TODAS las propiedades explícitamente (no solo "left: auto") para
   que no quede ninguna heredada de la regla mobile de arriba. */
@media (min-width: 640px) {
    .chat-window-mobile {
        bottom: 6rem !important;
        left: auto !important;
        right: 1.5rem !important;
        width: 24rem !important;
        max-height: 70vh !important;
    }

    .chat-messages-area {
        max-height: 45vh;
    }
}

.chat-bubble {
    max-width: 85%;
    padding: 0.6rem 0.9rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.45;
    animation: chatBubbleIn 0.25s ease-out;
}

@keyframes chatBubbleIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.from-bot {
    background: #EFF6FF;
    color: #1E293B;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.chat-bubble.from-user {
    background: var(--primary-blue);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    margin-left: auto;
}

.chat-bubble-row {
    display: flex;
}

/* Mini tarjeta de herramienta sugerida dentro del chat */
.chat-tool-suggestion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
    margin-top: 0.4rem;
    text-decoration: none;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.chat-tool-suggestion:hover {
    border-color: var(--primary-blue);
    transform: translateX(2px);
}

.chat-tool-suggestion .cts-icon {
    font-size: 1.1rem;
}

.chat-tool-suggestion .cts-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1E293B;
}

.chat-tool-suggestion .cts-cat {
    font-size: 0.7rem;
    color: #94A3B8;
}

/* Chips de sugerencias dinámicas bajo los mensajes */
.chat-suggestion-chip {
    background: #DBEAFE;
    color: #1D4ED8;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.chat-suggestion-chip:hover {
    background: #BFDBFE;
    transform: translateY(-1px);
}

/* Indicador de "escribiendo..." */
.chat-typing {
    display: inline-flex;
    gap: 3px;
    padding: 0.6rem 0.9rem;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94A3B8;
    animation: chatTypingBounce 1.1s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Modo oscuro para el chat */
.dark-mode #chat-window {
    background: #1E293B;
    border-color: #334155;
}

.dark-mode #chat-window h3 {
    color: #F1F5F9;
}

.dark-mode .chat-bubble.from-bot {
    background: #334155;
    color: #F1F5F9;
}

.dark-mode .chat-tool-suggestion {
    background: #0F172A;
    border-color: #334155;
}

.dark-mode .chat-tool-suggestion .cts-name {
    color: #F1F5F9;
}

.dark-mode #chat-input {
    background-color: #ffffff !important;
}

/* ======================================================
   PARTE 6: COMPARADOR DE HERRAMIENTAS
   ====================================================== */

/* Botones de comparaciones curadas (accesos rápidos) */
.curated-comparison-btn {
    background: #ffffff;
    border: 1.5px solid #E2E8F0;
    color: #1E293B;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.curated-comparison-btn:hover {
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -6px rgba(59, 130, 246, 0.25);
}

/* Filtros rápidos por dificultad y velocidad */
.qf-btn {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1.5px solid #E2E8F0;
    background: #F8FAFC;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.qf-btn:hover {
    background: #EFF6FF;
    border-color: #93C5FD;
    color: #1D4ED8;
}
.qf-btn.active {
    background: #2563EB;
    border-color: #2563EB;
    color: #fff;
}
.qf-sep {
    color: #CBD5E1;
    font-size: 1.1rem;
    line-height: 1;
    align-self: center;
    padding: 0 0.25rem;
    user-select: none;
}
.dark .qf-btn {
    background: #1E293B;
    border-color: #334155;
    color: #94A3B8;
}
.dark .qf-btn:hover {
    background: #1E3A5F;
    border-color: #60A5FA;
    color: #93C5FD;
}
.dark .qf-btn.active {
    background: #2563EB;
    border-color: #2563EB;
    color: #fff;
}
.dark .qf-sep {
    color: #475569;
}

/* Selectores del comparador libre */
.compare-select {
    background-color: #ffffff;
    color: #1E293B;
    cursor: pointer;
    border: 1.5px solid #E2E8F0;
    padding: 0.65rem 2.2rem 0.65rem 0.9rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.compare-select:hover {
    border-color: #CBD5E1;
}

.compare-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Tabla comparativa */
#comparison-result {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    padding-bottom: 4px; /* deja ver la sombra inferior de la tabla al scrollear */
}

/* Barra de scroll discreta, consistente con la estética del sitio */
#comparison-result::-webkit-scrollbar {
    height: 8px;
}

#comparison-result::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 999px;
}

.dark-mode #comparison-result::-webkit-scrollbar-thumb {
    background: #475569;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 25px -8px rgba(15, 23, 42, 0.12);
    margin: 0 auto;
}

.comparison-table th,
.comparison-table td {
    padding: 0.9rem 1.1rem;
    text-align: left;
    border-bottom: 1px solid #F1F5F9;
    font-size: 0.88rem;
    vertical-align: top;
    white-space: normal;
    min-width: 160px;
}

.comparison-table thead th {
    background: linear-gradient(135deg, #1E293B, #334155);
    color: #ffffff;
    border-bottom: none;
}

.comparison-table tbody tr:last-child td {
    border-bottom: none;
}

.comparison-table tbody tr:hover td {
    background-color: #F8FAFC;
}

.comparison-row-label {
    font-weight: 700;
    color: #64748B;
    background: #F8FAFC;
    min-width: 130px;
    white-space: nowrap;
}

.comparison-tool-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.comparison-tool-icon {
    font-size: 1.5rem;
}

.comparison-tool-name {
    font-weight: 800;
    font-size: 1rem;
}

.comparison-tool-link {
    font-size: 0.75rem;
    color: #93C5FD;
    text-decoration: underline;
}

/* Modo oscuro del comparador */
.dark-mode .curated-comparison-btn {
    background: #1E293B;
    border-color: #334155;
    color: #F1F5F9;
}

.dark-mode .compare-select {
    background-color: #0F172A;
    color: #F1F5F9;
    border-color: #475569;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23CBD5E1' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
}

.dark-mode .compare-select:hover {
    border-color: #64748B;
}

.dark-mode .compare-select option,
.dark-mode .compare-select optgroup {
    background-color: #0F172A;
    color: #F1F5F9;
}

.dark-mode .comparison-table {
    background: #1E293B;
}

.dark-mode .comparison-table th,
.dark-mode .comparison-table td {
    border-bottom-color: #334155;
    color: #E2E8F0;
}

.dark-mode .comparison-row-label {
    background: #0F172A;
    color: #94A3B8;
}

.dark-mode .comparison-table tbody tr:hover td {
    background-color: #0F172A;
}

/* Responsive: reducimos el ancho mínimo de las celdas progresivamente,
   así la tabla necesita scrollear lo menos posible en pantallas chicas/medianas */
@media (max-width: 1024px) {
    .comparison-table th,
    .comparison-table td {
        min-width: 150px;
    }
}

@media (max-width: 640px) {
    .comparison-table th,
    .comparison-table td {
        font-size: 0.8rem;
        padding: 0.7rem 0.8rem;
        min-width: 130px;
    }

    .comparison-row-label {
        min-width: 100px;
    }
}

/* ======================================================
   PARTE 7: PUNTUACIÓN, VELOCIDAD, DIFICULTAD, ETIQUETAS
   ====================================================== */

/* --- Rating (estrellas + número) en tarjetas --- */
.tool-rating {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.rating-stars {
    font-size: 0.85rem;
    letter-spacing: -1px;
}

.rating-score {
    font-size: 0.8rem;
    font-weight: 800;
    color: #F59E0B;
    background: #FEF3C7;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    line-height: 1.4;
}

.dark-mode .rating-score {
    background: rgba(245, 158, 11, 0.2);
    color: #FCD34D;
}

/* --- Badges de velocidad y dificultad --- */
.tool-meta-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.7rem;
}

.tool-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    letter-spacing: 0.01em;
}

.badge-speed {
    background: #EFF6FF;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
}

.badge-diff {
    background: #F8FAFC;
    color: #475569;
    border: 1px solid #E2E8F0;
}

.dark-mode .badge-speed {
    background: rgba(29, 78, 216, 0.2);
    color: #93C5FD;
    border-color: rgba(59, 130, 246, 0.3);
}

.dark-mode .badge-diff {
    background: rgba(71, 85, 105, 0.3);
    color: #CBD5E1;
    border-color: #475569;
}

/* --- Etiquetas especiales (🏆 🔥 💎 🚀) --- */
.tool-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.tool-label {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
    color: #92400E;
    border: 1px solid #FDE68A;
    letter-spacing: 0.02em;
}

.dark-mode .tool-label {
    background: rgba(146, 64, 14, 0.25);
    color: #FCD34D;
    border-color: rgba(252, 211, 77, 0.3);
}

/* ======================================================
   PARTE 8: COMPARADOR MEJORADO — PROS/CONTRAS Y RECOMENDACIÓN
   ====================================================== */

/* Rating en la cabecera de la tabla comparativa */
.comp-header-rating {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #F59E0B;
    background: #FEF3C7;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-top: 0.2rem;
}

.dark-mode .comp-header-rating {
    background: rgba(245, 158, 11, 0.2);
    color: #FCD34D;
}

/* Rating en filas de la tabla */
.comp-rating {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
}

/* Filas de pros */
.comp-pros-row td {
    background: #F0FDF4 !important;
}

.comp-pros-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.comp-pros-list li {
    font-size: 0.82rem;
    color: #166534;
    line-height: 1.35;
}

/* Filas de contras */
.comp-cons-row td {
    background: #FFF7F7 !important;
}

.comp-cons-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.comp-cons-list li {
    font-size: 0.82rem;
    color: #991B1B;
    line-height: 1.35;
}

/* Modo oscuro pros/contras */
.dark-mode .comp-pros-row td {
    background: rgba(22, 101, 52, 0.12) !important;
}

.dark-mode .comp-pros-list li {
    color: #86EFAC;
}

.dark-mode .comp-cons-row td {
    background: rgba(153, 27, 27, 0.12) !important;
}

.dark-mode .comp-cons-list li {
    color: #FCA5A5;
}

/* --- Bloque "Nuestra Recomendación" --- */
.comp-recommendation {
    margin-top: 1.25rem;
    background: linear-gradient(135deg, #1E293B, #1D4ED8);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    color: #ffffff;
    box-shadow: 0 8px 24px -6px rgba(29, 78, 216, 0.45);
    animation: fadeIn 0.5s ease-out;
}

.comp-rec-crown {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #FCD34D;
    margin-bottom: 0.5rem;
}

.comp-rec-winner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.comp-rec-icon {
    font-size: 2rem;
    line-height: 1;
}

.comp-rec-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: #ffffff;
}

.comp-rec-reason {
    font-size: 0.88rem;
    color: #CBD5E1;
    line-height: 1.5;
    margin: 0;
}

.comp-rec-reason strong {
    color: #ffffff;
}

@media (max-width: 640px) {
    .tool-meta-badges {
        gap: 0.25rem;
    }
    .tool-badge {
        font-size: 0.62rem;
        padding: 0.2rem 0.45rem;
    }
    .tool-label {
        font-size: 0.6rem;
    }
    .comp-recommendation {
        padding: 1rem;
    }
    .comp-rec-name {
        font-size: 1.15rem;
    }
}