/* ═══════════════════════════════════════════════════════════════════
   WHAT JUJU — app.css COMPLETO
   ═══════════════════════════════════════════════════════════════════ */

/* ── Temas completos ─────────────────────────────────────────────── */
:root {
  --primary: #075E54;
  --primary-dark: #054d44;
  --accent: #25D366;
  --accent-dark: #1da852;
  --bg-app: #ece5dd;
  --bg-chat: #e5ddd5;
  --bubble-user: #dcf8c6;
  --bubble-ai: #ffffff;
  --text-primary: #111b21;
  --text-secondary: #667781;
  --text-muted: #8696a0;
  --header-bg: #075E54;
  --header-text: #ffffff;
  --input-bg: #ffffff;
  --border: #d1d7db;
  --shadow: rgba(0,0,0,.13);
  --unread-bg: #25D366;
  --unread-text: #ffffff;
  --sidebar-bg: #f0f2f5;
  --modal-bg: #ffffff;
  --danger: #f44336;
  --warning: #ff9800;
  --info: #2196f3;
  --success: #4caf50;
  --icon-color: #075E54;
  --icon-hover: #25D366;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --primary: #1a1f36;
  --primary-dark: #0f1220;
  --accent: #4e8cff;
  --accent-dark: #3a72e8;
  --bg-app: #13161f;
  --bg-chat: #1a1e2e;
  --bubble-user: #253359;
  --bubble-ai: #1e2540;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --header-bg: #1a1f36;
  --header-text: #e2e8f0;
  --input-bg: #1e2540;
  --border: #2d3561;
  --sidebar-bg: #151827;
  --modal-bg: #1a1f36;
  --unread-bg: #4e8cff;
  --icon-color: #4e8cff;
  --icon-hover: #7aa8ff;
}

[data-theme="light"] {
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --accent: #42a5f5;
  --accent-dark: #1e88e5;
  --bg-app: #f5f5f5;
  --bg-chat: #e3f2fd;
  --bubble-user: #bbdefb;
  --bubble-ai: #ffffff;
  --text-primary: #212121;
  --text-secondary: #757575;
  --text-muted: #9e9e9e;
  --header-bg: #1976d2;
  --header-text: #ffffff;
  --input-bg: #ffffff;
  --border: #e0e0e0;
  --sidebar-bg: #fafafa;
  --modal-bg: #ffffff;
  --unread-bg: #1976d2;
  --icon-color: #1976d2;
  --icon-hover: #42a5f5;
}

[data-theme="rainbow"] {
  --primary: #ff6b6b;
  --primary-dark: #ee5a24;
  --accent: #feca57;
  --accent-dark: #ff9f43;
  --bg-app: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #a1c4fd 100%);
  --bg-chat: rgba(255,255,255,0.3);
  --bubble-user: #ff7675;
  --bubble-ai: rgba(255,255,255,0.95);
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --text-muted: #b2bec3;
  --header-bg: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
  --header-text: #2d3436;
  --input-bg: rgba(255,255,255,0.9);
  --border: #dfe6e9;
  --sidebar-bg: rgba(255,255,255,0.5);
  --modal-bg: rgba(255,255,255,0.95);
  --unread-bg: #fd79a8;
  --icon-color: #ff7675;
  --icon-hover: #d63031;
}

[data-theme="pink"] {
  --primary: #e91e63;
  --primary-dark: #c2185b;
  --accent: #f48fb1;
  --accent-dark: #f06292;
  --bg-app: #fce4ec;
  --bg-chat: #f8bbd9;
  --bubble-user: #f48fb1;
  --bubble-ai: #ffffff;
  --text-primary: #880e4f;
  --text-secondary: #ad1457;
  --text-muted: #f48fb1;
  --header-bg: #e91e63;
  --header-text: #ffffff;
  --input-bg: #ffffff;
  --border: #f48fb1;
  --sidebar-bg: #fce4ec;
  --modal-bg: #ffffff;
  --unread-bg: #e91e63;
  --icon-color: #e91e63;
  --icon-hover: #f06292;
}

[data-theme="orange"] {
  --primary: #f57c00;
  --primary-dark: #ef6c00;
  --accent: #ffb74d;
  --accent-dark: #ffa726;
  --bg-app: #fff3e0;
  --bg-chat: #ffe0b2;
  --bubble-user: #ffe0b2;
  --bubble-ai: #ffffff;
  --text-primary: #e65100;
  --text-secondary: #ef6c00;
  --text-muted: #ffcc80;
  --header-bg: #f57c00;
  --header-text: #ffffff;
  --input-bg: #ffffff;
  --border: #ffe0b2;
  --sidebar-bg: #fff3e0;
  --modal-bg: #ffffff;
  --unread-bg: #f57c00;
  --icon-color: #f57c00;
  --icon-hover: #ffb74d;
}

