/* ════════════════════════════════════════════════════════════════════════════
   chat-viewer.css — Visor de conversaciones (/chats · inbox del agente)
   ────────────────────────────────────────────────────────────────────────────
   Reemplaza el bloque <style> inline de ChatViewer.razor. Prefijo .wachat-*
   (mismos nombres que ya usa el markup) + los nuevos .wachat-cmp-* del
   compositor rico (emojis / adjuntos / audio).

   Los colores del CHROME (sidebar, modales, botones) usan tokens --gi-* de
   tokens.css para que sigan el tema de la app. Los colores de la SUPERFICIE
   DE CHAT (fondo con patrón, burbujas, ticks) son propios del visor y viven
   en las variables --wa-* de abajo, con override para data-theme="dark".
   ════════════════════════════════════════════════════════════════════════════ */

.wachat {
    --wa-bg:        #EEE5DB;
    --wa-pattern:   rgba(120, 85, 45, .10);
    --wa-head:      #FFFFFF;
    --wa-surface:   #FFFFFF;   /* burbuja entrante / chips */
    --wa-surface-2: #F2F0EB;   /* hover / fills sutiles */
    --wa-out:       #D9F2CC;   /* burbuja saliente */
    --wa-text:      #111B21;
    --wa-text-2:    #667781;
    --wa-line:      rgba(0, 0, 0, .09);
    --wa-icon:      #54656F;
    --wa-tick:      #31A9F0;
    --wa-accent:    #12A05C;   /* verde de envío / links del chat */
    --wa-mic:       #F0653C;
    --wa-shadow:    0 1px 1px rgba(11, 20, 26, .13);

    display: grid;
    grid-template-columns: 340px 1fr;
    height: 100%;
    min-height: 0;
    background: var(--gi-card);
    border: 1px solid var(--gi-border);
    border-radius: 12px;
    overflow: hidden;
}

[data-theme="dark"] .wachat {
    --wa-bg:        #0B141A;
    --wa-pattern:   rgba(255, 255, 255, .06);
    --wa-head:      #1F2C33;
    --wa-surface:   #202C33;
    --wa-surface-2: #182229;
    --wa-out:       #144D37;
    --wa-text:      #E9EDEF;
    --wa-text-2:    #8696A0;
    --wa-line:      rgba(255, 255, 255, .10);
    --wa-icon:      #AEBAC1;
    --wa-tick:      #53BDEB;
    --wa-shadow:    0 1px 1px rgba(0, 0, 0, .35);
}

/* `:global()` es sintaxis de CSS scoped de Blazor (.razor.css). Acá es un CSS
   plano servido desde wwwroot: el selector va derecho o el navegador descarta
   toda la regla. */
.app-shell-embed .wachat { border: 0; border-radius: 0; }

/* ═══════════════════ Sidebar ═══════════════════ */

.wachat-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--gi-card);
    border-right: 1px solid var(--gi-border);
}

.wachat-side-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--gi-border);
}
.wachat-side-title {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--gi-fg-strong);
}
.wachat-title-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--gi-accent);
    color: var(--gi-accent-fg);
    font-size: .95rem;
}

.wachat-icon-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--gi-muted-fg);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.wachat-icon-btn:hover { background: var(--gi-muted); color: var(--gi-fg); }

