/* ===== Whats Marketing — visual fiel ao WhatsApp Web ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --wa-green: #00a884; --wa-green-dark: #008069; --wa-teal: #008069;
  --bg: #f0f2f5; --panel: #ffffff; --header: #f0f2f5;
  --text: #111b21; --muted: #667781; --border: #e9edef;
  --chat-bg: #efeae2; --bubble-in: #ffffff; --bubble-out: #d9fdd3;
  --hover: #f5f6f6; --active: #f0f2f5; --danger: #ea0038; --warn: #f9a825;
  --tick-read: #53bdeb;
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", Helvetica, "Helvetica Neue", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ===== TEMA ESCURO (estilo WhatsApp Web dark) ===== */
body.dark {
  --bg: #0b141a; --panel: #111b21; --header: #202c33; --text: #e9edef;
  --muted: #8696a0; --border: #222d34; --chat-bg: #0b141a;
  --bubble-in: #202c33; --bubble-out: #005c4b; --hover: #202c33; --active: #2a3942;
}
body.dark .chat-bg-doodle { opacity: .04; }
body.dark .bubble.in { color: #e9edef; }
body.dark .bubble.out { color: #e9edef; }

/* ===== LOGIN ===== */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #f0f2f5; position: relative; }
.login-screen::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 222px; background: var(--wa-green-dark); }
.login-card { position: relative; background: #fff; padding: 40px; border-radius: 6px; width: 380px;
  box-shadow: 0 1px 3px rgba(11,20,26,.28); display: flex; flex-direction: column; gap: 14px; }
.login-logo { display: block; width: 100%; max-width: 220px; margin: 0 auto 4px; border-radius: 6px; }
.login-card h1 { text-align: center; font-size: 22px; font-weight: 600; }
.login-card p { text-align: center; color: var(--muted); }
.login-card input { padding: 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--wa-green); }
.login-card button { padding: 12px; background: var(--wa-green-dark); color: #fff; border: none;
  border-radius: 24px; font-size: 15px; cursor: pointer; font-weight: 500; }
.login-card button:hover { background: var(--wa-green); }
.error { color: var(--danger); font-size: 13px; text-align: center; }

