/* ── Layout estilo WhatsApp ──────────────────────────────────────────────────
   Carregado depois do style.css (que mantém os modais, botões e toast).     */

/* ── Ícones (sprite Lucide embutido no index.html) ──────────────────────────
   Uso: <svg class="i"><use href="#i-nome"></use></svg>
   Herdam a cor do texto via currentColor; acompanham o font-size do pai.   */

.i {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
    vertical-align: -0.18em;
    stroke: currentColor;
}

.i-xl { width: 3rem; height: 3rem; }
.i-sm { width: .95em; height: .95em; }

/* Ícone dentro de botão de ícone ocupa o botão inteiro, sem herdar o
   font-size gigante que alguns emojis exigiam. */
.wa-icon-btn .i { width: 20px; height: 20px; vertical-align: middle; }
.wa-send-btn .i { width: 20px; height: 20px; vertical-align: middle; }

.wa-sheet-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.wa-target-hint {
    margin: -4px 0 10px;
    font-size: .82rem;
    color: var(--wa-muted, var(--muted));
}

/* Estado (concluído, RSVP) alinhado com o rótulo. */
.wa-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

:root {
    --wa-header:    #075E54;
    --wa-accent:    #25D366;
    --wa-bg-list:   #111B21;
    --wa-bg-chat:   #0B141A;
    --wa-bg-item:   #202C33;
    --wa-bubble-in: #202C33;
    --wa-bubble-out:#005C4B;
    --wa-text:      #E9EDEF;
    --wa-muted:     #8696A0;
    --wa-divider:   #222D34;
}

/* Tema claro. Sobrescreve as variáveis do app (--wa-*) e as do style.css
   (--bg, --surface...), que os modais e botões ainda usam. A cor de destaque
   é aplicada à parte, pelo settings.js, para poder ser personalizada. */
:root[data-theme="light"] {
    --wa-header:    #075E54;
    --wa-bg-list:   #FFFFFF;
    --wa-bg-chat:   #F0F2F5;
    --wa-bg-item:   #F6F7F8;
    --wa-bubble-in: #FFFFFF;
    --wa-bubble-out:#D9FDD3;
    --wa-text:      #111B21;
    --wa-muted:     #667781;
    --wa-divider:   #E4E7EA;

    --bg:       #F0F2F5;
    --surface:  #FFFFFF;
    --surface2: #F6F7F8;
    --surface3: #EBEDEF;
    --border:   rgba(0, 0, 0, .12);
    --text:     #111B21;
    --muted:    #667781;
    --shadow:   0 18px 42px rgba(0, 0, 0, .12);
}

/* No claro a trilha e os quadros de vídeo não podem ficar pretos. */
:root[data-theme="light"] #wa-rail { background: #E8EBED; }
:root[data-theme="light"] .wa-rail-item { background: #FFFFFF; color: #111B21; }
:root[data-theme="light"] .wa-rail-badge { border-color: #E8EBED; }
:root[data-theme="light"] #wa-call { background: #DDE1E4; }
:root[data-theme="light"] .wa-call-btn { background: rgba(0, 0, 0, .08); }
:root[data-theme="light"] .wa-call-btn:hover { background: rgba(0, 0, 0, .16); }
:root[data-theme="light"] .wa-channel:hover { background: rgba(0, 0, 0, .05); }
:root[data-theme="light"] .wa-channel.active { background: rgba(0, 0, 0, .08); }
:root[data-theme="light"] #wa-me-bar { background: rgba(0, 0, 0, .04); }
:root[data-theme="light"] .wa-icon-btn:hover { background: rgba(0, 0, 0, .06); }

html, body.wa-body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body.wa-body {
    background: var(--wa-bg-chat);
    color: var(--wa-text);
    font-family: 'DM Sans', system-ui, sans-serif;
}

#wa-app {
    display: flex;
    height: 100dvh;
    max-width: 1500px;
    margin: 0 auto;
}

/* ── Painel da lista ───────────────────────────────────────────────────────── */

#wa-list-panel {
    position: relative;
    width: 280px;
    min-width: 200px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--wa-bg-list);
    border-right: 1px solid var(--wa-divider);
}

/* Faixa fina na borda direita; o cursor já indica que dá para arrastar. */
#wa-list-resize {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 5;
}

