/* =====================================================================
   Gchats — layout do celular em pé (tela vertical)
   Liga sozinho quando a tela é estreita e está em pé ([data-cel]).
   Estrutura: abas embaixo (Conversas, Servidores, Amigos, Você),
   cada tela ocupa tudo, e dentro da conversa aparece o botão de voltar.
   ===================================================================== */

[data-cel] body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
[data-cel] .app { height: 100dvh; }
[data-cel] .main { padding-top: env(safe-area-inset-top); }

/* ---------- abas de baixo ---------- */
[data-cel] #abasCel { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 2px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--side) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
[data-cel] #abasCel button { position: relative; height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .01em; }
[data-cel] #abasCel button svg { width: 24px; height: 24px; transition: transform .15s; }
[data-cel] #abasCel button.sel { color: var(--accent-hi, var(--accent)); }
[data-cel] #abasCel button.sel svg { transform: translateY(-1px) scale(1.06); }
[data-cel] #abasCel button.sel::before { content: ''; position: absolute; top: 4px; width: 46px; height: 32px; border-radius: 16px; background: rgba(var(--accent-rgb, 139, 92, 246), .16); z-index: -1; }
[data-cel] #abasCel .aba-badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 800; font-style: normal; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--side); }
/* dentro de uma conversa as abas somem (mais espaço para ler e escrever) */
[data-cel][data-tela="conv"] .app:not(.nav-open) ~ #abasCel,
[data-cel][data-tela="camp"] .app:not(.nav-open) ~ #abasCel { display: none !important; }
[data-cel] .main { padding-bottom: calc(66px + env(safe-area-inset-bottom)) !important; }
[data-cel][data-tela="conv"] .app:not(.nav-open) .main,
[data-cel][data-tela="camp"] .app:not(.nav-open) .main { padding-bottom: 0 !important; }

