#chat-window {
    display: flex;
    flex-direction: column;
}

#chat-window[hidden] {
    display: none;
}

#chat-window-content {
    flex: 1;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

#chat-message-list {
    height: 100%;
    padding: 16px;

    display: flex;
    flex-direction: column;
    gap: 18px;

    overflow-y: auto;
}

.chat-message {
    max-width: 80%;
    padding: 10px 14px;

    border-radius: 14px;
}

.chat-message p {
    margin: 0;
    line-height: 1.5;
}

.chat-message-content > *:first-child {
    margin-top: 0;
}

.chat-message-content > *:last-child {
    margin-bottom: 0;
}

.chat-message-content p {
    margin: 0 0 8px;
    line-height: 1.5;
}

.chat-message-content ul {
    margin: 0 0 8px;
    padding-left: 18px;
}

.chat-message-content li {
    margin-bottom: 2px;
    line-height: 1.4;
}

.chat-message-content strong {
    font-weight: 700;
}

.chat-message-content .chat-md-heading {
    margin: 10px 0 4px;

    font-weight: 700;
    font-size: 13px;
}

/* Respuesta del Inge: encabezado (avatar + nombre) arriba y el texto
   abajo, sin burbuja y a todo lo ancho, como en ChatGPT o Claude. Solo los
   mensajes del cliente llevan burbuja. */
.chat-message-row {
    align-self: stretch;

    display: flex;
    flex-direction: column;
    gap: 6px;

    max-width: 100%;
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-message-author {
    color: #374151;
    font-size: 13px;
    font-weight: 600;
}

.chat-message-avatar {
    flex-shrink: 0;

    width: 26px;
    height: 26px;

    object-fit: cover;
    border-radius: 50%;
}

.chat-message-row .chat-message {
    max-width: 100%;
}

.chat-message--assistant {
    padding: 0;

    color: #1f2937;
    background-color: transparent;
    border-radius: 0;
}

/* Sin burbuja, el anillo del realce tras una navegación necesita un poco de
   aire alrededor del texto. */
.chat-message--assistant.chat-message--flash {
    border-radius: 8px;
}

.chat-message-row .chat-message--typing {
    align-self: flex-start;

    background-color: #f3f4f6;
}

.chat-message--user {
    align-self: flex-end;

    color: #1f2937;
    background-color: #f3f4f6;

    border-radius: 18px;
}

/* Lo que falta para que el último mensaje del cliente pueda quedar arriba
   de la vista (MessageListController.js, updateSpacer). */
.chat-message-spacer {
    flex-shrink: 0;
    height: 0;
}

/* Entrada de los mensajes que llegan en vivo. */
.chat-message-enter {
    animation: chat-message-enter 0.3s ease-out both;
}

@keyframes chat-message-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Aparece al subir a leer; baja al último mensaje. El "bottom" lo pone el
   JS según el alto del campo de texto. */
.chat-scroll-button {
    position: absolute;
    left: 50%;
    z-index: 2;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;
    padding: 0;

    color: #1f2937;
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);

    cursor: pointer;
    transform: translateX(-50%);
}

.chat-scroll-button[hidden] {
    display: none;
}

.chat-scroll-button:hover {
    background-color: #f9fafb;
}

.chat-scroll-button:focus-visible {
    outline: 2px solid rgba(215, 25, 32, 0.45);
    outline-offset: 1px;
}

.chat-message--typing {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 12px 14px;
}

.chat-message-typing-dots {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 4px;
}

.chat-message-typing-phrase {
    font-size: 13px;
    line-height: 1.3;
    color: #6b7280;

    opacity: 0;
    transition: opacity 0.25s ease;
}

.chat-message-typing-phrase.is-visible {
    opacity: 1;
}

.chat-message-typing-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;
    background-color: #9ca3af;
    opacity: 0.5;

    animation: chat-message-typing-bounce 1.2s infinite ease-in-out;
}

.chat-message-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-message-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chat-message-typing-bounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Realce del último mensaje del asistente tras una navegación (nav_to): un
   anillo con el color de acento que late para que el usuario note el cambio. */