#wa-list-resize:hover { background: var(--wa-accent); opacity: .5; }

#wa-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--wa-bg-item);
    min-height: 48px;
}

.wa-me {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    overflow: hidden;
}

#wa-me-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.wa-header-actions button,
.wa-header-actions a button {
    background: transparent;
    border: 1px solid var(--wa-divider);
    color: var(--wa-muted);
    border-radius: 8px;
    padding: 5px 9px;
    font-size: .75rem;
    cursor: pointer;
}

.wa-header-actions button:hover { color: var(--wa-text); }

.wa-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.wa-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wa-header);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
}

#wa-banner {
    padding: 10px 14px;
    background: rgba(37, 211, 102, .08);
    border-bottom: 1px solid var(--wa-divider);
    font-size: .85rem;
    color: var(--wa-muted);
}

#wa-conversations {
    flex: 1;
    overflow-y: auto;
}

.wa-conv {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--wa-divider);
}

.wa-conv:hover, .wa-conv.active { background: var(--wa-bg-item); }

.wa-conv-main {
    flex: 1;
    min-width: 0;
}

.wa-conv-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.wa-conv-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-conv-time {
    font-size: .72rem;
    color: var(--wa-muted);
    flex-shrink: 0;
}

.wa-conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.wa-conv-preview {
    font-size: .82rem;
    color: var(--wa-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-unread {
    background: var(--wa-accent);
    color: #04130c;
    font-size: .7rem;
    font-weight: 700;
    border-radius: 999px;
    min-width: 19px;
    height: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

.wa-online-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--wa-accent);
    position: absolute;
    right: 0;
    bottom: 0;
    border: 2px solid var(--wa-bg-list);
}

.wa-conv-avatar-wrap { position: relative; flex-shrink: 0; }

.wa-list-section {
    padding: 8px 14px 4px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--wa-muted);
}

/* ── Painel da conversa ────────────────────────────────────────────────────── */

#wa-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--wa-bg-chat);
}

#wa-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--wa-muted);
    text-align: center;
    padding: 20px;
}

.wa-empty-logo { font-size: 3rem; }

.wa-btn-primary {
    background: var(--wa-accent);
    color: #04130c;
    border: none;
    border-radius: 999px;
    padding: 10px 26px;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    margin-top: 10px;
}

#wa-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#wa-chat.hidden { display: none; }

#wa-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--wa-bg-item);
    min-height: 48px;
}

.wa-chat-peer {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

/* Em grupo o cabeçalho abre a lista de presentes. */
#wa-app.in-group .wa-chat-peer { cursor: pointer; }
#wa-app.in-group .wa-chat-peer:hover { opacity: .85; }

#members-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 55vh;
    overflow-y: auto;
}

#members-list .wa-avatar { width: 30px; height: 30px; font-size: .82rem; }

.wa-chat-title { min-width: 0; }

#wa-chat-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-sub {
    font-size: .75rem;
    color: var(--wa-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-actions { display: flex; gap: 4px; }

.wa-icon-btn {
    background: transparent;
    border: none;
    color: var(--wa-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
}

.wa-icon-btn:hover { background: rgba(255,255,255,.06); color: var(--wa-text); }

#wa-back { display: none; }

#wa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 8%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    background:
        radial-gradient(circle at 25% 15%, rgba(37,211,102,.03), transparent 40%),
        var(--wa-bg-chat);
}

.wa-msg {
    max-width: 72%;
    padding: 6px 10px 4px;
    border-radius: 8px;
    background: var(--wa-bubble-in);
    align-self: flex-start;
    font-size: .9rem;
    line-height: 1.35;
    word-break: break-word;
    position: relative;
}

.wa-msg.mine {
    background: var(--wa-bubble-out);
    align-self: flex-end;
}

.wa-msg.selected { outline: 2px solid var(--wa-accent); }

.wa-msg-sender {
    font-size: .74rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.wa-msg-time {
    font-size: .64rem;
    color: var(--wa-muted);
    text-align: right;
    margin-top: 2px;
}

.wa-msg-sys {
    align-self: center;
    background: var(--wa-bg-item);
    color: var(--wa-muted);
    font-size: .75rem;
    padding: 4px 12px;
    border-radius: 999px;
    margin: 6px 0;
}

#wa-typing {
    padding: 0 8% 4px;
    min-height: 18px;
}

#wa-input-area {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: var(--wa-bg-item);
}

