/* ============================================================
TCC UI Helper v2.0 — Transiciones de colapso refinadas
Prefijo: tcc-uih-
No interfiere con style.css ni con ninguna otra clase.

Mejoras v2.0:
· Easing expo-out para colapso (sensación premium)
· Transform translateY sutil para profundidad
· Timings sincronizados entre max-height, opacity y transform
· Transiciones suaves en contenedor principal y form
· will-change dinámico (solo durante transición)
· Reduced motion: mantiene fade sutil (accesible)
· Comentarios explicativos sobre decisiones de diseño
============================================================ */

/* ── Elementos colapsables (hero + pre-chat) ─────────────── */
.tcc-uih-hero,
.tcc-uih-pre-chat {
    /* v2.0: Easing expo-out para sensación premium */
    transition:
        max-height 0.50s cubic-bezier(0.16, 1, 0.3, 1),
        opacity    0.35s cubic-bezier(0.4, 0, 0.2, 1),
        transform  0.45s cubic-bezier(0.16, 1, 0.3, 1),
        margin     0.45s cubic-bezier(0.16, 1, 0.3, 1),
        padding    0.45s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    will-change: max-height, opacity, transform;
    /* v2.0: transform inicial para poder animar */
    transform: translateY(0);
}

/* ── Modo búsqueda activa: colapsar hero y pre-chat ──────── */
body.tcc-uih-search-active .tcc-uih-hero,
body.tcc-uih-search-active .tcc-uih-pre-chat {
    max-height: 0 !important;
    opacity: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    pointer-events: none;
    /* v2.0: translateY sutil para sensación de "deslizamiento" */
    transform: translateY(-8px);
}

/* ── Ajustes del contenedor principal en modo búsqueda ───── */
/* v2.0: Añadida transición suave para evitar "salto" visual */
body.tcc-uih-search-active main.container {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    transition:
        margin 0.40s cubic-bezier(0.16, 1, 0.3, 1),
        padding 0.40s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Estado normal del contenedor (sin transición al cargar) */
main.container {
    transition:
        margin 0.40s cubic-bezier(0.16, 1, 0.3, 1),
        padding 0.40s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Formulario: pequeño respiro bajo el navbar sticky ───── */
/* v2.0: Transición suave en margins */
body.tcc-uih-search-active #search-form {
    margin-top: 0.25rem !important;
    margin-bottom: 0.5rem !important;
    transition:
        margin 0.40s cubic-bezier(0.16, 1, 0.3, 1);
}

#search-form {
    transition:
        margin 0.40s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Chat container: reducir margen superior ─────────────── */
body.tcc-uih-search-active #chat-container {
    margin-top: 0.5rem !important;
    transition:
        margin 0.40s cubic-bezier(0.16, 1, 0.3, 1);
}

#chat-container {
    transition:
        margin 0.40s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Maximizar altura del scroll del chat en móvil/tablet ── */
/*
El .tcc-chat-scroll original tiene max-height fijo (500px desktop,
400px ≤768px). En modo búsqueda activa se sobreescribe para que
el chat ocupe todo el viewport disponible menos navbar + form +
card-header. Se usa dvh (dynamic viewport height) con fallback
a vh para navegadores que no lo soporten.

v2.0: Añadida transición suave para evitar "salto" al expandir.
*/
body.tcc-uih-search-active .tcc-chat-scroll {
    max-height: calc(100vh - 190px) !important;
    max-height: calc(100dvh - 190px) !important;
    transition:
        max-height 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.tcc-chat-scroll {
    transition:
        max-height 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 768px) {
    body.tcc-uih-search-active .tcc-chat-scroll {
        max-height: calc(100vh - 170px) !important;
        max-height: calc(100dvh - 170px) !important;
    }
}

@media (max-width: 480px) {
    body.tcc-uih-search-active .tcc-chat-scroll {
        max-height: calc(100vh - 150px) !important;
        max-height: calc(100dvh - 150px) !important;
    }
}

/* ── Reduced motion ──────────────────────────────────────── */
/*
v2.0: En lugar de desactivar TODO, mantenemos el fade de opacidad
(que es accesible y no causa mareos) pero eliminamos el movimiento
de translateY y el colapso de max-height (que sí pueden causar
problemas vestibulares).
*/
@media (prefers-reduced-motion: reduce) {
    .tcc-uih-hero,
    .tcc-uih-pre-chat {
        /* Mantener fade de opacidad (accesible) */
        transition:
            opacity 0.25s ease,
            margin 0.01s,
            padding 0.01s !important;
        /* Eliminar transform y max-height animados */
        transform: none !important;
    }

    body.tcc-uih-search-active .tcc-uih-hero,
    body.tcc-uih-search-active .tcc-uih-pre-chat {
        /* Colapso instantáneo pero con fade */
        max-height: 0 !important;
        transform: none !important;
    }

    /* Contenedores: transición instantánea */
    main.container,
    #search-form,
    #chat-container,
    .tcc-chat-scroll {
        transition-duration: 0.01s !important;
    }
}

/* ── Print: no interferir ────────────────────────────────── */
@media print {
    body.tcc-uih-search-active .tcc-uih-hero,
    body.tcc-uih-search-active .tcc-uih-pre-chat {
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
        transform: none !important;
    }
}