[data-theme="purple"] {
  --primary: #6a1b9a;
  --primary-dark: #4a148c;
  --accent: #ce93d8;
  --accent-dark: #ba68c8;
  --bg-app: #f3e5f5;
  --bg-chat: #eed6f3;
  --bubble-user: #ce93d8;
  --bubble-ai: #ffffff;
  --text-primary: #4a148c;
  --text-secondary: #7b1fa2;
  --text-muted: #9c6daf;
  --header-bg: #6a1b9a;
  --header-text: #ffffff;
  --input-bg: #ffffff;
  --border: #e1bee7;
  --sidebar-bg: #f3e5f5;
  --modal-bg: #ffffff;
  --unread-bg: #6a1b9a;
  --icon-color: #6a1b9a;
  --icon-hover: #ce93d8;
  --shadow: rgba(106,27,154,.15);
}

[data-theme="darkblue"] {
  --primary: #1a1f36;
  --primary-dark: #0f1220;
  --accent: #4e8cff;
  --accent-dark: #3a72e8;
  --bg-app: #13161f;
  --bg-chat: #161a28;
  --bubble-user: #2d4a8a;
  --bubble-ai: #252d47;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --header-bg: #1a1f36;
  --header-text: #e2e8f0;
  --input-bg: #1e2540;
  --border: #2d3561;
  --sidebar-bg: #151827;
  --modal-bg: #1a1f36;
  --unread-bg: #4e8cff;
  --icon-color: #4e8cff;
  --icon-hover: #7aa8ff;
  --shadow: rgba(0,0,0,.35);
}

[data-theme="green"] {
  --primary: #075E54;
  --primary-dark: #054d44;
  --accent: #25D366;
  --accent-dark: #1da852;
  --bg-app: #ece5dd;
  --bg-chat: #e5ddd5;
  --bubble-user: #dcf8c6;
  --bubble-ai: #ffffff;
  --text-primary: #111b21;
  --text-secondary: #667781;
  --text-muted: #8696a0;
  --header-bg: #075E54;
  --header-text: #ffffff;
  --input-bg: #ffffff;
  --border: #d1d7db;
  --sidebar-bg: #f0f2f5;
  --modal-bg: #ffffff;
  --unread-bg: #25D366;
  --icon-color: #075E54;
  --icon-hover: #25D366;
}

/* ── Reset & Base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-app);
  overflow: hidden;
}

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  overflow: auto;
}

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-card {
  background: var(--modal-bg);
  border-radius: 24px;
  padding: 44px 38px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 80px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.06);
  animation: fadeInUp .5s cubic-bezier(.22,1,.36,1);
  border: 1.5px solid rgba(255,255,255,.08);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent, var(--primary-dark)));
  border-radius: 24px 24px 0 0;
}

.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo h1 { font-size: 2.6rem; font-weight: 800; color: var(--primary); letter-spacing: 3px; }
.login-logo p { color: var(--text-secondary); font-size: .9rem; margin-top: 6px; opacity: .85; }
.login-logo-img { max-height: 80px; max-width: 220px; object-fit: contain; display: block; margin: 0 auto 10px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.15)); }
.login-logo-emoji { font-size: 2.8rem; line-height: 1; margin-bottom: 6px; }

.login-form .form-group { margin-bottom: 18px; }
.login-form label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 7px; letter-spacing: .3px; }

/* Input wrapper com ícone */
.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.login-input-wrap .login-input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  opacity: .5;
  pointer-events: none;
  transition: opacity .2s, color .2s;
}
.login-input-wrap input {
  width: 100%;
  padding: 13px 14px 13px 42px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: border-color .2s, box-shadow .2s;
}
.login-input-wrap input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 79,195,247), .15); }
.login-input-wrap input:focus ~ .login-input-icon,
.login-input-wrap input:focus + .login-input-icon { color: var(--primary); opacity: 1; }
/* Ícone dentro — posição correta com selector anterior */
.login-input-wrap:focus-within .login-input-icon { color: var(--primary); opacity: 1; }

/* Toggle Lembrar-me */
.login-remember {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 8px;
}
.login-remember label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text-secondary);
  font-weight: 500;
  user-select: none;
  margin: 0;
}
.login-remember input[type="checkbox"] { display: none; }
.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background .25s;
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .25s cubic-bezier(.4,.0,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.login-remember input:checked + .toggle-track {
  background: var(--primary);
}
.login-remember input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.btn-login {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark, var(--primary)));
  color: #fff;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 8px;
  transition: all 0.3s cubic-bezier(.4,.0,.2,1);
  cursor: pointer;
  border: none;
  letter-spacing: .5px;
  box-shadow: 0 4px 15px rgba(var(--primary-rgb, 79,195,247), .3);
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(var(--primary-rgb, 79,195,247), .4); }
.btn-login:active { transform: translateY(0); }