.wachat-integ-tabs {
    display: flex;
    gap: .4rem;
    padding: .6rem .75rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--gi-border);
    scrollbar-width: none;
}
.wachat-integ-tabs::-webkit-scrollbar { display: none; }
.wachat-integ-tab {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    flex: none;
    padding: .38rem .8rem;
    border: 1px solid var(--gi-border);
    border-radius: 100px;
    background: var(--gi-card);
    color: var(--gi-body);
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.wachat-integ-tab:hover  { background: var(--gi-muted); }
.wachat-integ-tab.active {
    background: var(--gi-accent);
    border-color: transparent;
    color: var(--gi-accent-fg);
}
.wachat-integ-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gi-success);
}
.wachat-integ-name {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wachat-search { padding: .6rem .75rem; position: relative; }
.wachat-search-icon {
    position: absolute;
    left: 1.4rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gi-faint);
    font-size: .85rem;
    pointer-events: none;
}
.wachat-search-input {
    width: 100%;
    padding: .6rem .9rem .6rem 2.3rem;
    border: 1px solid var(--gi-border);
    border-radius: 100px;
    background: var(--gi-muted-2);
    color: var(--gi-fg);
    font: inherit;
    font-size: .9rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.wachat-search-input::placeholder { color: var(--gi-faint); }
.wachat-search-input:focus {
    border-color: var(--gi-primary);
    box-shadow: 0 0 0 3px var(--gi-ring);
}

.wachat-conv-list { flex: 1; overflow-y: auto; min-height: 0; }

.wachat-conv {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .7rem .85rem;
    border: 0;
    border-bottom: 1px solid var(--gi-border);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background .12s;
}
.wachat-conv:hover  { background: var(--gi-muted-2); }
.wachat-conv.active { background: var(--gi-accent); }
.wachat-conv.human-alert { box-shadow: inset 3px 0 0 var(--gi-warning); }

.wachat-conv-body { flex: 1; min-width: 0; }
.wachat-conv-top,
.wachat-conv-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}
.wachat-conv-name {
    font-size: .94rem;
    font-weight: 600;
    color: var(--gi-fg-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wachat-conv-time { font-size: .72rem; color: var(--gi-faint); flex: none; }
.wachat-conv-preview {
    display: flex;
    align-items: center;
    gap: .25rem;
    font-size: .84rem;
    color: var(--gi-muted-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wachat-conv-preview .wachat-tick { color: var(--wa-tick); letter-spacing: -3px; }
.wachat-conv-count {
    flex: none;
    min-width: 20px;
    height: 20px;
    padding: 0 .4rem;
    border-radius: 100px;
    background: var(--gi-success);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.wachat-avatar {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 50%;
    background: #B7E0F2;
    color: #1A6E93;
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .02em;
}
.wachat-avatar.large { width: 40px; height: 40px; }

/* ═══════════════════ Panel de chat ═══════════════════ */

.wachat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--wa-bg);
}

.wachat-chat-header {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex: none;
    padding: .55rem .8rem;
    background: var(--wa-head);
    border-bottom: 1px solid var(--wa-line);
}
.wachat-chat-head-body { min-width: 0; flex: 1; }
.wachat-chat-name {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--wa-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wachat-chat-sub { font-size: .76rem; color: var(--wa-text-2); }

.wachat-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .5rem;
    border-radius: 100px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .01em;
}
.wachat-mode-badge.web   { background: var(--gi-info-bg);    color: var(--gi-info-text); }
.wachat-mode-badge.human { background: var(--gi-warning-bg); color: var(--gi-warning-text); }

.wachat-back-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--wa-text);
    font-size: 1.1rem;
    cursor: pointer;
}
.wachat-back-btn:hover { background: var(--wa-surface-2); }

/* ───── Thread: fondo con patrón de puntos ───── */

.wachat-thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .85rem 6% .5rem;
    background-image:
        radial-gradient(var(--wa-pattern) 1.1px, transparent 1.1px),
        radial-gradient(var(--wa-pattern) 1.1px, transparent 1.1px);
    background-size: 38px 38px, 38px 38px;
    background-position: 0 0, 19px 19px;
}

.wachat-day { display: flex; justify-content: center; margin: .6rem 0; }
.wachat-day span {
    padding: .3rem .8rem;
    border-radius: 8px;
    background: var(--wa-surface);
    color: var(--wa-text-2);
    font-size: .72rem;
    font-weight: 500;
    box-shadow: var(--wa-shadow);
}