#message-input {
    flex: 1;
    background: var(--wa-bg-list);
    border: 1px solid var(--wa-divider);
    color: var(--wa-text);
    border-radius: 999px;
    padding: 11px 16px;
    font-size: .92rem;
    outline: none;
}

.wa-send-btn {
    background: var(--wa-accent);
    color: #04130c;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.05rem;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Mobile: lista ↔ conversa ─────────────────────────────────────────────── */

@media (max-width: 760px) {
    /* No celular a trilha e os canais dividem a tela; ao abrir a conversa,
       as duas somem e o chat ocupa tudo. */
    #wa-rail { width: 58px; padding: 8px 0; }
    .wa-rail-item { width: 42px; height: 42px; }

    #wa-list-panel { flex: 1; width: auto; min-width: 0; }
    #wa-chat-panel { display: none; }

    #wa-app.show-chat #wa-rail        { display: none; }
    #wa-app.show-chat #wa-list-panel  { display: none; }
    #wa-app.show-chat #wa-chat-panel  { display: flex; }

    #wa-back { display: block; }
    #wa-messages { padding: 12px 4%; }
    #wa-typing { padding: 0 4% 4px; }
    .wa-msg { max-width: 86%; }
}

/* ── Coluna de membros (direita) ───────────────────────────────────────────── */

#wa-members-panel {
    width: 220px;
    flex-shrink: 0;
    background: var(--wa-bg-list);
    border-left: 1px solid var(--wa-divider);
    overflow-y: auto;
    padding-bottom: 10px;
}

#wa-members-panel.hidden { display: none; }

.wa-panel-member {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 12px;
    margin: 0 6px;
    border-radius: 8px;
    font-size: .88rem;
    cursor: pointer;
    transition: background .12s ease;
}

.wa-panel-member:hover { background: rgba(255, 255, 255, .06); }
.wa-panel-member.offline { opacity: .45; }

.wa-panel-avatar { position: relative; flex-shrink: 0; display: flex; }
.wa-panel-avatar .wa-avatar { width: 28px; height: 28px; font-size: .78rem; }
.wa-panel-avatar .wa-online-dot { border-color: var(--wa-bg-list); }

.wa-panel-member-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    /* Em tela média a coluna de membros atrapalha mais do que ajuda. */
    #wa-members-panel { display: none; }
}

/* ── Movimento ─────────────────────────────────────────────────────────────── */

.wa-rail-item,
.wa-channel,
.wa-sheet-item,
.wa-icon-btn,
.wa-call-btn,
.btn,
.wa-conv,
.wa-member-row .btn {
    transition: background .14s ease, color .14s ease, border-color .14s ease,
                transform .12s ease, filter .14s ease, opacity .14s ease;
}

.wa-icon-btn:active,
.wa-call-btn:active,
.wa-rail-item:active { transform: scale(.92); }

.btn:active, .wa-sheet-item:active { transform: scale(.98); }

/* O quadro cresce ao entrar em destaque, em vez de saltar. */
.wa-call-tile {
    transition: border-color .14s ease, aspect-ratio .2s ease, box-shadow .12s ease;
}

/* Mensagem nova sobe suavemente. */
@keyframes wa-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.wa-msg, .wa-shared-card, .wa-poll-card {
    animation: wa-msg-in .16s ease-out;
}

/* Modal aparece com um leve crescimento em vez de piscar na tela. */
@keyframes wa-modal-in {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

@keyframes wa-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-overlay:not(.hidden) { animation: wa-overlay-in .14s ease-out; }
.modal-overlay:not(.hidden) .modal { animation: wa-modal-in .18s cubic-bezier(.2, .8, .3, 1); }

/* A coluna de membros desliza para dentro. */
@keyframes wa-panel-in {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: none; }
}

#wa-members-panel:not(.hidden) { animation: wa-panel-in .18s ease-out; }
#wa-call:not(.hidden) { animation: wa-msg-in .2s ease-out; }