.login-error {
  background: rgba(255,0,0,.06);
  border: 1px solid rgba(255,0,0,.15);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: .88rem;
  margin-top: 14px;
  display: none;
  animation: fadeInUp .3s ease;
}

/* ── Force Password Change ───────────────────────────────────────── */
.force-pw-card {
  background: var(--modal-bg);
  border-radius: 16px;
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: fadeInUp .4s ease;
}

/* ── App Layout ──────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh; /* fallback pra browsers antigos */
  height: 100dvh; /* altura dinâmica - considera barra de endereço do mobile */
  width: 100vw;
  background: var(--bg-chat);
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────── */
#main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 60px;
  background: var(--header-bg);
  color: var(--header-text);
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 10;
}

.header-logo { display: flex; align-items: center; gap: 10px; }
.header-logo-text { font-size: 1.4rem; font-weight: 800; letter-spacing: 2px; color: var(--header-text); }

.header-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  border: 2px solid rgba(255,255,255,.4);
  transition: all 0.3s;
}
.header-user-avatar:hover { border-color: rgba(255,255,255,.9); transform: scale(1.05); }
.header-user-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.header-user-avatar span { font-weight: bold; font-size: 1rem; }

/* ── HEADER ACTIONS (BOTÕES DO TOPO) ─────────────────────────────── */
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hbtn {
  padding: 8px 16px;
  border-radius: 30px;
  background: rgba(255,255,255,0.15);
  color: var(--header-text);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
}

.hbtn:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-2px);
}

.hbtn .hbtn-icon {
  font-size: 1.1rem;
  display: inline-block;
}

.hbtn span:not(.hbtn-icon) {
  display: inline-block;
}

/* Cores dos botões */
.hbtn-contacts {
  background: #25D366 !important;
  color: #fff !important;
}

.hbtn-profile {
  background: #34B7F1 !important;
  color: #fff !important;
}

.hbtn-admin {
  background: #9c27b0 !important;
  color: #fff !important;
}

.hbtn-logout {
  background: #f44336 !important;
  color: #fff !important;
}