.wachat-notice {
    align-self: center;
    max-width: 34ch;
    margin-bottom: .5rem;
    padding: .5rem .9rem;
    border-radius: 8px;
    background: #FCF4CB;
    color: #5E5A44;
    font-size: .75rem;
    line-height: 1.5;
    text-align: center;
    box-shadow: var(--wa-shadow);
}
[data-theme="dark"] .wachat-notice { background: #253A2E; color: #C7D6C8; }

.wachat-msg { display: flex; max-width: 100%; }
.wachat-msg.in  { justify-content: flex-start; padding-left: .35rem; }
.wachat-msg.out { justify-content: flex-end;   padding-right: .35rem; }

/* Burbuja con cola: la cola es un ::after recortado con clip-path, del mismo
   color que el fondo de la burbuja (hereda var(--bub)). */
.wachat-bubble {
    position: relative;
    max-width: 65%;
    padding: .4rem .55rem .3rem;
    border-radius: 8px;
    background: var(--bub);
    box-shadow: var(--wa-shadow);
    word-wrap: break-word;
    transition: box-shadow .15s;
}
.wachat-msg.in  .wachat-bubble { --bub: var(--wa-surface); border-top-left-radius: 0; }
.wachat-msg.out .wachat-bubble { --bub: var(--wa-out);     border-top-right-radius: 0; }

.wachat-bubble::after {
    content: "";
    position: absolute;
    top: 0;
    width: 8px;
    height: 11px;
    background: var(--bub);
}
.wachat-msg.in  .wachat-bubble::after { left: -8px;  clip-path: polygon(100% 0, 100% 100%, 0 0); }
.wachat-msg.out .wachat-bubble::after { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }

.wachat-bubble.selected { box-shadow: 0 0 0 2px var(--wa-accent); }

.wachat-bubble-text {
    white-space: pre-wrap;
    text-wrap: pretty;
    color: var(--wa-text);
    font-size: .9rem;
    line-height: 1.4;
    padding-right: 3.6rem;   /* hueco para hora + ticks */
}
.wachat-msg.in .wachat-bubble-text { padding-right: 2.6rem; }

/* Meta (hora + ticks): misma fila inferior para TODOS los tipos de mensaje. */
.wachat-bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .25rem;
    margin-top: 2px;
    padding: 0 .25rem 1px;
    line-height: 1;
}
.wachat-bubble-time { font-size: .66rem; color: var(--wa-text-2); }
.wachat-bubble-tick { display: inline-flex; color: var(--wa-text-2); }
.wachat-bubble-tick.read { color: var(--wa-tick); }