/* Quem pediu menos movimento no sistema não recebe nenhum. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

.wa-danger-zone { border-color: rgba(255, 92, 92, .35); }

/* ── Aulas: player e progresso ─────────────────────────────────────────────── */

.wa-player {
    width: 100%;
    margin: 8px 0;
    border-radius: 8px;
    background: #000;
    display: block;
}

audio.wa-player { background: transparent; }

.wa-progress {
    height: 5px;
    margin-top: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    overflow: hidden;
}

.wa-progress-fill {
    height: 100%;
    background: var(--wa-accent);
    border-radius: inherit;
    transition: width .25s ease;
}

:root[data-theme="light"] .wa-progress { background: rgba(0, 0, 0, .1); }

/* Cabeçalho de seção com o "+" de criar canal à direita. */
.wa-section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.wa-section-add {
    background: transparent;
    border: none;
    color: var(--wa-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

.wa-section-add:hover { color: var(--wa-text); background: rgba(255, 255, 255, .08); }

/* Registro de auditoria no chat: discreto, fora do fluxo da conversa, e só
   entregue pelo servidor a quem administra o grupo. */
.wa-msg-audit {
    align-self: center;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 90%;
    margin: 6px 0;
    padding: 4px 12px;
    border: 1px dashed var(--wa-divider);
    border-radius: 999px;
    font-size: .74rem;
    color: var(--wa-muted);
    text-align: center;
}

#group-invite-url {
    font-size: .8rem;
    font-family: var(--mono), monospace;
}

/* ── Cantos ────────────────────────────────────────────────────────────────── */
/* O style.css vem da fase anterior do projeto, com cantos bem arredondados.
   Aqui eles são suavizados para o app parecer menos "bolha". */

.modal { border-radius: 10px; }
.modal input, .modal select, .modal textarea { border-radius: 8px; }
.btn { border-radius: 8px; }
.wa-sheet-item { border-radius: 8px; }
.wa-announcement-card, .wa-shared-card, .wa-poll-card { border-radius: 8px; }
.wa-call-tile { border-radius: 8px; }
.wa-theme-btn { border-radius: 8px; }
.wa-rail-item { border-radius: 12px; }
.wa-rail-item:hover, .wa-rail-item.active { border-radius: 10px; }

/* ── Configurações ─────────────────────────────────────────────────────────── */

.wa-settings-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 12px;
}

.wa-settings-section:first-of-type { border-top: none; margin-top: 0; }

.wa-settings-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: .92rem;
    margin-bottom: 10px;
}

.wa-settings-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    font-size: .9rem;
}

.wa-settings-field select { flex: 1; min-width: 0; max-width: 60%; }

.wa-theme-row { display: flex; gap: 8px; margin-bottom: 12px; }

.wa-theme-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface2);
    color: var(--text);
    font-size: .9rem;
    cursor: pointer;
}

.wa-theme-btn:hover { filter: brightness(1.08); }

.wa-theme-btn.active {
    border-color: var(--wa-accent);
    box-shadow: 0 0 0 1px var(--wa-accent) inset;
}

.wa-accent-row { display: flex; align-items: center; gap: 8px; }

#setting-accent {
    width: 46px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    cursor: pointer;
}

/* ── Menu do grupo (⋮), avisos e banner urgente ────────────────────────────── */

.wa-badge-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff5c5c;
}

#btn-group-menu { position: relative; }

.wa-sheet { display: flex; flex-direction: column; gap: 6px; }

.wa-sheet-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: var(--wa-bg-item, var(--surface2));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    color: inherit;
    font-size: .95rem;
    cursor: pointer;
}

.wa-sheet-item:hover { background: rgba(255,255,255,.06); }

.wa-badge {
    background: #ff5c5c;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 2px 8px;
}

#announcements-list { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }

.wa-announcement-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--surface2);
}

.wa-announcement-card.pinned { border-color: #ffd37b; }

.wa-announcement-title {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.wa-announcement-body { white-space: pre-wrap; word-break: break-word; font-size: .9rem; }

.wa-announcement-meta {
    margin-top: 6px;
    font-size: .75rem;
    color: var(--wa-muted, var(--muted));
}

#wa-announcement-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: #5a3d00;
    color: #ffd37b;
    font-size: .88rem;
    border-bottom: 1px solid var(--border);
}

#wa-announcement-banner button {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1rem;
    cursor: pointer;
}