/* ===== APP ===== */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar { background: var(--wa-green-dark); color: #fff; padding: 0 16px; height: 50px;
  display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.brand { flex-shrink: 0; }
.brand { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand-logo { height: 26px; border-radius: 4px; }
.wa-status { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .9; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa; }
.dot.ready { background: #25d366; box-shadow: 0 0 6px #25d366; }
.dot.qr, .dot.starting { background: var(--warn); }
.dot.disconnected, .dot.stopped { background: #ff5c5c; }
.info-note { background: rgba(37,211,102,.10); border: 1px solid rgba(37,211,102,.35);
  color: var(--text); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 0 0 16px; line-height: 1.4; }
.sched-day {
  cursor: pointer; border-radius: 999px; padding: 7px 18px; font-size: 13px; font-weight: 600; line-height: 1;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--text);
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
}
.sched-day:hover { border-color: var(--wa-green); color: var(--wa-green); background: var(--panel); }
.sched-day:active { transform: scale(.96); }
.sched-day.active { background: var(--wa-green); color: #fff !important; border-color: var(--wa-green);
  box-shadow: 0 2px 6px rgba(37,211,102,.4); }
.nav { display: flex; gap: 7px; margin-left: auto; flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav-btn { background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.18); color: #eafaf4;
  padding: 7px 15px; border-radius: 20px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1; transition: background .15s, transform .15s;
  white-space: nowrap; flex-shrink: 0; }
.nav-btn .nav-ic { font-size: 15px; }
.nav-btn:hover { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.35); transform: translateY(-1px); }
.nav-btn.active { background: #fff; color: var(--wa-green-dark); border-color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.18); }

/* Responsivo: em telas estreitas o topo continua em UMA linha */
@media (max-width: 1150px) { .brand span, .clock { display: none; } .topbar { gap: 10px; } }
@media (max-width: 950px) {
  .nav-btn .nav-lbl { display: none; }           /* botões viram só ícone */
  .nav-btn { padding: 8px 11px; }
  .nav-btn .nav-ic { font-size: 17px; }
  .wa-status span:last-child { display: none; }   /* esconde o texto "Conectado" */
}
@media (max-width: 720px) { .current-user { display: none; } .topbar { padding: 0 10px; } }

/* Botão voltar (só aparece no modo celular) */
.back-btn { display: none; font-size: 26px; line-height: 1; margin-right: 4px; }

/* Telas médias: aproveita melhor o espaço das mensagens */
@media (max-width: 900px) {
  .chat-list { min-width: 240px; width: 34%; }
  .bubble { max-width: 84%; }
  .messages { padding: 12px 3%; }
}

/* Telas pequenas / celular: lista OU conversa em tela cheia */
@media (max-width: 600px) {
  .wa-layout { position: relative; }
  .chat-list { width: 100%; min-width: 0; max-width: none; border-right: none; }
  .conversation { position: absolute; inset: 0; z-index: 4; display: none; }
  body.chat-open .chat-list { display: none; }
  body.chat-open .conversation { display: flex; }
  .back-btn { display: inline-flex; }
  .bubble { max-width: 88%; font-size: 14.5px; }
  .messages { padding: 10px 8px; }
  .contact-panel { width: 100%; max-width: 100%; }
  .panel-grid { grid-template-columns: 1fr; }
  .modal-box { width: 94%; }
}
.clock { color: #d9f2ec; font-size: 12px; font-variant-numeric: tabular-nums; }
.ghost { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff;
  padding: 5px 12px; border-radius: 16px; cursor: pointer; font-size: 13px; }
.ghost.small { padding: 4px 10px; font-size: 12px; border-color: var(--border); color: var(--muted); }
.current-user { color: #d9f2ec; font-size: 13px; }
.current-user .role-tag { background: rgba(255,255,255,.2); padding: 1px 7px; border-radius: 8px; font-size: 11px; margin-left: 4px; }

/* ===== VIEWS ===== */
.view { flex: 1; overflow: hidden; display: none; }
.view.active { display: flex; }
#view-scheduled.active, #view-contacts.active, #view-connection.active, #view-users.active, #view-logs.active {
  display: block; overflow-y: auto; padding: 24px; background: #f0f2f5; }
body.dark #view-scheduled.active, body.dark #view-contacts.active,
body.dark #view-connection.active, body.dark #view-users.active, body.dark #view-logs.active { background: #0b141a; }
.logs-box { background: #0b141a; color: #cfe9df; font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.5; padding: 14px; border-radius: 8px; height: calc(100vh - 200px);
  overflow: auto; white-space: pre-wrap; word-break: break-word; }
.logs-box .log-err { color: #ff6b6b; }
.logs-box .log-warn { color: #f9c74f; }
.logs-box .log-info { color: #8ecae6; }

/* ===== LAYOUT WHATSAPP ===== */
.wa-layout { display: flex; width: 100%; height: 100%; }
.chat-list { width: 30%; min-width: 300px; max-width: 420px; background: var(--panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.chat-list-head { padding: 8px 12px; display: flex; gap: 8px; background: var(--panel); }
.chat-list-head input { flex: 1; padding: 8px 14px 8px 38px; border: none; border-radius: 8px;
  background: var(--header); font-size: 14px; color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667781' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; }
.chat-list-head input:focus { outline: none; }
.icon-btn { background: transparent; border: none; width: 40px; height: 40px; border-radius: 50%;
  cursor: pointer; font-size: 18px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--hover); }
.chat-items { flex: 1; overflow-y: auto; }
.chat-items.hidden { display: none; }
/* Abas de filtro da lista */
.chat-filters { display: flex; gap: 6px; padding: 4px 12px 8px; flex-wrap: wrap; }
.chat-filter { padding: 5px 12px; border: none; background: var(--header); color: var(--muted);
  border-radius: 16px; font-size: 13px; cursor: pointer; }
.chat-filter:hover { background: var(--hover); }
.chat-filter.active { background: var(--wa-green); color: #fff; }
/* Cabeçalho da busca global e favoritas */
.search-head { padding: 10px 14px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--wa-green-dark); font-weight: 600; }
.star-mark { font-size: 11px; margin-right: 3px; }
.starred-list { max-height: 62vh; overflow-y: auto; }
.starred-item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.starred-item:hover { background: var(--hover); }
.chat-item { display: flex; align-items: center; gap: 13px; padding: 10px 14px; cursor: pointer; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.avatar { width: 49px; height: 49px; border-radius: 50%; background: #dfe5e7; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 500; flex-shrink: 0; font-size: 18px; }
.avatar.group { background: #b3bcc2; }
.avatar-img { width: 49px; height: 49px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #dfe5e7; }
.chat-meta { flex: 1; min-width: 0; border-top: 1px solid var(--border); padding: 10px 0; margin-top: -10px; }
.chat-item:first-child .chat-meta { border-top: none; }
.chat-meta .name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta .preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-right { text-align: right; flex-shrink: 0; align-self: flex-start; padding-top: 12px; }
.chat-right .time { font-size: 12px; color: var(--muted); }
.unread { background: var(--wa-green); color: #fff; border-radius: 12px; font-size: 12px;
  min-width: 20px; height: 20px; line-height: 20px; padding: 0 6px; display: inline-block; margin-top: 5px; font-weight: 600; }
/* Conversa com mensagens não lidas: nome/preview em destaque e hora verde, igual WhatsApp Web */
.chat-item.has-unread .chat-meta .name { font-weight: 700; }
.chat-item.has-unread .chat-meta .preview { color: var(--text); font-weight: 500; }
.chat-right .time.unread-time { color: var(--wa-green); font-weight: 600; }

/* ===== CONVERSA ===== */
.conversation { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.chat-bg-doodle { position: absolute; inset: 0; opacity: .4; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%23d5cec4' stroke-width='1'%3E%3Ccircle cx='10' cy='10' r='3'/%3E%3Cpath d='M30 20l6 6-6 6-6-6z'/%3E%3Cpath d='M45 40h8M49 36v8'/%3E%3C/g%3E%3C/svg%3E"); }
.conv-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; background: #f0f2f5; border-bottom: 6px solid var(--wa-green); position: relative; z-index: 1; padding: 0 20px; }
.empty-illus { font-size: 96px; opacity: .35; margin-bottom: 6px; }
.empty-title { font-weight: 300; font-size: 30px; color: #41525d; margin-bottom: 12px; }
.empty-sub { color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 460px; }
body.dark .conv-empty { background: #222e35; }
.conv-active { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 1; }
.conv-head { background: var(--header); padding: 10px 16px; border-left: 1px solid var(--border);
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.conv-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; margin-right: 12px; background: #dfe5e7; }
.conv-name { font-size: 16px; font-weight: 500; }
.conv-head-info { display: flex; align-items: center; cursor: pointer; flex: 1; min-width: 0; border-radius: 6px; padding: 2px 4px; }
.conv-head-info:hover { background: rgba(0,0,0,.04); }
body.dark .conv-head-info:hover { background: rgba(255,255,255,.06); }
.conv-head-actions { display: flex; gap: 2px; flex-shrink: 0; }
/* Painel de dados do contato/grupo (drawer direita) */
.contact-panel { position: absolute; top: 0; right: 0; bottom: 0; width: 360px; max-width: 88%;
  background: var(--panel); border-left: 1px solid var(--border); z-index: 6; display: flex; flex-direction: column;
  box-shadow: -4px 0 16px rgba(0,0,0,.12); }
.cp-head { background: var(--header); padding: 14px 16px; display: flex; align-items: center; gap: 14px; flex-shrink: 0; font-weight: 500; }
.cp-body { flex: 1; overflow-y: auto; }
.cp-top { text-align: center; padding: 24px 16px; border-bottom: 8px solid var(--bg); }
.cp-avatar { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; display: block; }
.cp-avatar-ph { background: var(--wa-green); color: #fff; font-size: 40px; display: flex; align-items: center; justify-content: center; }
.cp-name { font-size: 19px; font-weight: 500; }
.cp-section { padding: 14px 16px; border-bottom: 8px solid var(--bg); }
.cp-section h4 { font-size: 14px; color: var(--wa-green-dark); margin-bottom: 10px; font-weight: 500; }
.cp-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.cp-media img { width: 100%; height: 96px; object-fit: cover; border-radius: 4px; cursor: pointer; }
.cp-doc, .cp-link { display: block; padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.04); margin-bottom: 6px;
  text-decoration: none; color: inherit; font-size: 13px; word-break: break-all; }
body.dark .cp-doc, body.dark .cp-link { background: rgba(255,255,255,.06); }
.cp-part { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.cp-part .avatar { width: 36px; height: 36px; font-size: 13px; }
.cp-part-info { flex: 1; min-width: 0; }
.cp-admin { font-size: 11px; color: var(--wa-green-dark); border: 1px solid var(--wa-green); border-radius: 8px; padding: 0 5px; }

/* Busca dentro da conversa */
.msg-search-bar { display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--header); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.msg-search-bar input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); font-size: 14px; }
.bubble.search-hit { box-shadow: 0 0 0 2px var(--warn), 0 1px .5px rgba(11,20,26,.13); }
.bubble.search-current { box-shadow: 0 0 0 3px var(--wa-green), 0 1px .5px rgba(11,20,26,.13); }
/* Destaque ao pular para a mensagem citada */
.bubble.jump-flash { animation: jumpFlash 1.6s ease; }
@keyframes jumpFlash { 0%, 100% { box-shadow: 0 1px .5px rgba(11,20,26,.13); } 25%, 60% { box-shadow: 0 0 0 3px var(--wa-green); } }
.messages { flex: 1; overflow-y: auto; padding: 12px 6% 12px 6%; display: flex; flex-direction: column; gap: 2px; }

/* Linha da mensagem (avatar + balão) */
.msg-row { display: flex; align-items: flex-end; gap: 6px; }
.msg-row.out { justify-content: flex-end; }
.msg-row.in { justify-content: flex-start; }
.msg-avatar { width: 28px; height: 28px; border-radius: 50%; color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; margin-bottom: 2px; }
.msg-avatar-spacer { width: 28px; flex-shrink: 0; }

/* Separador de data */
.date-sep { display: flex; justify-content: center; margin: 12px 0 8px; }
.date-sep span { background: #fff; color: var(--muted); font-size: 12px; padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 1px .5px rgba(11,20,26,.13); text-transform: uppercase; letter-spacing: .3px; }
body.dark .date-sep span { background: #182229; color: #8696a0; }

/* Balões com rabinho (só na 1ª do grupo) */
.bubble { max-width: 70%; padding: 6px 9px 8px; border-radius: 8px; font-size: 14.2px; line-height: 19px;
  box-shadow: 0 1px .5px rgba(11,20,26,.13); position: relative; word-wrap: break-word; white-space: normal; }
.b-text { white-space: pre-wrap; }
.bubble.in { background: var(--bubble-in); align-self: flex-start; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; }
.bubble.in.tail { border-top-left-radius: 0; }
.bubble.out.tail { border-top-right-radius: 0; }
.bubble.in.tail::before { content: ""; position: absolute; top: 0; left: -8px; width: 8px; height: 13px;
  background: var(--bubble-in); clip-path: polygon(100% 0, 0 0, 100% 100%); }
.bubble.out.tail::before { content: ""; position: absolute; top: 0; right: -8px; width: 8px; height: 13px;
  background: var(--bubble-out); clip-path: polygon(0 0, 100% 0, 0 100%); }

/* Álbum de fotos (grade) */
.album { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; max-width: 272px; border-radius: 6px; overflow: hidden; }
.album-cell { position: relative; }
.album-cell img { width: 100%; height: 132px; object-fit: cover; display: block; }
.album-more { position: absolute; inset: 0; background: rgba(0,0,0,.55); color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 28px; font-weight: 300; }
.album-dl { margin-top: 5px; background: var(--wa-green-dark); color: #fff; border: none; border-radius: 14px;
  padding: 5px 12px; font-size: 12px; cursor: pointer; display: block; }
.album-dl:hover { background: var(--wa-green); }
.bubble .b-author { font-size: 12.5px; font-weight: 500; color: var(--wa-green-dark); margin-bottom: 2px; }
.bubble .b-time { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; float: right;
  margin-left: 10px; position: relative; top: 4px; }
.bubble img { max-width: 260px; border-radius: 6px; display: block; margin-bottom: 3px; }
.chat-img { cursor: pointer; }
/* Figurinha / GIF */
.sticker { max-width: 130px; max-height: 130px; display: block; }
.gif-media { max-width: 260px; border-radius: 6px; display: block; margin-bottom: 3px; }
/* Localização / contato / enquete */
.loc-card, .vcard-card { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.05);
  border-radius: 8px; padding: 8px 10px; text-decoration: none; color: inherit; margin-bottom: 3px; min-width: 180px; }
body.dark .loc-card, body.dark .vcard-card { background: rgba(255,255,255,.06); }
.loc-map, .vcard-ic { font-size: 26px; }
.loc-open { color: var(--wa-green-dark); font-size: 12px; }
.poll-card { background: rgba(0,0,0,.05); border-radius: 8px; padding: 8px 10px; margin-bottom: 3px; min-width: 200px; }
body.dark .poll-card { background: rgba(255,255,255,.06); }
.poll-q { font-weight: 600; margin-bottom: 6px; }
.poll-opt { border: 1px solid var(--border); border-radius: 14px; padding: 5px 12px; margin-bottom: 4px; font-size: 13px; }
/* Link e emoji grande */
.msg-link { color: #027eb5; text-decoration: underline; word-break: break-all; }
/* Menção (@) */
.mention-menu { position: absolute; left: 12px; right: 12px; bottom: 60px; z-index: 12; max-height: 220px;
  overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.mention-menu button { display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 10px 14px; font-size: 14px; cursor: pointer; color: var(--text); }
.mention-menu button:hover { background: var(--hover); }
.mention { color: var(--wa-green-dark); font-weight: 600; }
body.dark .mention { color: #53bdeb; }
body.dark .msg-link { color: #53bdeb; }
.emoji-big { font-size: 40px; line-height: 1.1; }
/* Áudio com velocidade */
.audio-wrap { display: flex; align-items: center; gap: 6px; }
.audio-wrap audio { height: 38px; }
.audio-speed { border: none; background: var(--wa-green-dark); color: #fff; border-radius: 12px;
  font-size: 11px; padding: 3px 8px; cursor: pointer; flex-shrink: 0; }
/* Botão carregar mensagens antigas */
.load-older { display: block; margin: 6px auto 12px; background: var(--panel); border: 1px solid var(--border);
  color: var(--wa-green-dark); border-radius: 16px; padding: 6px 16px; font-size: 13px; cursor: pointer; }
.load-older:hover { background: var(--hover); }
/* Reagir ao passar o mouse */
.hover-react { position: absolute; top: -12px; right: 6px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 50%; width: 26px; height: 26px; font-size: 14px; cursor: pointer; display: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.2); align-items: center; justify-content: center; padding: 0; }
.bubble:hover .hover-react { display: flex; }

/* Visualizador de imagem (lightbox) */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 200;
  display: flex; align-items: center; justify-content: center; }
.lb-img { max-width: 90vw; max-height: 84vh; border-radius: 4px; box-shadow: 0 4px 30px rgba(0,0,0,.5); }
.lb-close { position: absolute; top: 16px; right: 26px; background: none; border: none; color: #fff;
  font-size: 42px; line-height: 1; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12);
  border: none; color: #fff; font-size: 38px; width: 54px; height: 54px; border-radius: 50%; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-prev { left: 24px; } .lb-next { right: 24px; }
.lb-dl { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--wa-green-dark);
  color: #fff; text-decoration: none; padding: 9px 20px; border-radius: 22px; font-size: 14px; }
.lb-dl:hover { background: var(--wa-green); }
.bubble video { max-width: 260px; border-radius: 6px; display: block; margin-bottom: 3px; }
.bubble audio { display: block; margin-bottom: 3px; height: 40px; width: 260px; }
.bubble .media-tag { font-style: italic; color: var(--muted); }
.bubble a.media-tag { text-decoration: none; }
/* Cartão de documento (PDF etc.) */
.doc-card { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.06); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 3px; text-decoration: none; color: inherit; min-width: 190px; max-width: 260px; }
body.dark .doc-card { background: rgba(255,255,255,.06); }
.doc-card:hover { background: rgba(0,0,0,.1); }
body.dark .doc-card:hover { background: rgba(255,255,255,.1); }
.doc-ic { font-size: 30px; flex-shrink: 0; }
.doc-info { display: flex; flex-direction: column; min-width: 0; }
.doc-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-open { font-size: 12px; color: var(--muted); }

/* Citação (resposta) */
.quote { border-left: 4px solid var(--wa-green); background: rgba(0,0,0,.05); border-radius: 4px;
  padding: 4px 8px; margin-bottom: 4px; font-size: 13px; max-width: 100%; overflow: hidden; }
body.dark .quote { background: rgba(255,255,255,.06); }
.quote-author { font-weight: 600; font-size: 12.5px; }
.quote-body { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Encaminhada / apagada */
.fwd { font-size: 12.5px; color: var(--muted); font-style: italic; margin-bottom: 2px; }
.deleted-msg { font-style: italic; color: var(--muted); }
/* Reações */
.reactions { position: absolute; bottom: -12px; right: 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 1px 6px; font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,.15); }

/* Menu de contexto */
.msg-menu { position: fixed; z-index: 210; background: var(--panel); border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25); padding: 5px 0; min-width: 160px; }
.msg-menu button { display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 9px 16px; font-size: 14px; cursor: pointer; color: var(--text); }
.msg-menu button:hover { background: var(--hover); }
.msg-menu .fromme-only { color: var(--text); }
/* Barra rápida de reações */
.react-bar { position: fixed; z-index: 215; background: var(--panel); border: 1px solid var(--border);
  border-radius: 24px; padding: 4px 6px; display: flex; gap: 2px; box-shadow: 0 4px 18px rgba(0,0,0,.22); }
.react-bar button { border: none; background: none; font-size: 22px; cursor: pointer; padding: 3px 6px;
  border-radius: 50%; line-height: 1; transition: transform .1s; }
.react-bar button:hover { background: var(--hover); transform: scale(1.25); }

/* Barra de responder (acima do composer) */
.reply-bar { background: var(--header); padding: 8px 16px 0; display: flex; align-items: center; gap: 10px; }
.reply-content { flex: 1; background: var(--panel); border-left: 4px solid var(--wa-green);
  border-radius: 6px; padding: 6px 10px; min-width: 0; }
.reply-author { font-weight: 600; font-size: 13px; color: var(--wa-green-dark); }
.reply-body { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-close { background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.bubble .ack { font-size: 11px; color: #667781; margin-left: 2px; }
.bubble .ack.read { color: var(--tick-read); }
.group-dl { display: flex; margin: 1px 8px 6px; }
.group-dl.out { justify-content: flex-end; } .group-dl.in { justify-content: flex-start; }
.group-dl button { background: var(--wa-green-dark); color: #fff; border: none; border-radius: 16px;
  padding: 5px 14px; font-size: 12px; cursor: pointer; }
.group-dl button:hover { background: var(--wa-green); }
.mic-recording { color: var(--danger) !important; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ===== COMPOSER ===== */
.composer { background: var(--header); padding: 8px 16px; display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; }
.composer textarea { flex: 1; border: none; border-radius: 8px; padding: 10px 14px; font-size: 15px;
  font-family: inherit; resize: none; max-height: 120px; background: var(--panel); color: var(--text); }
.composer textarea:focus { outline: none; }
.send-btn { background: transparent; color: var(--muted); border: none; width: 42px; height: 42px;
  border-radius: 50%; cursor: pointer; font-size: 22px; flex-shrink: 0; }
.send-btn:hover { background: var(--hover); }
/* Seletor de emoji */
.emoji-panel { position: absolute; bottom: 62px; left: 10px; width: 340px; max-height: 260px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; z-index: 30; box-shadow: 0 4px 20px rgba(0,0,0,.2); }
.emoji-item { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; border-radius: 6px; line-height: 1; }
.emoji-item:hover { background: var(--hover); }

/* Menu de anexo (+) */
.attach-menu { position: absolute; bottom: 62px; left: 10px; background: var(--panel); border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25); padding: 6px 0; z-index: 30; min-width: 190px; }
.attach-menu button { display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 11px 18px; font-size: 14px; cursor: pointer; color: var(--text); }
.attach-menu button:hover { background: var(--hover); }

/* Botão "ir para o fim" */
.scroll-bottom { position: absolute; right: 22px; bottom: 78px; width: 42px; height: 42px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 24px; cursor: pointer;
  z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.2); display: flex; align-items: center; justify-content: center; }
.scroll-bottom:hover { background: var(--hover); }

.schedule-bar { background: var(--header); padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  font-size: 13px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.schedule-bar input[type=datetime-local], .schedule-bar input[type=time] {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); font-size: 13px; }
.schedule-bar input[type=time]:focus, .schedule-bar input[type=datetime-local]:focus {
  outline: none; border-color: var(--wa-green); box-shadow: 0 0 0 2px rgba(37,211,102,.15); }
#confirmSchedule { background: var(--wa-green); color: #fff; border-color: var(--wa-green); font-weight: 600; }
#confirmSchedule:hover { filter: brightness(1.05); }
#schedDayLabel { font-weight: 500; }
#confirmSchedule { background: var(--wa-green-dark); color: #fff; border: none; border-radius: 18px;
  padding: 8px 18px; font-size: 13px; font-weight: 500; cursor: pointer; }
#confirmSchedule:hover { background: var(--wa-green); }

/* Banner de aviso no topo */
.wa-banner { background: #fff3cd; color: #7a5c00; padding: 8px 16px; font-size: 13px; text-align: center;
  flex-shrink: 0; border-bottom: 1px solid #f0d98a; }
body.dark .wa-banner { background: #3a2f0a; color: #ffd873; border-color: #4a3d10; }
.banner-link { background: var(--wa-green-dark); color: #fff; border: none; border-radius: 12px;
  padding: 3px 12px; font-size: 12px; cursor: pointer; margin-left: 8px; }
.banner-link:hover { background: var(--wa-green); }

/* Abas Contatos / Grupos na Nova conversa */
.nc-tabs { display: flex; gap: 6px; margin: 4px 0 12px; }
.nc-tab { flex: 1; padding: 8px 10px; border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); border-radius: 8px; font-size: 13px; cursor: pointer; }
.nc-tab.active { background: var(--wa-green-dark); color: #fff; border-color: var(--wa-green-dark); font-weight: 500; }

/* Prévia do agendamento (como vai chegar) */
.prev-bubble { background: var(--bubble-out); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
body.dark .prev-bubble { color: #e9edef; }
.prev-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 4px; margin-bottom: 8px; }
.prev-imgs img { width: 100%; border-radius: 6px; display: block; object-fit: cover; }
.prev-bubble .b-text { white-space: pre-wrap; font-size: 14px; line-height: 1.45; }
.sched-eye { white-space: nowrap; }

/* Abas (sub-menus) da tela de Agendados */
.sched-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.sched-tab { padding: 8px 14px; border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  border-radius: 20px; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.sched-tab:hover { background: var(--hover); }
.sched-tab.active { background: var(--wa-green-dark); color: #fff; border-color: var(--wa-green-dark); font-weight: 500; }
.sched-tab.active .badge { background: rgba(255,255,255,0.28); color: #fff; }

/* Aviso de agendamento atrasado */
.sched-warn { background: #fff3cd; color: #7a5c00; padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
body.dark .sched-warn { background: #3a2f0a; color: #ffd873; }
.attach-preview { background: var(--header); padding: 8px 16px; font-size: 13px; }
.attach-preview img { max-height: 60px; border-radius: 6px; vertical-align: middle; margin-right: 8px; }

/* ===== PAINÉIS (agendados/contatos/conexão/usuários) ===== */
.panel { background: var(--panel); border-radius: 8px; padding: 22px; max-width: 900px; margin: 0 auto 20px;
  box-shadow: 0 1px 3px rgba(11,20,26,.1); }
.panel.center { text-align: center; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 1000px; margin: 0 auto; }
@media (max-width: 820px) { .panel-grid { grid-template-columns: 1fr; } }
.panel h2 { font-size: 18px; margin-bottom: 14px; font-weight: 500; }
.panel h3 { font-size: 14px; margin: 8px 0; }
.panel label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.panel input[type=text], .panel input[type=datetime-local], .panel textarea, .panel input[type=file], .panel select {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: var(--panel); color: var(--text); }
.panel input:focus, .panel textarea:focus { outline: none; border-color: var(--wa-green); }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.primary { margin-top: 14px; width: 100%; padding: 12px; background: var(--wa-green-dark); color: #fff;
  border: none; border-radius: 24px; cursor: pointer; font-size: 15px; font-weight: 500; }
.primary:hover { background: var(--wa-green); }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.badge { background: var(--wa-green); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; margin-left: 6px; }
.result { margin-top: 12px; font-size: 13px; }
.result.ok { color: var(--wa-green-dark); } .result.err { color: var(--danger); }
.radio-row { display: flex; gap: 20px; margin-top: 8px; } .radio-row label { display: inline; color: var(--text); }

/* Contatos / usuários */
.contacts-table, .recipient-list { max-height: 360px; overflow-y: auto; margin-top: 10px; }
.contact-row { display: flex; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.contact-row .info { flex: 1; } .contact-row .name { font-weight: 500; }
.contact-row .phone { color: var(--muted); font-size: 12px; }
.del-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 18px; }
.recipient-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px solid var(--border); }
.recipient-item label { flex: 1; cursor: pointer; } .recipient-item .phone { color: var(--muted); font-size: 12px; }
.bc-actions { display: flex; gap: 8px; margin: 8px 0; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #e7f3ff; color: #084298; }
.role-badge.admin { background: #ffe8cc; color: #8a4b00; }

/* Agendados */
.scheduled-list { display: flex; flex-direction: column; gap: 10px; }
.sched-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel); }
.sched-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.sched-noimg { background: var(--header); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.sched-item .s-info { flex: 1; min-width: 0; }
.sched-item .s-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-tag { font-size: 11px; padding: 3px 8px; border-radius: 10px; text-transform: uppercase; }
.status-scheduled { background: #fff3cd; color: #856404; }
.status-sent, .status-done { background: #d1e7dd; color: #0f5132; }
.status-failed { background: #f8d7da; color: #842029; }
.status-canceled { background: #eee; color: #555; }

/* Conexão */
#connArea img { border: 10px solid #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.conn-steps { text-align: left; max-width: 380px; margin: 16px auto; font-size: 14px; color: var(--muted); line-height: 1.8; }

/* Modais */
.modal { position: fixed; inset: 0; background: rgba(11,20,26,.55); display: flex; align-items: center;
  justify-content: center; z-index: 100; }
.modal-box { background: var(--panel); border-radius: 8px; padding: 24px; max-width: 560px; width: 90%;
  max-height: 85vh; overflow-y: auto; position: relative; }
.modal-box.small-box { max-width: 400px; }
.modal-box label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.modal-box input[type=text], .modal-box input[type=datetime-local], .modal-box textarea, .modal-box input[type=file] {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: var(--panel); color: var(--text); }
.modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 26px;
  cursor: pointer; color: var(--muted); }

.dot.auth_failure { background: #ff5c5c; }

/* ---- Barra de progresso do envio de arquivos ---- */
.upload-bar {
  /* Fixa no topo: serve para Conversa, Agendamento e Transmissão (telas diferentes) */
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff; border-bottom: 2px solid #00a884;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.upload-track {
  flex: 1; height: 6px; background: #e9edef; border-radius: 99px; overflow: hidden;
}
.upload-fill {
  height: 100%; width: 0; background: #00a884; border-radius: 99px;
  transition: width .2s ease;
}
.upload-txt { font-size: 12px; color: #667781; white-space: nowrap; }
@media (max-width: 600px) { .upload-txt { font-size: 11px; } }

/* Aviso GRANDE de sucesso após agendar */
#bigSuccess {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(11, 20, 26, 0.55);
  animation: bsFade .18s ease;
}
#bigSuccess.hidden { display: none; }
.big-success-card {
  background: #fff; border-radius: 18px; padding: 34px 40px;
  text-align: center; max-width: 90vw; width: 420px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.35);
  animation: bsPop .22s cubic-bezier(.2,.9,.3,1.3);
}
.bs-check {
  width: 84px; height: 84px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--wa-green);
  display: flex; align-items: center; justify-content: center;
  font-size: 46px; color: #fff; line-height: 1;
}
.bs-title { font-size: 22px; font-weight: 700; color: #111b21; margin-bottom: 6px; }
.bs-sub { font-size: 15px; color: #3b4a54; margin-bottom: 14px; }
.bs-hint { font-size: 12px; color: #8696a0; }
@keyframes bsFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bsPop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (max-width: 600px) { .big-success-card { width: 88vw; padding: 28px 22px; } .bs-title { font-size: 20px; } }