/* Cita / responder */
.wachat-quote {
    max-width: 240px;
    margin-bottom: .25rem;
    padding: .3rem .5rem;
    border-left: 4px solid var(--wa-accent);
    border-radius: 5px;
    background: rgba(0, 0, 0, .05);
}
.wachat-quote-name {
    font-size: .76rem;
    font-weight: 600;
    color: var(--wa-accent);
    margin-bottom: 1px;
}
.wachat-quote-text {
    font-size: .76rem;
    color: var(--wa-text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wachat-forwarded {
    display: flex;
    align-items: center;
    gap: .3rem;
    margin-bottom: .2rem;
    color: var(--wa-text-2);
    font-size: .76rem;
    font-style: italic;
}

/* ───── Adjuntos dentro de la burbuja ───── */

.wachat-media {
    display: block;
    width: 216px;
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: .2rem;
    background: var(--wa-surface-2);
    object-fit: cover;
}
.wachat-media-ph {
    display: grid;
    place-items: center;
    gap: .5rem;
    width: 216px;
    height: 162px;
    border-radius: 8px;
    margin-bottom: .2rem;
    background: linear-gradient(135deg, #D3CBC0, #ABA091);
    color: rgba(255, 255, 255, .95);
    font-size: .72rem;
    font-weight: 500;
}

.wachat-doc {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 208px;
    margin-bottom: .2rem;
    padding: .5rem .6rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, .05);
    text-decoration: none;
}
.wachat-doc-badge {
    display: grid;
    place-items: center;
    width: 32px;
    height: 38px;
    flex: none;
    border-radius: 4px;
    background: #E8453C;
    color: #fff;
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: .03em;
}
.wachat-doc-name {
    font-size: .84rem;
    font-weight: 500;
    color: var(--wa-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wachat-doc-meta { font-size: .72rem; color: var(--wa-text-2); margin-top: 2px; }

/* Nota de voz */
.wachat-audio {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 216px;
    padding-top: 2px;
}
.wachat-audio-avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 50%;
    background: var(--wa-mic);
    color: #fff;
}
.wachat-audio-play {
    border: 0;
    background: transparent;
    color: var(--wa-icon);
    cursor: pointer;
    padding: 0;
    display: grid;
    place-items: center;
}
.wachat-audio-body { flex: 1; min-width: 0; }
.wachat-audio-wave {
    display: flex;
    align-items: center;
    gap: 1.5px;
    height: 24px;
}
.wachat-audio-wave i {
    flex: 1;
    border-radius: 1.5px;
    background: rgba(120, 130, 135, .45);
    transition: background .12s;
}
.wachat-audio-wave i.done { background: var(--wa-accent); }
.wachat-audio-dur { font-size: .72rem; color: var(--wa-text-2); margin-top: 2px; }
.wachat-audio-native { width: 216px; height: 34px; }

/* Ubicación */
.wachat-loc {
    position: relative;
    width: 230px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: .2rem;
    background: #E8E3D6;
    background-image:
        linear-gradient(90deg, #D6D0C0 2px, transparent 2px),
        linear-gradient(0deg,  #D6D0C0 2px, transparent 2px);
    background-size: 44px 44px;
    display: block;
}
.wachat-loc-pin {
    position: absolute;
    left: 50%;
    top: 44%;
    transform: translate(-50%, -50%);
    color: #E8453C;
}
.wachat-loc-label {
    position: absolute;
    left: .5rem;
    bottom: .35rem;
    font-size: .72rem;
    font-weight: 600;
    color: #5E5A50;
}

/* Reacciones */
.wachat-reactions {
    position: absolute;
    bottom: -13px;
    display: flex;
    gap: 2px;
    padding: 3px 7px;
    border-radius: 12px;
    background: var(--wa-surface);
    border: 1px solid var(--wa-line);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .14);
    font-size: .8rem;
    line-height: 1;
}
.wachat-msg.out .wachat-reactions { right: 6px; }
.wachat-msg.in  .wachat-reactions { left: 6px; }
.wachat-msg.has-reactions { margin-bottom: .55rem; }

/* Barra de reacción rápida + responder */
.wachat-quickbar {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: none;
    margin: 0 .6rem .4rem;
    padding: .35rem .5rem;
    border-radius: 26px;
    background: var(--wa-surface);
    box-shadow: 0 5px 20px rgba(0, 0, 0, .18);
}
.wachat-quickbar button {
    flex: 1;
    padding: .3rem 0;
    border: 0;
    border-radius: 18px;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: background .12s, transform .12s;
}
.wachat-quickbar button:hover { background: var(--wa-surface-2); transform: scale(1.15); }
.wachat-quickbar .wachat-quickbar-reply {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .75rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--wa-text);
    border-left: 1px solid var(--wa-line);
    border-radius: 0 18px 18px 0;
}

/* Indicador de "escribiendo…" */
.wachat-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    margin: 2px 0 .35rem .35rem;
    padding: .8rem .9rem;
    border-radius: 8px;
    background: var(--wa-surface);
    box-shadow: var(--wa-shadow);
}
.wachat-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--wa-text-2);
    animation: wachat-dot 1.2s infinite;
}
.wachat-typing i:nth-child(2) { animation-delay: .18s; }
.wachat-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes wachat-dot {
    0%, 60%, 100% { transform: translateY(0);    opacity: .4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ═══════════════════ Footer / compositor ═══════════════════ */

.wachat-footer {
    flex: none;
    padding: .45rem .5rem .5rem;
    background: var(--wa-bg);
    border-top: 1px solid var(--wa-line);
}
.wachat-footer-note {
    display: block;
    padding: .3rem .5rem;
    font-size: .78rem;
    color: var(--wa-text-2);
    font-style: italic;
}
.wachat-footer-note.wachat-footer-warn {
    font-style: normal;
    color: var(--wa-icon);
    line-height: 1.5;
}
.wachat-footer-note.wachat-footer-warn b { color: var(--wa-text); }
.wachat-send-error {
    margin: .35rem .5rem 0;
    font-size: .78rem;
    color: var(--gi-danger-text);
}

/* Fila del compositor: grid minmax(0,1fr) auto — la pastilla SE ENCOGE y el
   botón redondo nunca se sale del panel (con flex:1 sin min-width:0 se
   desbordaba). */
.wachat-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: .45rem;
    width: 100%;
    box-sizing: border-box;
}

.wachat-cmp-pill {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    min-height: 50px;
    box-sizing: border-box;
    padding: .25rem .5rem .25rem .3rem;
    border-radius: 26px;
    background: var(--wa-surface);
    box-shadow: var(--wa-shadow);
}
.wachat-composer-input {
    flex: 1;
    min-width: 0;
    max-height: 96px;
    padding: .4rem .25rem;
    border: 0;
    background: transparent;
    color: var(--wa-text);
    font: inherit;
    font-size: 1rem;
    line-height: 1.4;
    resize: none;
    outline: none;
}
.wachat-composer-input::placeholder { color: var(--wa-text-2); }

.wachat-cmp-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--wa-icon);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.wachat-cmp-btn:hover    { background: var(--wa-surface-2); }
.wachat-cmp-btn.active   { background: var(--wa-surface-2); color: var(--wa-accent); }
.wachat-cmp-btn:disabled { opacity: .45; cursor: default; }