/* ── Card publicado pelo "+" (aviso, aula, evento) ─────────────────────────── */

.wa-shared-card {
    align-self: flex-start;
    width: 100%;
    max-width: 420px;
    background: var(--wa-bubble-in);
    border: 1px solid var(--wa-divider);
    border-left: 3px solid var(--wa-accent);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 6px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wa-shared-card.mine {
    align-self: flex-end;
    background: var(--wa-bubble-out);
}

.wa-shared-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--wa-muted);
}

.wa-shared-title {
    font-size: .95rem;
    font-weight: 600;
    word-break: break-word;
}

.wa-shared-card .btn { align-self: flex-start; }

#publish-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 45vh;
    overflow-y: auto;
}

/* ── Coluna 1: trilha de grupos ────────────────────────────────────────────── */

#wa-rail {
    width: 68px;
    flex-shrink: 0;
    background: #0a1014;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    overflow-y: auto;
    scrollbar-width: none;
}

#wa-rail::-webkit-scrollbar { display: none; }

#wa-rail-groups {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.wa-rail-item {
    position: relative;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 16px;
    background: var(--wa-bg-item);
    color: var(--wa-text);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-radius .15s ease, background .15s ease;
}

/* O quadrado arredondado vira círculo ao passar; o ativo fica quadrado. */
.wa-rail-item:hover  { border-radius: 14px; background: var(--wa-header); }
.wa-rail-item.active { border-radius: 14px; background: var(--wa-header); }

/* Marcador à esquerda do grupo ativo. */
.wa-rail-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    width: 4px;
    height: 26px;
    border-radius: 0 4px 4px 0;
    background: var(--wa-text);
}

.wa-rail-item .i { width: 20px; height: 20px; }

.wa-rail-badge {
    position: absolute;
    right: -2px;
    bottom: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ff5c5c;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0a1014;
}

.wa-rail-sep {
    width: 32px;
    height: 2px;
    background: rgba(255, 255, 255, .08);
    border-radius: 2px;
    flex-shrink: 0;
}

/* Configurações ficam no pé da trilha, longe dos grupos. */
.wa-rail-bottom { margin-top: auto; }

/* Criar grupo: tracejado, para não parecer um grupo existente. */
.wa-rail-new {
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, .2);
    color: var(--wa-accent);
}

.wa-rail-new:hover { background: rgba(255, 255, 255, .06); border-style: solid; }

#wa-list-header {
    justify-content: space-between;
}

.wa-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.wa-member-row:last-child { border-bottom: none; }
.wa-member-row .wa-avatar { width: 30px; height: 30px; font-size: .8rem; }

#group-members-list { max-height: 50vh; overflow-y: auto; }

/* ── Coluna 2: cabeçalho e rodapé ──────────────────────────────────────────── */

#wa-list-title {
    font-weight: 700;
    font-size: .98rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#wa-me-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, .25);
    border-top: 1px solid var(--wa-divider);
    flex-shrink: 0;
}

#wa-me-bar .wa-avatar { width: 30px; height: 30px; font-size: .8rem; }

/* ── Canais ────────────────────────────────────────────────────────────────── */

.wa-channel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: calc(100% - 16px);
    margin: 1px 8px;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--wa-muted);
    font-size: .9rem;
    cursor: pointer;
    text-align: left;
}

.wa-channel:hover { background: rgba(255, 255, 255, .05); color: var(--wa-text); }
.wa-channel.active { background: rgba(255, 255, 255, .09); color: var(--wa-text); }

/* Canal de voz em que você está fica verde, como no Discord. */
.wa-channel-voice.connected { color: var(--wa-accent); }

