/*
 * ANEXOS DO CHAT (ADR-0005) — o mesmo visual nas tres pontas: widget do
 * visitante, inbox da empresa e painel do super admin. A marcacao vem de
 * client-chat-attachments.js (html/criarCompositor) e do parcial PHP
 * app/Views/components/client-chat-anexos.php.
 *
 * O cartao do anexo tem fundo proprio (branco): fica legivel tanto na bolha
 * branca do cliente quanto na azul/vermelha da equipe.
 */

/* A landing e o widget nao tem o reset do Bootstrap: sem border-box, o
   padding da miniatura empurrava o nome para baixo dela. */
.lx-anexos,
.lx-anexos *,
.lx-anexo-area,
.lx-anexo-area * { box-sizing: border-box; }

/* -- Na bolha ------------------------------------------------------------ */
.lx-anexos {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-top: 8px;
    /* A bolha usa pre-wrap para manter as quebras do texto; aqui nao. */
    white-space: normal;
    line-height: 1.3;
}
.lx-anexos:first-child { margin-top: 0; }
.lx-anexo {
    display: block;
    max-width: 100%;
    color: inherit;
}
.lx-anexo:focus-visible,
.lx-anexo__baixar:focus-visible {
    outline: 3px solid #4f46e5;
    outline-offset: 2px;
    border-radius: 12px;
}

.lx-anexo--imagem {
    display: inline-block;
    border-radius: 12px;
    overflow: hidden;
    line-height: 0;
    background: rgba(15, 23, 42, .06);
    cursor: zoom-in;
}
.lx-anexo--imagem img {
    display: block;
    max-width: min(100%, 260px);
    max-height: 260px;
    height: auto;
    border-radius: 12px;
}

.lx-anexo--video { width: 280px; }
.lx-anexo--video video {
    display: block;
    width: 100%;
    max-height: 320px;
    border-radius: 12px;
    background: #0f172a;
}
.lx-anexo__baixar {
    display: inline-flex;
    margin-top: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
    font-size: .76rem;
    font-weight: 600;
    text-decoration: none;
}
.lx-anexo__baixar:hover { background: #eef2ff; color: #3730a3; text-decoration: underline; }

.lx-anexo--pdf {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 260px;
    padding: 9px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.lx-anexo--pdf:hover {
    border-color: #a5b4fc;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .08);
    color: #0f172a;
}
/* Inbox que nao abre arquivo (balde acidental do chat publico): so o aviso. */
.lx-anexo--restrito {
    display: block;
    width: 260px;
    max-width: 100%;
    padding: 8px 12px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #334155;
    cursor: default;
}
.lx-anexo__icone {
    flex: none;
    width: 34px;
    height: 38px;
    color: #dc2626;
}
.lx-anexo__texto { min-width: 0; }
.lx-anexo__nome {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .85rem;
    font-weight: 700;
}
.lx-anexo__meta {
    display: block;
    margin-top: 2px;
    font-size: .74rem;
    color: #64748b;
}

/* -- Na caixa de escrever (chips) ----------------------------------------- */
.lx-anexo-area { grid-column: 1 / -1; min-width: 0; }
.lx-anexo-area:not(.tem-anexos) .lx-anexo-chips { display: none; }
.lx-anexo-chips {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
}
.lx-anexo-chip {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 9px;
    width: 250px;
    max-width: 100%;
    padding: 7px 6px 7px 7px;
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    background: #f8fafc;
    color: #0f172a;
    font-size: .8rem;
    line-height: 1.25;
}
.lx-anexo-chip__mini {
    width: 40px;
    height: 40px;
    padding: 6px;
    border-radius: 9px;
    overflow: hidden;
    background: #eef2ff;
    color: #4f46e5;
}
.lx-anexo-chip__mini img {
    display: block;
    width: calc(100% + 12px);
    height: calc(100% + 12px);
    margin: -6px;
    object-fit: cover;
}
.lx-anexo-chip__texto { min-width: 0; }
.lx-anexo-chip__nome {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}
.lx-anexo-chip__info {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: .74rem;
}
.lx-anexo-chip__remover {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.lx-anexo-chip__remover:hover { background: #fee2e2; color: #b91c1c; }
.lx-anexo-chip__repetir {
    margin-top: 4px;
    padding: 3px 9px;
    border: 1px solid #4f46e5;
    border-radius: 999px;
    background: #fff;
    color: #3730a3;
    font-size: .74rem;
    font-weight: 700;
    cursor: pointer;
}
.lx-anexo-chip__repetir[hidden] { display: none; }
.lx-anexo-chip__remover:focus-visible,
.lx-anexo-chip__repetir:focus-visible,
.lx-anexo-clip:focus-visible {
    outline: 3px solid #4f46e5;
    outline-offset: 2px;
}
.lx-anexo-chip__barra {
    grid-column: 1 / -1;
    display: block;
    height: 4px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}
.lx-anexo-chip__barra > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #4f46e5;
    transition: width .2s ease;
}
.lx-anexo-chip.is-pronto { border-color: #bbf7d0; background: #f0fdf4; }
.lx-anexo-chip.is-pronto .lx-anexo-chip__info { color: #15803d; font-weight: 600; }
.lx-anexo-chip.is-pronto .lx-anexo-chip__barra > span { background: #16a34a; }
.lx-anexo-chip.is-erro { border-color: #fecaca; background: #fef2f2; }
.lx-anexo-chip.is-erro .lx-anexo-chip__info { color: #b91c1c; font-weight: 600; }
.lx-anexo-chip.is-erro .lx-anexo-chip__barra > span { background: #dc2626; }

.lx-anexo-aviso {
    margin-top: 8px;
    padding: 8px 11px;
    border-radius: 10px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
    font-size: .8rem;
    line-height: 1.35;
    white-space: pre-line;
}
.lx-anexo-aviso[hidden] { display: none; }

/* Fora da tela, mas lido pelo leitor de tela e clicavel pelo JS. */
.lx-anexo-input,
.lx-anexo-sr {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0;
}
.lx-anexo-input { pointer-events: none; }

.lx-anexo-clip.is-cheio { opacity: .5; }

/* -- Arrastar e soltar ---------------------------------------------------- */
.lx-anexo-zona.is-arrastando::after {
    content: "Solte o arquivo aqui para anexar";
    position: absolute;
    inset: 6px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    border: 2px dashed #4f46e5;
    border-radius: 16px;
    background: rgba(238, 242, 255, .92);
    color: #3730a3;
    font-weight: 800;
    font-size: 1rem;
    pointer-events: none;
}

@media (max-width: 520px) {
    /* No telefone os chips andam para o lado em vez de empurrar a conversa. */
    .lx-anexo-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }
    .lx-anexo-chip { flex: 0 0 220px; }
    .lx-anexo-chip__remover { width: 38px; height: 38px; }
    .lx-anexo--video,
    .lx-anexo--pdf { width: 100%; max-width: 280px; }
}
@media (prefers-reduced-motion: reduce) {
    .lx-anexo-chip__barra > span,
    .lx-anexo--pdf { transition: none; }
}