/* ---------- telas próprias: Conversas e Você ---------- */
.cel-tela { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.cel-cab { flex: none; display: flex; align-items: center; gap: 4px; padding: 14px 10px 6px 18px; }
.cel-cab h1 { flex: 1; margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.cel-cab .icon-btn { width: 42px; height: 42px; border-radius: 14px; }
.cel-cab .icon-btn svg { width: 22px; height: 22px; }
.cel-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 16px; }
.cel-busca-box { display: flex; align-items: center; gap: 8px; margin: 4px 14px 10px; padding: 0 14px; height: 44px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.cel-busca-box svg { width: 18px; height: 18px; flex: none; }
.cel-busca { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; height: 42px; font-size: 16px; flex: 1; min-width: 0; color: var(--text); }
.cel-pedidos { display: flex; align-items: center; gap: 12px; width: calc(100% - 28px); margin: 0 14px 10px; padding: 12px 14px; border-radius: 16px; background: rgba(var(--accent-rgb, 139, 92, 246), .14); border: 1px solid rgba(var(--accent-rgb, 139, 92, 246), .4); color: var(--text); font-weight: 700; text-align: left; }
.cel-pedidos span { flex: 1; }
.cel-pedidos svg { width: 20px; height: 20px; color: var(--accent-hi, var(--accent)); }

/* amigos online em bolinhas */
.cel-stories { display: flex; gap: 14px; overflow-x: auto; padding: 4px 16px 14px; scrollbar-width: none; }
.cel-stories::-webkit-scrollbar { display: none; }
.cel-story { position: relative; flex: none; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-2, var(--text)); font-size: 12px; }
.cel-story .av { width: 58px !important; height: 58px !important; font-size: 20px; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(var(--accent-rgb, 139, 92, 246), .7); }
.cel-story > span { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cel-story > i { position: absolute; top: -2px; right: 0; font-style: normal; font-size: 15px; }

/* lista de conversas */
.cel-lista { display: flex; flex-direction: column; padding: 0 6px; }
.cel-item { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 16px; min-height: 70px; cursor: pointer; }
.cel-item:active { background: var(--panel); }
.cel-item .av.lg, .cel-item > .av { width: 52px !important; height: 52px !important; font-size: 19px; flex: none; }
.cel-meio { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cel-l1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cel-l1 b { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cel-l2 { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cel-l2.jogo { color: var(--ok, #22c55e); }
.cel-call { color: var(--ok, #22c55e); font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.cel-call svg { width: 14px; height: 14px; }
.cel-fim { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; align-self: stretch; justify-content: center; }
.cel-fim time { font-size: 12px; color: var(--dim, var(--muted)); }
.cel-item.nao-lida .cel-l1 b { font-weight: 800; }
.cel-item.nao-lida .cel-l2 { color: var(--text); font-weight: 600; }
.cel-item.nao-lida .cel-fim time { color: var(--accent-hi, var(--accent)); font-weight: 700; }
.cel-item .badge { min-width: 22px; height: 22px; border-radius: 11px; font-size: 12px; }

/* aba Você */
.cel-eu { display: flex; align-items: center; gap: 16px; margin: 6px 14px 14px; padding: 18px; border-radius: 22px; background: linear-gradient(150deg, rgba(var(--accent-rgb, 139, 92, 246), .22), transparent 70%), var(--panel); border: 1px solid var(--line); }
.cel-eu-av { padding: 0; border-radius: 50%; flex: none; }
.cel-eu-av .av { width: 72px !important; height: 72px !important; font-size: 26px; }
.cel-eu-info { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cel-eu-info > b { font-size: 21px; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cel-eu-st { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; max-width: 100%; padding: 7px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cel-eu-st svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.cel-eu-st .dot-mini { width: 10px; height: 10px; border-radius: 50%; flex: none; background: #55556d; }
.cel-eu-st .st-online { background: var(--ok, #22c55e); } .cel-eu-st .st-dnd { background: #ef4444; } .cel-eu-st .st-away { background: var(--away, #f5b13d); }
.cel-plano { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: calc(100% - 28px); margin: 0 14px 14px; padding: 14px 16px; border-radius: 18px; border: 1px solid rgba(var(--accent-rgb, 139, 92, 246), .45); background: rgba(var(--accent-rgb, 139, 92, 246), .1); text-align: left; color: var(--text); }
.cel-plano > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.cel-plano small { color: var(--muted); font-size: 13px; }
.cel-plano .btn { flex: none; pointer-events: none; }
.cel-grupo { margin: 0 14px 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.cel-op { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 10px 14px; text-align: left; color: var(--text); border-bottom: 1px solid var(--line); }
.cel-op:last-child { border-bottom: 0; }
.cel-op:active { background: var(--panel-2); }
.cel-op > svg { width: 18px; height: 18px; color: var(--dim, var(--muted)); flex: none; }
.cel-op-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--panel-2); color: var(--accent-hi, var(--accent)); flex: none; font-size: 18px; }
.cel-op-ic svg { width: 19px; height: 19px; }
.cel-op-t { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 15.5px; font-weight: 600; min-width: 0; }
.cel-op-t small { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.cel-op.perigo { color: #f87171; }
.cel-op.perigo .cel-op-ic { color: #f87171; background: rgba(239, 68, 68, .12); }

/* ---------- topo das telas (conversa, amigos) ---------- */
[data-cel] .top { min-height: 58px; padding: 6px 8px 6px 4px; gap: 6px; }
[data-cel] .top .menu-btn { display: inline-grid !important; width: 42px; height: 42px; flex: none; }
[data-cel] .top .menu-btn svg { width: 24px; height: 24px; }
[data-cel] .top .title { font-size: 17px; min-width: 0; }
[data-cel] .top .title .sub { display: none; }
/* abas de Amigos rolam de lado em vez de sair da tela */
[data-cel] .top .tabs { flex: 1; min-width: 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; gap: 6px; }
[data-cel] .top .tabs::-webkit-scrollbar { display: none; }
[data-cel] .top .tabs .tab { flex: none; white-space: nowrap; height: 36px; padding: 0 14px; font-size: 14px; }
[data-cel][data-tela="friends"] .top > .title { display: none; }

/* ---------- conversa aberta ---------- */
[data-cel] .messages { padding-bottom: 6px; }
[data-cel] .msg { padding-left: 10px; padding-right: 10px; }
[data-cel] .composer { padding: 6px 8px calc(8px + env(safe-area-inset-bottom)) !important; }
[data-cel] .composer-box { border-radius: 24px; min-height: 48px; }
[data-cel] .composer textarea { font-size: 16px; } /* 16px evita o zoom automático do iPhone */
[data-cel] input, [data-cel] textarea, [data-cel] select { font-size: 16px; }
[data-cel] .conv-row > .members { display: none; }

/* ---------- servidores (tela inteira, não gaveta) ---------- */
[data-cel] .app.nav-open .rail { box-shadow: none; }
[data-cel] .app.nav-open .side { bottom: calc(64px + env(safe-area-inset-bottom)) !important; }
[data-cel] .rail .rail-busca, [data-cel] .rail .rail-sino, [data-cel] .rail .rail-logo { display: none !important; }

/* ---------- chamada: barra flutuante acima das abas ---------- */
[data-cel] .voice-bar:not(.hidden) { bottom: calc(72px + env(safe-area-inset-bottom)) !important; }
[data-cel][data-tela="conv"] .app:not(.nav-open) .voice-bar:not(.hidden) { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }

/* palco da chamada ocupa a largura; controles grandes para o dedo */
[data-cel] .stage { border-radius: 0 0 22px 22px; }
[data-cel] .stage-bar { gap: 10px; padding: 10px 6px 12px; }
[data-cel] .stage-bar .round { width: 52px; height: 52px; }
[data-cel] .stage-bar .round svg { width: 22px; height: 22px; }
[data-cel] .stage-videos > .tile.video { width: 100% !important; height: auto !important; aspect-ratio: 16 / 9; resize: none; }

/* janelas (modais) viram folha que sobe de baixo */
[data-cel] .modal-back { align-items: flex-end; padding: 0; }
[data-cel] .modal-back .modal { width: 100% !important; max-width: 100% !important; max-height: 92dvh; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: celSobe .22s ease-out; }
@keyframes celSobe { from { transform: translateY(40px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { [data-cel] .modal-back .modal { animation: none; } }
[data-cel] .popover { max-width: calc(100vw - 16px); }

/* avisos ficam acima das abas */
[data-cel] .toasts, [data-cel] #toasts { bottom: calc(80px + env(safe-area-inset-bottom)) !important; left: 10px; right: 10px; }

/* ---------- modo claro ---------- */
[data-cel][data-modo="claro"] #abasCel { background: color-mix(in srgb, #ffffff 92%, transparent); }
/* com a barra de voz aberta, o chat ganha espaço para não ficar escondido */
[data-cel] .app.em-voz .messages, [data-cel] body:has(.voice-bar:not(.hidden)) .messages { padding-bottom: 96px; }
/* reações no celular: o botão + fica sempre visível e os chips maiores */
[data-cel] .reacao { height: 30px; }
[data-cel] .reacao.mais { opacity: .7; }