.wa-channel-label {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-channel-count {
    font-size: .72rem;
    color: var(--wa-muted);
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
    padding: 1px 7px;
    flex-shrink: 0;
}

/* Quem está no canal de voz, listado abaixo dele. */
.wa-voice-members {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px 8px 6px 30px;
}

.wa-voice-member {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .84rem;
    color: var(--wa-muted);
    padding: 3px 0;
}

.wa-voice-member .wa-avatar { width: 22px; height: 22px; font-size: .7rem; }

.wa-voice-member-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Microfone mudo, câmera ligada, tela compartilhada. */
.wa-voice-signals {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    color: var(--wa-muted);
}

/* Anel verde em volta do avatar de quem está falando. */
.wa-voice-member .wa-avatar {
    box-shadow: 0 0 0 0 transparent;
    transition: box-shadow .12s ease;
}

.wa-voice-member.speaking .wa-avatar {
    box-shadow: 0 0 0 2px var(--wa-accent);
}

.wa-voice-member.speaking .wa-voice-member-name { color: var(--wa-text); }

/* ── Barra de voz (rodapé da lista) ────────────────────────────────────────── */

#wa-voice-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--wa-bg-item);
    border-top: 1px solid var(--wa-divider);
    flex-shrink: 0;
}

#wa-voice-bar.hidden { display: none; }

.wa-voice-info { min-width: 0; }

.wa-voice-state {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--wa-accent);
}

.wa-voice-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--wa-accent);
}

.wa-voice-actions { display: flex; gap: 2px; flex-shrink: 0; }
.wa-voice-actions .wa-icon-btn.off { color: #ff7b7b; }
.wa-icon-btn.wa-voice-danger:hover { color: #ff7b7b; }

/* ── Barras de rolagem discretas ───────────────────────────────────────────── */

#wa-conversations, #wa-messages, #wa-call-tiles,
#announcements-list, #contents-list, #calendar-list,
#members-list, #publish-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

#wa-conversations::-webkit-scrollbar,
#wa-messages::-webkit-scrollbar,
#wa-call-tiles::-webkit-scrollbar,
#announcements-list::-webkit-scrollbar,
#contents-list::-webkit-scrollbar,
#calendar-list::-webkit-scrollbar,
#members-list::-webkit-scrollbar,
#publish-list::-webkit-scrollbar {
    width: 8px;
}

#wa-conversations::-webkit-scrollbar-track,
#wa-messages::-webkit-scrollbar-track,
#wa-call-tiles::-webkit-scrollbar-track,
#announcements-list::-webkit-scrollbar-track,
#contents-list::-webkit-scrollbar-track,
#calendar-list::-webkit-scrollbar-track,
#members-list::-webkit-scrollbar-track,
#publish-list::-webkit-scrollbar-track {
    background: transparent;
}

#wa-conversations::-webkit-scrollbar-thumb,
#wa-messages::-webkit-scrollbar-thumb,
#wa-call-tiles::-webkit-scrollbar-thumb,
#announcements-list::-webkit-scrollbar-thumb,
#contents-list::-webkit-scrollbar-thumb,
#calendar-list::-webkit-scrollbar-thumb,
#members-list::-webkit-scrollbar-thumb,
#publish-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .16);
    border-radius: 999px;
}

#wa-conversations::-webkit-scrollbar-thumb:hover,
#wa-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .28);
}

/* ── Chamada (LiveKit) ─────────────────────────────────────────────────────── */

/* O painel fica ACIMA das mensagens, não sobre elas: o canal de voz é um
   lugar em que se está, e a conversa continua acontecendo ao lado. */
#wa-call {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: #0d1418;
    border-bottom: 1px solid var(--wa-divider);
    flex-shrink: 0;
}

#wa-call.hidden { display: none; }

#wa-call-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    overflow-y: auto;
    align-content: start;
    min-height: 120px;
    height: 200px;   /* ponto de partida; a alça ajusta e o valor é lembrado */
    resize: none;
}

/* Alça de redimensionar, entre os vídeos e os controles. */
#wa-call-resize {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 14px;
    cursor: ns-resize;
    color: var(--wa-muted);
    flex-shrink: 0;
    touch-action: none;
}

#wa-call-resize:hover { color: var(--wa-text); }
#wa-call-resize .i { width: 18px; height: 18px; }

.wa-call-tile {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--wa-bg-item);
    border: 2px solid transparent;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Destaque e expansão ───────────────────────────────────────────────────── */

/* Com alguém em destaque, ele ocupa a largura toda e os demais viram uma
   fileira de miniaturas abaixo. */
#wa-call-tiles.has-pinned {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
}