/* MOBILE - Ícones sempre visíveis */
@media (max-width: 768px) {
  .header-actions {
    gap: 6px;
  }
  
  .hbtn {
    padding: 8px 12px;
    border-radius: 30px;
    gap: 6px;
  }
  
  .hbtn .hbtn-icon {
    font-size: 1.1rem;
    display: inline-block !important;
  }
  
  .hbtn span:not(.hbtn-icon) {
    display: inline-block !important;
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .hbtn {
    padding: 8px 10px;
  }
  
  .hbtn .hbtn-icon {
    font-size: 1rem;
  }
  
  .hbtn span:not(.hbtn-icon) {
    font-size: 0.65rem;
  }
}

/* Hover */
.hbtn-contacts:hover { background: #1da852 !important; transform: translateY(-2px); }
.hbtn-profile:hover { background: #1e88e5 !important; transform: translateY(-2px); }
.hbtn-admin:hover { background: #7b1fa2 !important; transform: translateY(-2px); }
.hbtn-logout:hover { background: #d32f2f !important; transform: translateY(-2px); }

/* ── TABELA DE CORES PARA CADA BOTÃO ─────────────────────────────── */
/* Cada botão tem sua própria cor distinta */
.hbtn-contacts { background: #25D366 !important; }
.hbtn-profile { background: #34B7F1 !important; }
.hbtn-admin { background: #9c27b0 !important; }
.hbtn-logout { background: #f44336 !important; }

/* Hover com cores mais escuras */
.hbtn-contacts:hover { background: #1da852 !important; }
.hbtn-profile:hover { background: #1e88e5 !important; }
.hbtn-admin:hover { background: #7b1fa2 !important; }
.hbtn-logout:hover { background: #d32f2f !important; }

/* ── Chat Area ───────────────────────────────────────────────────── */
#chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* Welcome Screen */
#welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
}
#welcome-screen .welcome-icon { font-size: 5rem; opacity: .4; }
#welcome-screen h2 { font-size: 1.5rem; font-weight: 600; color: var(--text-primary); }
#welcome-screen p { font-size: .95rem; max-width: 360px; color: var(--text-secondary); }

/* Chat View */
#chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  flex: 1 1 0;
}

/* Chat Header */
#chat-header {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background: var(--header-bg);
  color: var(--header-text);
  gap: 12px;
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-size: 1rem; font-weight: 600; }
.chat-header-status { font-size: .78rem; opacity: .75; }

.chat-header-actions { display: flex; gap: 8px; }
.chat-header-actions button {
  background: transparent;
  color: var(--header-text);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: .9rem;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}
.chat-header-actions button:hover { background: rgba(255,255,255,.15); transform: scale(1.05); }

/* Botões especiais no chat header */
.btn-group-chat { background: var(--accent) !important; color: #fff !important; }
.btn-edit-character { background: #ff9800 !important; color: #fff !important; }
.btn-delete-character { background: var(--danger) !important; color: #fff !important; }

/* ── Messages Container ──────────────────────────────────────────── */
#messages-container {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-chat);
  scroll-behavior: smooth;
}

/* ── MESSAGE BUBBLE COM PONTA APONTANDO PARA O AVATAR ────────────── */
.message-wrapper {
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
  max-width: 75%;
  animation: fadeInUp 0.2s ease;
  position: relative;
}

.message-wrapper.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message-wrapper.assistant { align-self: flex-start; }

/* Avatar */
.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  align-self: flex-end;
  box-shadow: 0 2px 6px var(--shadow);
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* BALÃO DO ASSISTENTE (personagem) - PONTA ESQUERDA */
.message-wrapper.assistant .msg-bubble {
  background: var(--bubble-ai);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  position: relative;
  word-break: break-word;
  font-size: .95rem;
  line-height: 1.45;
  box-shadow: 0 1px 2px var(--shadow);
}

.message-wrapper.assistant .msg-bubble::before {
  content: '';
  position: absolute;
  left: -10px;
  bottom: 8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 10px 8px 0;
  border-color: transparent var(--bubble-ai) transparent transparent;
  filter: drop-shadow(-1px 1px 0px var(--shadow));
}

/* BALÃO DO USUÁRIO - PONTA DIREITA */
.message-wrapper.user .msg-bubble {
  background: var(--bubble-user);
  color: var(--text-primary);
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  position: relative;
  word-break: break-word;
  font-size: .95rem;
  line-height: 1.45;
}

.message-wrapper.user .msg-bubble::before {
  content: '';
  position: absolute;
  right: -10px;
  bottom: 8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 0 8px 10px;
  border-color: transparent transparent transparent var(--bubble-user);
}

/* Nome do personagem dentro do balão */
.msg-sender-name {
  font-weight: bold;
  font-size: .75rem;
  color: var(--accent);
  margin-bottom: 4px;
  display: block;
}

/* Conteúdo da mensagem */
.msg-content { line-height: 1.4; }
.msg-content p { margin-bottom: 4px; }
.msg-content a { color: var(--accent); text-decoration: none; }
.msg-content a:hover { text-decoration: underline; }
.msg-content code {
  background: rgba(0,0,0,.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: .85em;
}
.msg-content pre {
  background: rgba(0,0,0,.08);
  padding: 8px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 6px 0;
}
.msg-content img.file-preview {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  margin-top: 4px;
  cursor: pointer;
}

/* Timestamp */
.msg-time {
  font-size: .65rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 5px;
}

/* Botão de áudio */
.msg-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .7rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(0,0,0,.06);
  border: none;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.msg-audio-btn:hover { background: rgba(0,0,0,.12); transform: scale(1.02); }
.msg-audio-btn.playing {
  background: var(--accent);
  color: #fff;
  animation: audio-pulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(var(--accent-rgb, 99,102,241), 0.4);
}
.msg-audio-btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

@keyframes audio-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.75; transform: scale(1.05); }
}

/* Streaming cursor */
.streaming-cursor::after {
  content: '▋';
  display: inline-block;
  animation: blink .8s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Typing Indicator ────────────────────────────────────────────── */
#typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 8px 14px;
  background: var(--bubble-ai);
  border-radius: 18px 18px 18px 4px;
  margin-top: 4px;
  margin-bottom: 6px;
  gap: 8px;
  align-items: center;
  box-shadow: 0 1px 2px var(--shadow);
}
#typing-indicator.visible { display: flex; }

.typing-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .7rem;
  overflow: hidden;
}
.typing-avatar img { width: 100%; height: 100%; object-fit: cover; }

.typing-dots { display: flex; gap: 4px; align-items: center; }
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 0.8s ease infinite;
}
.typing-dot:nth-child(2) { animation-delay: .16s; }
.typing-dot:nth-child(3) { animation-delay: .32s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.typing-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-left: 4px;
  white-space: nowrap;
  font-style: italic;
}

/* ── Search Info Bubble ──────────────────────────────────────────── */
.search-info-bubble {
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
  padding: 6px 16px;
  margin: 4px auto;
  max-width: 350px;
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border-color, rgba(0,0,0,0.08));
}

/* ── Scroll Button ───────────────────────────────────────────────── */
#scroll-bottom-btn {
  position: absolute;
  bottom: 90px;
  right: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--shadow);
  z-index: 100;
  border: none;
  transition: all 0.3s;
}
#scroll-bottom-btn.visible { display: flex; }
#scroll-bottom-btn:hover { transform: scale(1.1); background: var(--primary-dark); }

/* ── Input Bar ───────────────────────────────────────────────────── */
#input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.input-bar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--icon-color);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}
.input-bar-btn:hover { background: var(--border); color: var(--icon-hover); transform: scale(1.05); }

#message-input-wrap {
  flex: 1;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 8px 16px;
  min-height: 44px;
  max-height: 120px;
  transition: border-color var(--transition);
}
#message-input-wrap:focus-within { border-color: var(--accent); }

#message-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: .95rem;
  color: var(--text-primary);
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
}
#message-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}
.send-btn:hover { background: var(--primary-dark); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── File Preview Bar ────────────────────────────────────────────── */
#file-preview-bar {
  display: none;
  padding: 8px 16px;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
}
#file-preview-bar.visible { display: flex; }

.file-preview-item {
  background: var(--input-bg);
  padding: 6px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  border: 1px solid var(--border);
}
.file-preview-thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.file-preview-remove {
  cursor: pointer;
  color: var(--danger);
  font-weight: bold;
  font-size: 1.1rem;
  margin-left: 4px;
}
.file-preview-remove:hover { transform: scale(1.1); }

/* ── Emoji Picker ────────────────────────────────────────────────── */
#emoji-picker {
  position: absolute;
  bottom: 80px;
  left: 20px;
  background: var(--modal-bg);
  border-radius: 16px;
  padding: 12px;
  display: none;
  z-index: 200;
  box-shadow: 0 4px 20px var(--shadow);
  border: 1px solid var(--border);
}
#emoji-picker.visible { display: block; animation: fadeInUp 0.2s ease; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-btn {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
}
.emoji-btn:hover { background: var(--border); transform: scale(1.1); }

/* ── Modais ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--modal-bg);
  border-radius: 20px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalFadeIn 0.3s ease;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  padding: 0 8px;
}
.modal-close:hover { color: var(--text-primary); transform: scale(1.1); }

.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* Modal de contatos (slide lateral) */
#modal-contacts { justify-content: flex-start; }
#modal-contacts .modal-box {
  width: 360px;
  height: 100%;
  border-radius: 0 20px 20px 0;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  max-width: none;
}
#modal-contacts.open .modal-box { transform: translateX(0); }

/* Modal de perfil (centrado) */
#modal-profile { align-items: center; justify-content: center; }
#modal-profile .modal-box { transform: translateY(20px); transition: transform 0.25s ease; }
#modal-profile.open .modal-box { transform: translateY(0); }

/* ── Formulários ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: .95rem;
  transition: all 0.3s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* Range sliders for voice controls */
.form-range {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary, #ddd);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}
.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

/* ── Botões ──────────────────────────────────────────────────────── */
.btn {
  padding: 8px 20px;
  border-radius: 24px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d32f2f; transform: translateY(-2px); }
.btn-sm { padding: 4px 12px; font-size: .8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Contacts List ───────────────────────────────────────────────── */
.contacts-list { flex: 1; overflow-y: auto; padding: 8px; }
.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  position: relative;
}
.contact-item:hover { background: var(--sidebar-bg); border-color: var(--border); }
.contact-item.active { background: var(--accent); color: #fff; }

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.contact-avatar img { width: 100%; height: 100%; object-fit: cover; }

.contact-info { flex: 1; min-width: 0; }
.contact-name { font-weight: bold; font-size: .95rem; }
.contact-last-msg {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.contact-time { font-size: .7rem; color: var(--text-muted); }
.unread-badge {
  background: var(--unread-bg);
  color: var(--unread-text);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: .7rem;
  font-weight: bold;
}

.contact-item-actions {
  display: none;
  gap: 4px;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}
.contact-item:hover .contact-item-actions { display: flex; }
.contact-item-actions button { padding: 4px 8px; border-radius: 6px; font-size: .7rem; background: var(--border); cursor: pointer; border: none; }

.contacts-new-btn {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.contacts-new-btn:hover { background: var(--accent-dark); }

.contact-search-wrap { padding: 12px; border-bottom: 1px solid var(--border); }
.contact-search-wrap input {
  width: 100%;
  padding: 8px 14px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-primary);
}

/* ── Contacts Modal Tabs ─────────────────────────────────────────── */
.contacts-modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
}
.contacts-modal-tab {
  flex: 1;
  padding: 12px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all 0.2s;
}
.contacts-modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Character Modal Tabs ────────────────────────────────────────── */
.char-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  padding: 0 16px;
}
.char-tab {
  padding: 10px 16px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.char-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.char-tab-content { display: none; }
.char-tab-content.active { display: block; }

/* Delete button inside tab bar or modal header */
.btn-delete-tab {
  margin-left: auto;
  color: #e53935 !important;
  font-size: .82rem;
  padding: 6px 12px;
  border: 1px solid #e5393544;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-delete-tab:hover {
  background: #e5393515;
  border-color: #e53935;
}

/* Avatar upload */
.char-avatar-upload-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.char-avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 3px solid var(--border);
  transition: all 0.2s;
}
.char-avatar-preview:hover { border-color: var(--accent); transform: scale(1.02); }
.char-avatar-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  border-radius: 50%;
}
.char-avatar-preview:hover .profile-avatar-overlay { display: flex; }

/* ── Profile Modal ───────────────────────────────────────────────── */
.profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 3px solid var(--border);
}
.profile-avatar:hover .profile-avatar-overlay { display: flex; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Theme Selector */
.theme-selector {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.theme-swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s;
  border: 3px solid transparent;
}
.theme-swatch.selected { border-color: var(--accent); transform: scale(1.1); }
.theme-swatch:hover { transform: scale(1.05); }
.theme-green { background: #075E54; }
.theme-dark { background: #1a1f36; }
.theme-light { background: #1976d2; }
.theme-rainbow { background: linear-gradient(135deg, #ff9a9e, #fecfef, #a1c4fd); }
.theme-pink { background: #e91e63; }
.theme-orange { background: #f57c00; }
.theme-purple { background: #6a1b9a; }
.theme-darkblue { background: #1a1f36; }

/* ── Group Items ─────────────────────────────────────────────────── */
.group-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--modal-bg);
}
.group-item:hover { background: var(--sidebar-bg); border-color: var(--accent); transform: translateY(-2px); }

.group-avatar-stack {
  display: flex;
  position: relative;
  width: 50px;
  height: 50px;
  flex-shrink: 0;
}
.group-avatar-stack .ga {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .7rem;
  position: absolute;
  overflow: hidden;
  border: 2px solid var(--modal-bg);
}
.group-avatar-stack .ga:nth-child(1) { top: 0; left: 0; z-index: 3; }
.group-avatar-stack .ga:nth-child(2) { bottom: 0; right: 0; z-index: 2; }
.group-avatar-stack .ga:nth-child(3) { top: 12px; left: 12px; z-index: 1; }
.group-avatar-stack .ga img { width: 100%; height: 100%; object-fit: cover; }

.group-item-actions { display: flex; gap: 6px; margin-left: auto; }
.group-item-actions button {
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--border);
  border: none;
  cursor: pointer;
  font-size: .75rem;
  transition: all 0.2s;
}
.group-item-actions button:hover { background: var(--accent); color: #fff; transform: scale(1.05); }

/* Group chat header avatars */
.group-header-avatars { display: flex; }
.group-header-avatars .ga {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: bold;
  border: 2px solid var(--header-bg);
  overflow: hidden;
  margin-left: -8px;
}
.group-header-avatars .ga:first-child { margin-left: 0; }
.group-header-avatars .ga img { width: 100%; height: 100%; object-fit: cover; }

/* Group member chip */
.group-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sidebar-bg);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: .8rem;
  border: 1px solid var(--border);
}
.chip-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .7rem;
  overflow: hidden;
}
.chip-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chip-remove {
  cursor: pointer;
  color: var(--danger);
  font-weight: bold;
  margin-left: 4px;
}
.chip-remove:hover { transform: scale(1.1); }

/* Group reply quote */
.group-reply-quote {
  background: rgba(0,0,0,.05);
  border-left: 3px solid var(--accent);
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: .75rem;
}
.reply-quote-name { font-weight: bold; color: var(--accent); }
.reply-quote-text { color: var(--text-muted); }

/* ── Admin Modal ─────────────────────────────────────────────────── */
#modal-admin {
  align-items: stretch;
  justify-content: stretch;
}
#modal-admin .modal-box {
  width: 100%;
  height: 100%;
  border-radius: 0;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  flex-direction: row;
  max-width: none;
}
#modal-admin.open .modal-box { transform: translateY(0); }

.admin-sidebar {
  width: 220px;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}
.admin-sidebar-logo {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 0 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-nav-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: rgba(255,255,255,.8);
}
.admin-nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.admin-nav-item.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.admin-nav-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.admin-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-app);
}
.admin-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--modal-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.admin-panel { display: none; flex-direction: column; overflow: hidden; flex: 1; }
.admin-panel.active { display: flex; }
.admin-panel-body { flex: 1; overflow-y: auto; padding: 24px; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--modal-bg);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 8px var(--shadow);
}
.stat-label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }

/* Admin section cards */
.admin-section-card {
  background: var(--modal-bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 20px;
}
.admin-section-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Last logins grid */
.last-logins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.login-card {
  background: var(--bg-app);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.login-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.login-card-info { flex: 1; min-width: 0; }
.login-card-name { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.login-card-email { font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.login-card-date { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

/* Data table */
.data-table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th { background: var(--sidebar-bg); font-weight: 600; color: var(--text-secondary); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .7rem;
  font-weight: 600;
}
.badge-admin { background: #e3f2fd; color: #1565c0; }
.badge-user { background: #e8f5e9; color: #2e7d32; }
.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-inactive { background: #ffebee; color: #c62828; }

/* Logo upload */
.logo-upload-preview { margin-bottom: 16px; }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--modal-bg);
  color: var(--text-primary);
  box-shadow: 0 4px 12px var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }
.toast-icon { font-size: 1.1rem; }

/* ── Message Date Divider ────────────────────────────────────────── */
.msg-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  color: var(--text-muted);
  font-size: .7rem;
}
.msg-date-divider::before, .msg-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.msg-date-text {
  background: var(--bg-chat);
  padding: 2px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ── Spinner ─────────────────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilitários ─────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.w-full { width: 100%; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.hidden { display: none !important; }

/* ── Animações ───────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Responsivo ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .message-wrapper { max-width: 90%; }
  .modal-box { width: 95%; }
  .header-actions button span { display: none; }
  .hbtn { padding: 8px 12px; }
  .admin-sidebar { width: 60px; }
  .admin-sidebar-logo span:last-child, .admin-nav-item .nav-label { display: none; }
  .admin-nav-item { justify-content: center; padding: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }

  /* FIX MOBILE: garantir que input-bar fique sempre visível */
  #app {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
  }
  #chat-area {
    min-height: 0;
    overflow: hidden;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
  }
  #chat-view {
    min-height: 0;
    overflow: hidden;
    flex: 1 1 0;
  }
  #messages-container {
    min-height: 0;
    flex: 1 1 0;
  }
  #input-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: var(--sidebar-bg);
    flex-shrink: 0 !important;
  }
  /* Quando teclado abre, reduzir um pouco o input bar pra não espremer */
  #message-input-wrap {
    min-height: 40px;
  }
  #message-input {
    font-size: 16px; /* evita zoom do iOS ao focar */
  }
}