.chat-message--flash {
    animation: chat-message-flash 1.8s ease-out 1;
}

@keyframes chat-message-flash {
    0% {
        box-shadow: 0 0 0 0 rgba(215, 25, 32, 0);
    }

    15% {
        box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.55);
    }

    55% {
        box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.35);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(215, 25, 32, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-message-typing-dot {
        animation: none;
    }

    .chat-message-typing-phrase {
        transition: none;
    }

    .chat-message--flash {
        animation: none;
    }

    .chat-message-enter {
        animation: none;
    }
}

.chat-model-carousel {
    position: relative;

    flex-shrink: 0;

    /* A todo lo ancho, en la misma columna que el texto del Inge (que ya
       no lleva burbuja ni sangría de avatar). */
    max-width: 100%;
}

.chat-model-grid {
    display: flex;
    gap: 0;

    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;

    scrollbar-width: none;
}

.chat-model-grid::-webkit-scrollbar {
    display: none;
}

.chat-model-card {
    flex: 0 0 100%;
    scroll-snap-align: start;

    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 14px;

    overflow: hidden;
}

.chat-model-card-image {
    display: block;

    width: 100%;

    /* El arte del catálogo es cuadrado (1080×1080), así que la caja toma
       esa forma — pero con un tope de alto: a lo ancho de la tarjeta, un
       cuadrado perfecto se comía la ventana y dejaba el nombre y el botón
       fuera de vista.
       Con el tope, en pantallas anchas sobran unas franjas a los lados;
       son blancas igual que el fondo del arte, así que no se ven. Antes
       no se podía hacer esto porque en esas franjas asomaba una foto de
       campo que se pintaba detrás, necesaria cuando los recortes llegaban
       con transparencia y hoy ya no.
       Reducir no cuesta nitidez: 1080 px de origen para 280 de destino
       sobran incluso en pantallas de alta densidad. */
    aspect-ratio: 1 / 1;
    max-height: 280px;

    background-color: #ffffff;
    object-fit: contain;
}

/* Producto sin foto, o foto que no cargó: un ícono atenuado sobre un gris
   muy claro, para que se lea como "aquí va una imagen" y no como un error.
   Ya casi no aparece —los productos sin foto propia toman la de su línea—
   pero sigue cubriendo una URL que falle. */
.chat-model-card-image--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;

    background-color: #f3f4f6;
}

.chat-model-card-image--placeholder svg {
    width: 56px;
    height: 56px;

    color: #9ca3af;
}

.chat-model-carousel-arrow {
    position: absolute;
    top: 50%;
    z-index: 1;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 28px;
    padding: 0;

    color: #9ca3af;
    font-size: 20px;
    line-height: 1;

    background: none;
    border: none;

    cursor: pointer;

    transform: translateY(-50%);
    transition: color 0.15s ease;
}

.chat-model-carousel-arrow:hover {
    color: #4b5563;
}

.chat-model-carousel-arrow--prev {
    left: 4px;
}

.chat-model-carousel-arrow--next {
    right: 4px;
}

.chat-model-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;

    padding: 12px 14px;
}

.chat-model-card-name {
    margin: 0;

    color: #1f2937;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
}

.chat-model-card-action {
    display: flex;
    align-items: center;
    gap: 8px;

    width: 100%;
    padding: 9px 12px;

    color: #1f2937;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;

    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-control, 8px);

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.chat-model-card-action:hover {
    color: white !important;
    background-color: #d71920 !important;
    border-color: #d71920 !important;
}

.chat-model-card-action:hover .chat-action-icon svg {
    color: white !important;
}

.chat-model-card-action:active {
    color: white !important;
    background-color: #b9151b !important;
    border-color: #b9151b !important;
}

.chat-model-card-action:active .chat-action-icon svg {
    color: white !important;
}

.chat-model-card-action:focus-visible {
    outline: 2px solid rgba(215, 25, 32, 0.45);
    outline-offset: 1px;
}

