* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #1f2d3d;
  background: #f4f6f8;
}

#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1f2d3d;
  color: #fff;
  padding: 10px 16px;
  flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 16px; }
.brand span { font-weight: 400; opacity: 0.75; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.biz-status { font-size: 12px; padding: 4px 8px; border-radius: 10px; background: #334; }
.biz-status.open { background: #1f9254; }
.biz-status.closed { background: #a8390f; }
.nav-btn {
  background: transparent;
  color: #cfd8e3;
  border: 1px solid #3c4a5c;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.nav-btn.active { background: #0b5fff; color: #fff; border-color: #0b5fff; }
.nav-btn.demo { border-color: #c77d00; color: #ffd48a; }
.nav-btn.notify-on { border-color: #1f9254; color: #8be3b0; }
.nav-btn.sound-off { opacity: 0.5; }

.layout { flex: 1; display: flex; overflow: hidden; }
.hidden { display: none !important; }

.sidebar {
  width: 280px;
  background: #fff;
  border-right: 1px solid #e3e8ee;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.filters, .status-filters {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid #eef1f4;
}
.filter-btn, .status-btn {
  flex: 1;
  background: #f0f2f5;
  border: none;
  padding: 7px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.filter-btn.active, .status-btn.active { background: #0b5fff; color: #fff; }

.label-filters { padding: 10px; border-bottom: 1px solid #eef1f4; }
.label-filters-title { font-size: 11px; text-transform: uppercase; color: #8a97a8; margin-bottom: 6px; }
.label-chip {
  display: inline-block;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 10px;
  margin: 2px 3px 2px 0;
  cursor: pointer;
  border: 1px solid transparent;
  color: #fff;
}
.label-chip.inactive { opacity: 0.45; }
.label-chip.active-filter { box-shadow: 0 0 0 2px #0b5fff inset; }

.conversation-list { flex: 1; overflow-y: auto; }
.conversation-item {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
}
.conversation-item:hover { background: #f7f9fb; }
.conversation-item.selected { background: #e8f0ff; }
.conv-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; }
.conv-top-left { display: flex; align-items: center; gap: 6px; }
.unread-badge { background: #e23; color: #fff; font-size: 10px; font-weight: 700; border-radius: 10px; padding: 1px 6px; min-width: 16px; text-align: center; }
.conv-snippet { font-size: 12px; color: #65758a; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }
.mini-label { font-size: 10px; padding: 1px 6px; border-radius: 8px; color: #fff; }
.mini-assignee { font-size: 10px; color: #0b5fff; margin-top: 4px; }
.example-tag { color: #a8390f; font-weight: 700; }

.thread-panel { flex: 1; display: flex; flex-direction: column; background: #fff; border-right: 1px solid #e3e8ee; min-width: 0; }
.thread-header { padding: 12px 16px; border-bottom: 1px solid #eef1f4; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.thread-header .status-toggle { font-size: 12px; padding: 5px 10px; border-radius: 6px; border: 1px solid #ccd4dd; background: #fff; cursor: pointer; }

.thread-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 65%; padding: 8px 12px; border-radius: 10px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; }
.msg.contact { align-self: flex-start; background: #eef1f4; }
.msg.agent, .msg.bot { align-self: flex-end; background: #0b5fff; color: #fff; }
.msg.bot { background: #4b3fb0; }
.msg.note { align-self: flex-end; background: #fff4d6; color: #6b5300; border: 1px dashed #e0c06a; }
.msg-meta { font-size: 10px; opacity: 0.7; margin-top: 4px; }
.msg.flagged { border: 2px solid #e23; }

.composer { border-top: 1px solid #eef1f4; padding: 10px 16px; }
.composer-tabs { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.composer-tab { background: #f0f2f5; border: none; padding: 6px 12px; border-radius: 6px 6px 0 0; cursor: pointer; font-size: 12px; }
.composer-tab.active { background: #0b5fff; color: #fff; }
.composer-tab[data-mode="note"].active { background: #e0c06a; color: #6b5300; }
.suggest-btn { margin-left: auto; background: #4b3fb0; color: #fff; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.composer-input-wrap { position: relative; }
#composerText { width: 100%; min-height: 70px; resize: vertical; padding: 8px; border: 1px solid #ccd4dd; border-radius: 6px; font-size: 14px; font-family: inherit; }
.canned-popup {
  position: absolute; bottom: 100%; left: 0; width: 100%; max-height: 220px; overflow-y: auto;
  background: #fff; border: 1px solid #ccd4dd; border-radius: 6px; box-shadow: 0 -4px 10px rgba(0,0,0,0.08); z-index: 10;
}
.canned-item { padding: 8px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f0f2f5; }
.canned-item:hover, .canned-item.highlighted { background: #e8f0ff; }
.canned-item code { color: #0b5fff; }
.canned-item .canned-preview { color: #65758a; font-size: 11px; display: block; margin-top: 2px; }
.composer-actions { text-align: right; margin-top: 8px; }
#sendBtn { background: #0b5fff; color: #fff; border: none; padding: 8px 20px; border-radius: 6px; cursor: pointer; }

.right-panel { width: 300px; background: #fff; overflow-y: auto; flex-shrink: 0; padding: 16px; }
.right-section { margin-bottom: 20px; }
.right-section h4 { font-size: 12px; text-transform: uppercase; color: #8a97a8; margin: 0 0 8px; }
.contact-name { font-size: 16px; font-weight: 700; }
.contact-field { font-size: 13px; color: #45505f; margin-top: 4px; }
.labels-list { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.label-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #fff; padding: 3px 8px; border-radius: 10px; }
.label-pill button { background: none; border: none; color: #fff; cursor: pointer; font-weight: 700; }
.add-label-row select { width: 100%; padding: 5px; }
.assignee-row select { width: 100%; padding: 6px; }
.notes-list { font-size: 12px; }
.note-item { background: #fff4d6; border: 1px dashed #e0c06a; padding: 6px 8px; border-radius: 6px; margin-bottom: 6px; }

.empty-state { padding: 40px; text-align: center; color: #8a97a8; }

.settings-view { background: #fff; overflow-y: auto; display: block; }
.settings-content { max-width: 800px; margin: 0 auto; padding: 24px; }
.settings-section { margin-bottom: 28px; }
.settings-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.settings-table th, .settings-table td { border: 1px solid #e3e8ee; padding: 6px 8px; text-align: left; }
.settings-table input[type="number"] { width: 50px; }
.settings-table input[type="checkbox"] { transform: scale(1.2); }
#oooMessage { width: 100%; margin-top: 8px; padding: 8px; font-family: inherit; }
#saveOooBtn, .save-row-btn { background: #0b5fff; color: #fff; border: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; margin-top: 8px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; }
.modal-box { background: #fff; padding: 20px; border-radius: 8px; width: 400px; display: flex; flex-direction: column; gap: 10px; }
.modal-box label { display: flex; flex-direction: column; font-size: 13px; gap: 4px; }
.modal-box input, .modal-box textarea { padding: 7px; border: 1px solid #ccd4dd; border-radius: 6px; font-family: inherit; }
.modal-hint { font-size: 12px; color: #8a97a8; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button { padding: 7px 14px; border-radius: 6px; border: none; cursor: pointer; }
#demoSendBtn { background: #0b5fff; color: #fff; }

/* ---------- Login / acesso negado ---------- */
.auth-body { background: #f4f6f8; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: #fff; border-radius: 10px; padding: 32px; width: 380px; box-shadow: 0 2px 16px rgba(0,0,0,0.08); text-align: center; }
.auth-card .brand { font-weight: 700; font-size: 20px; color: #1f2d3d; margin-bottom: 20px; }
.auth-card .brand span { font-weight: 400; opacity: 0.6; }
.auth-card h2 { margin-top: 0; }
.auth-card p { font-size: 13px; color: #45505f; text-align: left; }
.auth-error { background: #fdeceb; color: #a8390f; border: 1px solid #f3c6bd; padding: 10px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; text-align: left; }
.google-btn {
  display: inline-block; background: #0b5fff; color: #fff; text-decoration: none;
  padding: 10px 20px; border-radius: 6px; font-size: 14px; font-weight: 600; margin-top: 8px;
}
.dev-banner {
  background: #c0392b; color: #fff; font-weight: 700; font-size: 12px;
  padding: 10px; border-radius: 6px; margin-bottom: 16px;
}
.dev-agent-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.dev-agent-form button {
  width: 100%; padding: 9px; border-radius: 6px; border: 1px solid #ccd4dd; background: #f0f2f5; cursor: pointer; font-size: 14px;
}
.dev-agent-form button:hover { background: #e3e8ee; }

/* ---------- WhatsApp (admin) / banner de alerta ---------- */
.wa-banner {
  background: #c0392b;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  text-align: center;
  flex-shrink: 0;
}
.wa-status-box { margin: 12px 0; }
.wa-status { display: inline-block; padding: 6px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; color: #fff; background: #777; }
.wa-status-conectado { background: #1f9254; }
.wa-status-aguardando_qr { background: #c77d00; }
.wa-status-conectando { background: #0b5fff; }
.wa-status-desconectado { background: #a8390f; }
.wa-qr-box { margin: 16px 0; }
.wa-qr-img { width: 260px; height: 260px; border: 1px solid #e3e8ee; border-radius: 8px; padding: 10px; background: #fff; }
#waLogoutBtn { background: #a8390f; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.msg-tick { margin-left: 6px; }
.msg-media { margin-top: 6px; font-size: 12px; }
.msg-media a { color: inherit; text-decoration: underline; }

/* ---------- Topbar usuário / Agentes admin ---------- */
.user-info { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.user-info .user-name { font-weight: 600; }
.user-info .user-role { font-size: 11px; opacity: 0.7; }
#logoutBtn { background: transparent; color: #cfd8e3; border: 1px solid #3c4a5c; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.agents-table input[type="text"], .agents-table select { width: 100%; padding: 5px; }
.agents-table td, .agents-table th { vertical-align: middle; }
.agent-inactive { opacity: 0.5; }
#newAgentBtn { background: #0b5fff; color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; margin-bottom: 12px; }
