* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root {
  --bg-main: #eae6df;
  --sidebar-bg: #ffffff;
  --primary: #10a37f;
  --primary-hover: #0e8a6c;
  --border: #e2e8f0;
  --text-main: #111b21;
  --text-muted: #667781;
  --client-bubble: #ffffff;
  --bot-bubble: #d9fdd3;
  --human-bubble: #cbf3bb;
  --note-bubble: #fef08a;
}

body {
  background-color: #111b21;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* TELA DE LOGIN */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #111b21 0%, #1e293b 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 420px;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-brand-icons {
  font-size: 32px;
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.login-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
}

.login-header p {
  font-size: 13px;
  color: #64748b;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.alert-error {
  background: #fee2e2;
  border: 1px solid #f87171;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.btn-login {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.2s;
}

.btn-login:hover {
  background: var(--primary-hover);
}

.login-footer {
  margin-top: 18px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
}

/* APP PRINCIPAL */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-main);
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 380px;
  min-width: 320px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-header {
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.brand-icon {
  font-size: 24px;
}

.brand-text h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.header-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
}

.status-indicator.online .status-dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.btn-qr-view {
  background: #e2e8f0;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  color: #334155;
}

.btn-qr-view:hover {
  background: #cbd5e1;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
}

.user-role {
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 600;
}

.header-btns {
  display: flex;
  gap: 4px;
}

.btn-icon {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.btn-icon:hover {
  background: #e2e8f0;
}

/* BARRA DE TROCA DE EMPRESA (ADMIN) */
.company-switch-bar {
  padding: 8px 14px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.company-switch-bar select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  font-size: 12px;
  font-weight: 600;
}

/* CONTROLES DA SIDEBAR */
.sidebar-controls {
  display: flex;
  padding: 8px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.search-box {
  flex: 1;
}

.search-box input {
  width: 100%;
  padding: 7px 10px;
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12.5px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
  background: #ffffff;
}

.btn-new-chat {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-new-chat:hover {
  background: var(--primary-hover);
}

/* ABAS DE FILTRO */
.filter-tabs {
  display: flex;
  padding: 6px 10px;
  gap: 4px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  padding: 6px 4px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.tab-btn:hover {
  background: #e2e8f0;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.badge-count {
  background: #e2e8f0;
  color: #475569;
  padding: 1px 5px;
  border-radius: 10px;
  font-size: 10px;
}

.tab-btn.active .badge-count {
  background: var(--primary);
  color: #ffffff;
}

/* LISTA DE CONVERSAS */
.chat-list {
  flex: 1;
  overflow-y: auto;
}

.loading-state,
.no-chats {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.chat-item {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-item:hover {
  background: #f8fafc;
}

.chat-item.active {
  background: #f1f5f9;
}

.chat-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

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

.chat-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.chat-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.chat-item-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.chat-item-msg {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-item-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.badge-bot {
  background: #e0f2fe;
  color: #0284c7;
}

.badge-pending {
  background: #fef3c7;
  color: #d97706;
}

.badge-human {
  background: #dcfce7;
  color: #15803d;
}

.badge-resolved {
  background: #f1f5f9;
  color: #64748b;
}

/* ÁREA PRINCIPAL DO CHAT */
.chat-area {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 50px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13.5px;
  max-width: 380px;
}

/* CONVERSA ATIVA */
.active-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.contact-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-name-row h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
}

.header-status-badge {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.contact-sub-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-phone {
  font-size: 11.5px;
  color: var(--text-muted);
}

.contact-assigned-tag {
  font-size: 10.5px;
  background: #ede9fe;
  color: #6d28d9;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-status-buttons {
  display: flex;
  gap: 6px;
}

.btn-action {
  border: none;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-action:hover {
  opacity: 0.85;
}

.btn-assign {
  background: #8b5cf6;
  color: white;
}

.btn-transfer {
  background: #3b82f6;
  color: white;
}

.btn-bot {
  background: #0284c7;
  color: white;
}

.btn-concluir {
  background: #10b981;
  color: white;
}

.btn-shortcuts-toggle {
  background: #f59e0b;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

/* MENSAGENS COMPACTAS */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-image: radial-gradient(#d1d5db 0.75px, transparent 0.75px);
  background-size: 16px 16px;
  background-color: var(--bg-main);
}

.message-bubble {
  max-width: 65%;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.35;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.message-bubble.client {
  align-self: flex-start;
  background: var(--client-bubble);
  border-top-left-radius: 2px;
}

.message-bubble.bot {
  align-self: flex-end;
  background: var(--bot-bubble);
  border-top-right-radius: 2px;
}

.message-bubble.human {
  align-self: flex-end;
  background: var(--human-bubble);
  border-top-right-radius: 2px;
}

.message-bubble.system_note {
  align-self: center;
  max-width: 85%;
  background: var(--note-bubble);
  border: 1px solid #facc15;
  font-size: 12px;
  border-radius: 6px;
  color: #854d0e;
  margin: 6px 0;
}

.bubble-author {
  font-size: 11px;
  font-weight: 700;
  color: #0369a1;
  margin-bottom: 2px;
}

.bubble-time {
  font-size: 10px;
  color: #64748b;
  float: right;
  margin-left: 8px;
  margin-top: 4px;
}

/* RODAPÉ DO CHAT */
.chat-footer {
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-footer textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: none;
  font-size: 13.5px;
  outline: none;
  height: 38px;
}

.chat-footer textarea:focus {
  border-color: var(--primary);
}

.btn-send {
  background: var(--primary);
  color: white;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-send:hover {
  background: var(--primary-hover);
}

/* MODAIS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 10px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-content.modal-small {
  max-width: 420px;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  color: var(--text-main);
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-hint {
  font-size: 12.5px;
  color: #64748b;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-cancel {
  background: #f1f5f9;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* TABELA DE ATENDENTES */
.new-agent-box {
  background: #f8fafc;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.new-agent-box h4 {
  font-size: 13.5px;
  margin-bottom: 10px;
  color: #1e293b;
}

.new-agent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-btn-row {
  grid-column: span 2;
  display: flex;
  justify-content: flex-end;
}

.agents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.agents-table th,
.agents-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.agents-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
}

.btn-del-agent {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* QR CODE BOX */
.qr-box {
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 220px;
}

.qr-box canvas {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ATALHOS */
.modal-search {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.shortcuts-list {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.shortcut-card {
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shortcut-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shortcut-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.shortcut-preview {
  font-size: 12px;
  color: #475569;
  background: #ffffff;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  white-space: pre-wrap;
}

.btn-use-shortcut {
  background: var(--primary);
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------- */
/* FILTRO E IDENTIFICACAO DE CANAL (WHATSAPP / INSTAGRAM / FACEBOOK) */
/* ------------------------------------------------------------- */
.channel-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
}

.channel-btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  color: #4b5563;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.channel-btn:hover {
  background: #f3f4f6;
}

.channel-btn.active {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.chat-item-channel {
  margin-right: 5px;
  font-size: 11px;
  vertical-align: middle;
}

/* Situacao da integracao com a Meta */
.meta-status-area {
  margin-top: 10px;
}

.meta-ok,
.meta-off {
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.meta-ok {
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.meta-off {
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.meta-steps {
  margin: 8px 0 10px 18px;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #374151;
}

.meta-steps li {
  margin-bottom: 6px;
}

.meta-steps code,
.modal-hint code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}