@media (max-width: 480px) {
  .login-card { padding: 24px 20px; margin: 16px; }
  .chat-header-actions button { padding: 4px 8px; font-size: .8rem; }
  .msg-avatar { width: 32px; height: 32px; font-size: .8rem; }
  .msg-bubble { padding: 8px 10px; font-size: .85rem; }
}

/* ── Voice Controls ──────────────────────────────────────────────── */
.voice-btn, .voice-config-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 20px;
  transition: all 0.2s;
  opacity: 0.6;
}
.message:hover .voice-btn { opacity: 1; }
.voice-btn:hover { background: var(--border); transform: scale(1.05); }

.voice-config-panel {
  background: var(--modal-bg);
  border-radius: 12px;
  padding: 15px;
  margin: 10px;
  box-shadow: 0 4px 15px var(--shadow);
  z-index: 1000;
  border: 1px solid var(--border);
}
.voice-config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.close-config {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  color: var(--text-muted);
}
.close-config:hover { color: var(--danger); }

/* ── Botões do Chat Header ───────────────────────────────────────── */
.chat-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chat-action-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  padding: 6px 12px;
  border-radius: 20px;
  color: var(--header-text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-action-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: translateY(-2px);
}

.chat-action-btn .action-icon {
  font-size: 0.9rem;
}