.wachat-cmp-send {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: var(--wa-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(18, 160, 92, .35);
    transition: filter .15s, transform .15s;
}
.wachat-cmp-send:hover    { filter: brightness(1.05); }
.wachat-cmp-send:active   { transform: scale(.96); }
.wachat-cmp-send:disabled { opacity: .5; cursor: default; box-shadow: none; }

/* InputFile invisible dentro de los <label> de adjuntar/cámara: el label ya
   es el control visible, el input real sólo tiene que ser alcanzable. */
.wachat-cmp-file {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
label.wachat-cmp-btn,
label.wachat-attach-item { position: relative; cursor: pointer; }

.wachat-cmp-progress {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: .35rem .5rem 0;
    font-size: .78rem;
    color: var(--wa-text-2);
}
.wachat-cmp-progress span {
    width: 60px;
    height: 3px;
    border-radius: 2px;
    background: var(--wa-line);
    overflow: hidden;
    position: relative;
}
.wachat-cmp-progress span::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 40%;
    border-radius: 2px;
    background: var(--wa-accent);
    animation: wachat-slide 1.1s ease-in-out infinite;
}
@keyframes wachat-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

/* ───── Panel de emojis ───── */

.wachat-emoji {
    display: flex;
    flex-direction: column;
    height: 290px;
    margin-top: .45rem;
    border-radius: 12px;
    border: 1px solid var(--wa-line);
    background: var(--wa-surface);
    overflow: hidden;
}
.wachat-emoji-top {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .8rem .35rem;
}
.wachat-emoji-search {
    flex: 1;
    min-width: 0;
    padding: .4rem .7rem;
    border: 1px solid var(--wa-line);
    border-radius: 100px;
    background: var(--wa-surface-2);
    color: var(--wa-text);
    font: inherit;
    font-size: .85rem;
    outline: none;
}
.wachat-emoji-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 2px;
    padding: .25rem .5rem .5rem;
    align-content: start;
}
.wachat-emoji-title {
    grid-column: 1 / -1;
    padding: .35rem .35rem .2rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--wa-text-2);
}
.wachat-emoji-grid button {
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 1.55rem;
    line-height: 1;
    padding: .35rem 0;
    cursor: pointer;
    transition: background .1s, transform .1s;
}
.wachat-emoji-grid button:hover { background: var(--wa-surface-2); transform: scale(1.18); }
.wachat-emoji-tabs {
    display: flex;
    align-items: center;
    padding: .2rem .35rem;
    border-top: 1px solid var(--wa-line);
}
.wachat-emoji-tabs button {
    flex: 1;
    padding: .45rem 0;
    border: 0;
    border-radius: 20px;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
    filter: grayscale(1);
    opacity: .55;
    transition: opacity .12s, filter .12s, background .12s;
}
.wachat-emoji-tabs button.active {
    filter: none;
    opacity: 1;
    background: var(--wa-surface-2);
}

/* ───── Hoja de adjuntar ───── */

.wachat-attach-backdrop {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: rgba(0, 0, 0, .35);
}
.wachat-attach {
    padding: .6rem .75rem 1.5rem;
    border-radius: 20px 20px 0 0;
    background: var(--wa-surface);
}
.wachat-attach-grip {
    width: 36px;
    height: 4px;
    margin: 0 auto 1rem;
    border-radius: 2px;
    background: var(--wa-line);
}
.wachat-attach-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem .4rem;
}
.wachat-attach-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    border: 0;
    background: transparent;
    color: var(--wa-text);
    font: inherit;
    font-size: .78rem;
    cursor: pointer;
}
.wachat-attach-tile {
    display: grid;
    place-items: center;
    width: 100%;
    height: 56px;
    border: 1px solid var(--wa-line);
    border-radius: 16px;
    background: var(--wa-surface);
    transition: background .12s;
}
.wachat-attach-item:hover .wachat-attach-tile { background: var(--wa-surface-2); }
.wachat-attach-item:disabled { opacity: .45; cursor: default; }

/* ───── Grabación de audio ───── */