/* :focus (a diferencia de :focus-visible) se activa también con clics de
   mouse y se queda pegado después de soltar el botón — si el tema de
   WordPress tiene alguna regla global de :focus con color pero sin fondo
   a juego, el texto queda invisible. Se resetea explícitamente al look
   normal (o al de :hover/:active si el cursor sigue encima). */
.chat-model-card-action:focus:not(:hover):not(:active) {
    color: #1f2937 !important;
    background-color: white !important;
    border-color: #e5e7eb !important;
}

/* Acciones rápidas (Buscar distribuidor / Cotizar / Ver implementos):
   apiladas verticalmente, mismo ancho, alineadas con el texto de la
   burbuja. */
.chat-action-buttons {
    flex-shrink: 0;

    display: flex;
    flex-direction: column;
    gap: 8px;

    /* Misma columna que el texto del Inge. */
    max-width: 100%;
}

.chat-action-button {
    width: 100%;

    display: flex;
    align-items: center;
    gap: 8px;

    padding: 9px 12px;

    color: #1f2937;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    white-space: normal;

    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-control, 8px);

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.chat-action-button:hover {
    color: white !important;
    background-color: #d71920 !important;
    border-color: #d71920 !important;
}

.chat-action-button:hover .chat-action-icon svg {
    color: white !important;
}

.chat-action-button:active {
    color: white !important;
    background-color: #b9151b !important;
    border-color: #b9151b !important;
}

.chat-action-button:active .chat-action-icon svg {
    color: white !important;
}

.chat-action-button:focus-visible {
    outline: 2px solid rgba(215, 25, 32, 0.45);
    outline-offset: 1px;
}

/* Mismo motivo que en .chat-model-card-action: :focus se queda activo tras
   un clic de mouse (a diferencia de :focus-visible) y puede heredar un
   :focus global del tema sin fondo a juego, dejando el texto invisible. */
.chat-action-button:focus:not(:hover):not(:active) {
    color: #1f2937 !important;
    background-color: white !important;
    border-color: #e5e7eb !important;
}

.chat-action-button--primary:focus:not(:hover):not(:active) {
    color: white !important;
    background-color: #d71920 !important;
    border-color: #d71920 !important;
}

.chat-action-icon {
    display: flex;
    flex-shrink: 0;
}

.chat-action-icon svg {
    width: 16px;
    height: 16px;
    color: #6b7280;
}

.chat-action-button--primary {
    color: white;
    background-color: #d71920;
    border-color: #d71920;
}

.chat-action-button--primary:hover {
    background-color: #b9151b;
    border-color: #b9151b;
}

.chat-action-button--primary:active {
    background-color: #a01319;
    border-color: #a01319;
}

.chat-action-button--primary:focus-visible {
    outline-color: rgba(255, 255, 255, 0.85);
}

.chat-action-button--primary .chat-action-icon svg {
    color: white;
}

.chat-distributor-list {
    flex-shrink: 0;

    display: flex;
    flex-direction: column;
    gap: 8px;

    max-width: 100%;
}

.chat-distributor-card {
    display: flex;
    flex-direction: column;
    gap: 4px;

    padding: 10px 12px;

    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-control, 8px);
}

.chat-distributor-name {
    margin: 0;

    color: #1f2937;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
}

.chat-distributor-meta,
.chat-distributor-phone {
    margin: 0;

    color: #6b7280;
    font-size: 12px;
    line-height: 1.3;
}

.chat-distributor-address {
    margin: 2px 0 4px;

    color: #1f2937;
    font-size: 12px;
    line-height: 1.4;
}

.chat-distributor-card .chat-action-button {
    margin-top: 6px;
}

#chat-welcome[hidden],
#chat-conversation[hidden] {
    display: none;
}

#chat-conversation {
    position: relative;

    display: flex;
    flex-direction: column;

    width: 100%;
    height: 100%;
    padding: 0 22px 22px;

    overflow: hidden;
    box-sizing: border-box;
}

#chat-conversation #chat-message-list {
    flex: 1;
    min-height: 0;
    height: auto;
    margin: 0 -22px;
}

#chat-conversation #chat-input-form,
#chat-conversation #chat-disclaimer {
    flex-shrink: 0;
}