.chat-action-btn .action-text {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Botão específico de editar personagem */
.btn-edit-character {
  background: #ff9800 !important;
  color: #fff !important;
}

.btn-edit-character:hover {
  background: #f57c00 !important;
  transform: translateY(-2px);
}

/* Botão específico de grupo */
.btn-group-chat {
  background: #4caf50 !important;
  color: #fff !important;
}

.btn-group-chat:hover {
  background: #388e3c !important;
  transform: translateY(-2px);
}

/* Botão de apagar conversa */
#btn-clear-chat {
  background: rgba(244, 67, 54, 0.2) !important;
  color: #ff6b6b !important;
}

#btn-clear-chat:hover {
  background: rgba(244, 67, 54, 0.4) !important;
}
/* ── HEADER ACTIONS (BOTÕES DO TOPO) ─────────────────────────────── */
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hbtn {
  padding: 8px 16px;
  border-radius: 30px;
  background: rgba(255,255,255,0.15);
  color: var(--header-text);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
}

.hbtn:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-2px);
}

.hbtn .hbtn-icon {
  font-size: 1.1rem;
  display: inline-block;
}

.hbtn span:not(.hbtn-icon) {
  display: inline-block;
}

/* Cores dos botões */
.hbtn-contacts {
  background: #25D366 !important;
  color: #fff !important;
}