.wachat-rec {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .7rem;
    border-radius: 28px;
    background: var(--wa-surface);
    box-shadow: var(--wa-shadow);
}
.wachat-rec-dot {
    width: 9px;
    height: 9px;
    flex: none;
    border-radius: 50%;
    background: #E8453C;
    animation: wachat-pulse 1.1s infinite;
}
@keyframes wachat-pulse {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%      { transform: scale(1.4); opacity: .3; }
}
.wachat-rec-time {
    flex: none;
    min-width: 44px;
    font-size: .9rem;
    font-weight: 500;
    color: var(--wa-text);
    font-variant-numeric: tabular-nums;
}
.wachat-rec-wave {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    height: 24px;
    overflow: hidden;
}
.wachat-rec-wave i {
    width: 3px;
    border-radius: 1.5px;
    background: var(--wa-accent);
}

/* ═══════════════════ Estados vacíos ═══════════════════ */

.wachat-empty-main,
.wachat-empty-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--wa-text-2);
}
.wachat-empty-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--wa-surface);
    color: var(--wa-accent);
    font-size: 1.7rem;
    box-shadow: var(--wa-shadow);
}
.wachat-empty-main h3 {
    margin: .4rem 0 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--wa-text);
}
.wachat-empty-main p { margin: 0; font-size: .88rem; line-height: 1.6; }
.wachat-hint { padding: 1rem; font-size: .85rem; color: var(--gi-muted-fg); text-align: center; }

.wachat-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border: 1px solid var(--gi-border);
    border-radius: 10px;
    background: var(--gi-card);
    color: var(--gi-body);
    font: inherit;
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .15s;
}
.wachat-btn:hover           { background: var(--gi-muted); }
.wachat-btn:active          { transform: translateY(1px); }
.wachat-btn:disabled        { opacity: .55; cursor: default; }
.wachat-btn.primary {
    background: var(--gi-primary);
    border-color: transparent;
    color: var(--gi-primary-fg);
}
.wachat-btn.primary:hover   { background: var(--gi-primary-hover); }

/* ═══════════════════ Modal de integraciones ═══════════════════ */

.wachat-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: rgba(11, 20, 26, .5);
}
.wachat-modal {
    width: min(460px, 92vw);
    max-height: 80vh;
    overflow-y: auto;
    padding: 1.25rem 1.4rem;
    border-radius: 14px;
    background: var(--gi-card);
    box-shadow: 0 24px 60px rgba(11, 20, 26, .3);
}
.wachat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}
.wachat-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gi-fg-strong);
}
.wachat-modal-sub { margin: .35rem 0 1rem; font-size: .85rem; color: var(--gi-muted-fg); }
.wachat-modal-list { display: flex; flex-direction: column; gap: .5rem; }
.wachat-modal-row {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .75rem;
    border: 1px solid var(--gi-border);
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s;
}
.wachat-modal-row:hover { background: var(--gi-muted-2); }
.wachat-modal-row input { accent-color: var(--gi-primary); width: 16px; height: 16px; }
.wachat-modal-row-name { font-size: .9rem; font-weight: 600; color: var(--gi-fg-strong); }
.wachat-modal-row-sub  { font-size: .76rem; color: var(--gi-muted-fg); margin-top: 2px; }

/* ═══════════════════ Responsive ═══════════════════ */

/* Mobile: layout excluyente — lista O chat, según .has-chat (la setea Razor). */
@media (max-width: 640px) {
    .wachat { grid-template-columns: 1fr; border: 0; border-radius: 0; }
    .wachat-side { border-right: 0; }
    .wachat.has-chat .wachat-side { display: none; }
    .wachat:not(.has-chat) .wachat-main { display: none; }

    .wachat-back-btn { display: grid; place-items: center; }
    .wachat-thread   { padding: .6rem .5rem .5rem; }
    .wachat-bubble   { max-width: 85%; }
    .wachat-bubble-text { font-size: .94rem; }
    .wachat-chat-header > div[style*="margin-left:auto"] { gap: .25rem !important; }
    .wachat-emoji    { height: 250px; }
    .wachat-media, .wachat-media-ph { width: 200px; }
}

/* Tablet: los dos paneles, sidebar más angosto. */
@media (min-width: 641px) and (max-width: 900px) {
    .wachat { grid-template-columns: 280px 1fr; }
    .wachat-bubble { max-width: 75%; }
    .wachat-thread { padding: .85rem 3% .5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .wachat-typing i,
    .wachat-rec-dot { animation: none; }
    .wachat-cmp-progress span::after { animation: none; width: 100%; }
    .wachat-emoji-grid button:hover,
    .wachat-quickbar button:hover { transform: none; }
}