#wa-call-tiles.has-pinned .wa-call-tile.pinned {
    grid-column: 1 / -1;
    aspect-ratio: 16 / 9;
}

#wa-call-tiles.has-pinned .wa-call-tile:not(.pinned) {
    aspect-ratio: 1 / 1;
}

.wa-call-tile { cursor: pointer; }

/* Quem compartilha a tela ganha moldura e o vídeo aparece inteiro, sem corte. */
.wa-call-tile.sharing { border-color: var(--wa-accent); }
.wa-call-tile.sharing video { object-fit: contain; background: #000; }

.wa-tile-expand {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.wa-tile-expand .i { width: 16px; height: 16px; }

/* Só faz sentido expandir o que tem imagem. */
.wa-call-tile.with-video .wa-tile-expand { display: flex; }
.wa-call-tile.sharing .wa-tile-expand { background: var(--wa-accent); color: #04130c; }

/* Em tela cheia o vídeo ocupa tudo. */
.wa-call-tile:fullscreen { aspect-ratio: auto; border: none; border-radius: 0; }
.wa-call-tile:fullscreen video { object-fit: contain; }

/* Falando: anel no avatar, como no Discord — não só a borda do quadro. */
.wa-call-tile.speaking .wa-call-avatar {
    box-shadow: 0 0 0 3px var(--wa-accent);
}

.wa-call-avatar { transition: box-shadow .12s ease; }

/* Sem câmera, mostra a inicial — o quadro não fica vazio. */
.wa-call-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--wa-header);
    color: #fff;
    font-weight: 700;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-call-tile.with-video .wa-call-avatar { display: none; }

/* Borda acesa em quem está falando. */
.wa-call-tile.speaking { border-color: var(--wa-accent); }

.wa-call-tile video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wa-call-name {
    position: absolute;
    left: 8px;
    bottom: 6px;
    z-index: 1;
    font-size: .78rem;
    background: rgba(0, 0, 0, .55);
    padding: 2px 8px;
    border-radius: 999px;
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#wa-call-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-shrink: 0;
}

#wa-call-status {
    margin-right: auto;
    padding-left: 4px;
}

.wa-call-select {
    background: rgba(255, 255, 255, .12);
    border: none;
    color: var(--wa-text);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: .82rem;
    cursor: pointer;
    flex-shrink: 0;
}

:root[data-theme="light"] .wa-call-select { background: rgba(0, 0, 0, .08); }

.wa-call-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .12);
    color: var(--wa-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wa-call-btn .i { width: 19px; height: 19px; }
.wa-call-btn:hover { background: rgba(255, 255, 255, .2); }
.wa-call-btn.off   { background: rgba(255, 255, 255, .06); color: var(--wa-muted); }
.wa-call-btn.danger { background: #d33; color: #fff; }
.wa-call-btn.danger:hover { background: #e44; }

/* ── Enquetes no chat (botão + e card) ─────────────────────────────────────── */

#btn-create { flex-shrink: 0; }

.wa-poll-card {
    align-self: center;
    width: 100%;
    max-width: 420px;
    background: var(--wa-bg-item);
    border: 1px solid var(--wa-divider);
    border-radius: 12px;
    padding: 10px 12px;
    margin: 6px 0;
    font-size: .9rem;
}

.wa-poll-question {
    font-weight: 700;
    margin-bottom: 8px;
}

.wa-poll-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wa-poll-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: var(--wa-bg-list);
    border: 1px solid var(--wa-divider);
    border-radius: 8px;
    padding: 7px 10px;
    color: inherit;
    font-size: .85rem;
    cursor: pointer;
    overflow: hidden;
}

.wa-poll-option:disabled { cursor: default; }

.wa-poll-option.voted { border-color: var(--wa-accent); }

.wa-poll-option-bar {
    position: absolute;
    inset: 0;
    width: 0;
    background: rgba(37, 211, 102, .18);
    transition: width .2s ease;
}

.wa-poll-option-label, .wa-poll-option-count {
    position: relative;
    z-index: 1;
}

.wa-poll-option-count { color: var(--wa-muted); white-space: nowrap; }

.wa-poll-total {
    margin-top: 6px;
    font-size: .72rem;
    color: var(--wa-muted);
    text-align: right;
}