.hbtn-profile {
  background: #34B7F1 !important;
  color: #fff !important;
}

.hbtn-admin {
  background: #9c27b0 !important;
  color: #fff !important;
}

.hbtn-logout {
  background: #f44336 !important;
  color: #fff !important;
}

/* MOBILE - Ícones sempre visíveis */
@media (max-width: 768px) {
  .header-actions {
    gap: 6px;
  }
  
  .hbtn {
    padding: 8px 12px;
    border-radius: 30px;
    gap: 6px;
  }
  
  .hbtn .hbtn-icon {
    font-size: 1.1rem;
    display: inline-block !important;
  }
  
  .hbtn span:not(.hbtn-icon) {
    display: inline-block !important;
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .hbtn {
    padding: 8px 10px;
  }
  
  .hbtn .hbtn-icon {
    font-size: 1rem;
  }
  
  .hbtn span:not(.hbtn-icon) {
    font-size: 0.65rem;
  }
}

/* Hover */
.hbtn-contacts:hover { background: #1da852 !important; transform: translateY(-2px); }
.hbtn-profile:hover { background: #1e88e5 !important; transform: translateY(-2px); }
.hbtn-admin:hover { background: #7b1fa2 !important; transform: translateY(-2px); }
.hbtn-logout:hover { background: #d32f2f !important; transform: translateY(-2px); }
/* ── CHAT HEADER CLICÁVEL ────────────────────────────────────────── */
.chat-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.chat-header-avatar:hover {
  transform: scale(1.05);
  border-color: rgba(255,255,255,0.5);
}

.chat-header-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  transition: all 0.2s;
  padding: 4px 8px;
  border-radius: 12px;
}

.chat-header-info:hover {
  background: rgba(255,255,255,0.1);
}

.chat-header-name {
  font-size: 1rem;
  font-weight: 600;
}

.chat-header-status {
  font-size: .78rem;
  opacity: .75;
}

/* Grupo header clicável */
.group-header-avatars {
  display: flex;
  cursor: pointer;
  transition: all 0.2s;
  padding: 4px;
  border-radius: 30px;
}

.group-header-avatars:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.02);
}
/* Indicador de que o nome do grupo é clicável */
.chat-header-name[style*="cursor: pointer"] {
  border-bottom: 1px dotted rgba(255,255,255,0.5);
  transition: all 0.2s;
}

.chat-header-name[style*="cursor: pointer"]:hover {
  border-bottom-color: rgba(255,255,255,0.9);
  transform: translateY(-1px);
}

.chat-header-status[style*="cursor: pointer"]:hover {
  border-bottom-color: rgba(255,255,255,0.9);
}

/* Tooltip para indicar que pode clicar */
.chat-header-name::after {
  content: '✏️';
  font-size: 0.7rem;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.chat-header-name:hover::after {
  opacity: 0.7;
}
/* ── MODAL DE CONFIRMAÇÃO MODERNO ────────────────────────────────── */
#confirm-modal .modal-box,
#alert-modal .modal-box {
  animation: modalPop 0.3s ease;
  border-radius: 24px;
}

@keyframes modalPop {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

#confirm-modal .modal-body,
#alert-modal .modal-body {
  background: var(--modal-bg);
  border-radius: 24px;
}

#confirm-icon,
#alert-icon {
  animation: iconBounce 0.4s ease;
}

@keyframes iconBounce {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Toast melhorado */
.toast {
  padding: 14px 20px;
  border-radius: 16px;
  background: var(--modal-bg);
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid;
  min-width: 280px;
  max-width: 380px;
  backdrop-filter: blur(10px);
}

.toast-success {
  border-left-color: #4caf50;
  background: linear-gradient(135deg, var(--modal-bg), rgba(76, 175, 80, 0.1));
}

.toast-error {
  border-left-color: #f44336;
  background: linear-gradient(135deg, var(--modal-bg), rgba(244, 67, 54, 0.1));
}

.toast-warning {
  border-left-color: #ff9800;
  background: linear-gradient(135deg, var(--modal-bg), rgba(255, 152, 0, 0.1));
}

.toast-info {
  border-left-color: #2196f3;
  background: linear-gradient(135deg, var(--modal-bg), rgba(33, 150, 243, 0.1));
}

.toast-icon {
  font-size: 1.4rem;
}

.toast-message {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
}

.toast-close {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  font-size: 1.1rem;
}

.toast-close:hover {
  opacity: 1;
}

/* ── Generated Images ────────────────────────────────────────────── */
.msg-generated-image {
  margin: 4px 0;
  text-align: center;
}

.msg-generated-image img {
  max-width: 320px;
  max-height: 320px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}

.msg-generated-image img:hover {
  transform: scale(1.02);
}

.msg-image-caption {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 4px;
}

.image-generating-bubble {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}