/* assets/css/painel.css */
/* Tema claro/escuro com variáveis CSS */

:root {
  --bg-primary:      #ffffff;
  --bg-secondary:    #f0f2f5;
  --bg-tertiary:     #e9edef;
  --bg-chat:         #efeae2;
  --bg-message-out:  #d9fdd3;
  --bg-message-in:   #ffffff;
  --bg-input:        #ffffff;
  --bg-sidebar:      #ffffff;
  --bg-header:       #f0f2f5;
  --bg-hover:        #f5f6f6;
  --bg-active:       #e9edef;
  --text-primary:    #111b21;
  --text-secondary:  #667781;
  --text-muted:      #8696a0;
  --border-color:    #d1d7db;
  --accent:          #00a884;
  --accent-hover:    #017561;
  --accent-light:    #d9fdd3;
  --danger:          #ea4335;
  --warning:         #f59e0b;
  --shadow:          0 1px 3px rgba(0,0,0,.12);
  --radius:          8px;
  --font:            'Segoe UI', system-ui, sans-serif;
}

[data-tema="escuro"] {
  --bg-primary:      #111b21;
  --bg-secondary:    #202c33;
  --bg-tertiary:     #2a3942;
  --bg-chat:         #0b141a;
  --bg-message-out:  #005c4b;
  --bg-message-in:   #202c33;
  --bg-input:        #2a3942;
  --bg-sidebar:      #111b21;
  --bg-header:       #202c33;
  --bg-hover:        #2a3942;
  --bg-active:       #2a3942;
  --text-primary:    #e9edef;
  --text-secondary:  #aebac1;
  --text-muted:      #8696a0;
  --border-color:    #2a3942;
  --accent:          #00a884;
  --accent-hover:    #06cf9c;
  --accent-light:    #005c4b;
  --danger:          #f28b82;
  --warning:         #fbbf24;
  --shadow:          0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg-secondary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* ── LOGIN ── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}

.login-card {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img { height: 48px; }

.login-logo h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 12px;
}

.login-logo p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

.form-group input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}

.btn-primary  { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover  { background: var(--accent-hover); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.erro-msg {
  background: #fde8e8;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

[data-tema="escuro"] .erro-msg { background: #3b1212; }

/* ── LAYOUT PRINCIPAL ── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 360px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-header);
  height: 60px;
}

.agente-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.agente-nome { font-size: 15px; font-weight: 600; }
.agente-depto { font-size: 12px; color: var(--text-secondary); }

.sidebar-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background .15s;
}

.icon-btn:hover { background: var(--bg-hover); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.status-online  { background: #dcfce7; color: #15803d; }
.status-ausente { background: #fef9c3; color: #a16207; }
.status-offline { background: var(--bg-tertiary); color: var(--text-muted); }

[data-tema="escuro"] .status-online  { background: #14532d; color: #86efac; }
[data-tema="escuro"] .status-ausente { background: #451a03; color: #fcd34d; }

.sidebar-search {
  padding: 8px 12px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-search input {
  width: 100%;
  padding: 8px 14px;
  border-radius: 20px;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.chat-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}

.tab.ativo {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background .15s;
  position: relative;
}

.chat-item:hover { background: var(--bg-hover); }
.chat-item.ativo  { background: var(--bg-active); }

.chat-item-info { flex: 1; min-width: 0; }

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.chat-item-nome {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-hora {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-item-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-aguardando {
  background: var(--warning);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
}

/* ── ÁREA DE CONVERSA ── */
.conversa {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  overflow: hidden;
}

.conversa-vazia {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
}

.conversa-vazia svg { opacity: .3; }
.conversa-vazia p { font-size: 14px; }

.conversa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  height: 60px;
}

.conversa-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conversa-header-nome { font-size: 15px; font-weight: 600; }
.conversa-header-sub  { font-size: 12px; color: var(--text-secondary); }
.conversa-header-acoes { display: flex; gap: 4px; }

.mensagens-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-wrapper {
  display: flex;
  margin-bottom: 2px;
}

.msg-wrapper.saida  { justify-content: flex-end; }
.msg-wrapper.entrada { justify-content: flex-start; }
.msg-wrapper.bot    { justify-content: center; }

.msg-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

.msg-wrapper.saida  .msg-bubble { background: var(--bg-message-out); border-radius: 8px 0 8px 8px; }
.msg-wrapper.entrada .msg-bubble { background: var(--bg-message-in); border-radius: 0 8px 8px 8px; }
.msg-wrapper.bot    .msg-bubble {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  border-radius: 8px;
  max-width: 80%;
  text-align: center;
}

.msg-hora {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

.msg-audio {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-audio audio { max-width: 220px; }

.msg-imagem img {
  max-width: 280px;
  border-radius: 6px;
  cursor: pointer;
}

.msg-documento {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}

/* ── INPUT DE MENSAGEM ── */
.input-area {
  padding: 10px 16px;
  background: var(--bg-header);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-area textarea {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: none;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
}

.btn-enviar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: background .2s;
}

.btn-enviar:hover { background: var(--accent-hover); }

.assinatura-preview {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 16px 0;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  display: none;
}

.modal-overlay.aberto { display: flex; }

.modal {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.modal h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-acoes {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ── BOTÃO TEMA ── */
.tema-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow);
  z-index: 50;
  transition: background .2s;
}

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

/* ── RESPONSIVO ── */
@media (max-width: 768px) {
  .sidebar { width: 100%; }
  .conversa { display: none; }
  .conversa.ativo { display: flex; width: 100%; }
  .sidebar.oculto { display: none; }
}
