/**
 * public/css/whatsapp_atendimento.css
 * 
 * Estilização Modular Isolada: Módulo WhatsApp Atendimento
 * Escopo 100% isolado no container #tab-config-whatsapp e prefixo .wa-*
 * Compatível com o tema escuro do portal GSI.
 */

/* Container Principal do Módulo de Atendimento */
#tab-config-whatsapp .wa-card-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 190px);
  min-height: 620px;
  max-height: 860px;
  padding: 0;
  overflow: hidden;
  background-color: var(--panel-bg, #1e293b);
  border: 1px solid var(--panel-border, #334155);
  border-radius: 14px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.45);
}

/* Barra Superior / Header do Atendimento */
.wa-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--panel-border, #334155);
  flex-shrink: 0;
  gap: 16px;
  flex-wrap: wrap;
}

.wa-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-header-title h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main, #f8fafc);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wa-connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--panel-border, #334155);
  color: var(--text-muted, #94a3b8);
  font-weight: 500;
}

.wa-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #94a3b8;
  display: inline-block;
}

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

.wa-status-dot.connecting {
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.wa-status-dot.offline {
  background-color: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.wa-header-operator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wa-header-operator label {
  font-size: 0.82rem;
  color: var(--text-muted, #94a3b8);
  font-weight: 600;
}

.wa-operator-select {
  background: #0f172a;
  color: var(--text-main, #f8fafc);
  border: 1px solid var(--panel-border, #334155);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.wa-operator-select:focus {
  border-color: var(--accent-blue, #38bdf8);
}

/* Layout em 2 Colunas (Sidebar + Chat) */
.wa-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Coluna 1: Sidebar de Conversas */
.wa-sidebar {
  width: 350px;
  min-width: 300px;
  max-width: 400px;
  background: rgba(15, 23, 42, 0.35);
  border-right: 1px solid var(--panel-border, #334155);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.wa-search-box {
  padding: 12px;
  border-bottom: 1px solid var(--panel-border, #334155);
  background: rgba(15, 23, 42, 0.2);
}

.wa-search-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--panel-border, #334155);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-main, #f8fafc);
  outline: none;
  transition: border-color 0.2s;
}

.wa-search-input:focus {
  border-color: var(--accent-blue, #38bdf8);
}

.wa-filter-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid var(--panel-border, #334155);
  overflow-x: auto;
}

.wa-filter-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted, #94a3b8);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.wa-filter-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main, #f8fafc);
}

.wa-filter-tab.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--accent-blue, #38bdf8);
}

.wa-pill-counter {
  background: #f59e0b;
  color: #000;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  line-height: 1.2;
}

.wa-pill-counter.zero {
  display: none;
}

/* Lista de Conversas */
.wa-conversation-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.wa-conversation-list::-webkit-scrollbar {
  width: 6px;
}
.wa-conversation-list::-webkit-scrollbar-thumb {
  background: rgba(51, 65, 85, 0.6);
  border-radius: 4px;
}

.wa-conv-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.wa-conv-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.wa-conv-item.active {
  background: rgba(56, 189, 248, 0.08);
  border-left: 3px solid var(--accent-blue, #38bdf8);
}

.wa-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(51, 65, 85, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-main, #f8fafc);
  flex-shrink: 0;
}

.wa-conv-info {
  flex: 1;
  min-width: 0;
}

.wa-conv-top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
}

.wa-conv-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main, #f8fafc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-conv-time {
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
  white-space: nowrap;
  flex-shrink: 0;
}

.wa-conv-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.wa-conv-snippet {
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.wa-conv-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Badges de Status das Conversas */
.wa-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.wa-badge-bot {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.wa-badge-waiting {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  animation: wa-pulse 1.8s infinite;
}

@keyframes wa-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.wa-badge-progress {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.wa-badge-closed {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.wa-badge-operator {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
}

/* Coluna 2: Painel Central de Chat */
.wa-chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0b1120;
  overflow: hidden;
  position: relative;
}

/* Estado Vazio (Sem Conversa) */
.wa-empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  color: var(--text-muted, #94a3b8);
}

.wa-empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.wa-empty-chat h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main, #f8fafc);
  margin-bottom: 6px;
}

.wa-empty-chat p {
  font-size: 0.85rem;
  max-width: 320px;
  line-height: 1.5;
}

/* Conversa Ativa */
.wa-active-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

/* Header da Conversa Ativa */
.wa-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(30, 41, 59, 0.6);
  border-bottom: 1px solid var(--panel-border, #334155);
  flex-shrink: 0;
  gap: 12px;
}

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

.wa-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #1e293b;
  border: 1px solid var(--panel-border, #334155);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

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

.wa-contact-name-row h3 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main, #f8fafc);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-contact-phone {
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  font-family: var(--font-mono, monospace);
}

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

.wa-btn-danger {
  border-color: rgba(244, 63, 94, 0.4) !important;
  color: #f43f5e !important;
}

.wa-btn-danger:hover {
  background: rgba(244, 63, 94, 0.15) !important;
}

/* Área de Mensagens */
.wa-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.25) 0%, rgba(15, 23, 42, 0.6) 100%);
}

.wa-messages-container::-webkit-scrollbar {
  width: 6px;
}
.wa-messages-container::-webkit-scrollbar-thumb {
  background: rgba(51, 65, 85, 0.6);
  border-radius: 4px;
}

/* Balões de Mensagem */
.wa-msg {
  display: flex;
  flex-direction: column;
  max-width: 68%;
  padding: 10px 14px;
  position: relative;
  word-break: break-word;
  animation: wa-slide-up 0.15s ease-out;
}

@keyframes wa-slide-up {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mensagem do Cliente */
.wa-msg-client {
  align-self: flex-start;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid var(--panel-border, #334155);
  border-radius: 14px 14px 14px 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Mensagem do Operador */
.wa-msg-operator {
  align-self: flex-end;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border-radius: 14px 14px 2px 14px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

/* Mensagem do Bot IA */
.wa-msg-bot {
  align-self: flex-end;
  background: #1e1b4b;
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #e0e7ff;
  border-radius: 14px 14px 2px 14px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.wa-msg-sender {
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.wa-msg-client .wa-msg-sender {
  color: var(--accent-blue, #38bdf8);
}

.wa-msg-operator .wa-msg-sender {
  color: rgba(255, 255, 255, 0.9);
}

.wa-msg-bot .wa-msg-sender {
  color: #a78bfa;
}

.wa-msg-text {
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.wa-msg-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.68rem;
  opacity: 0.8;
}

.wa-msg-time {
  font-family: var(--font-mono, monospace);
}

/* Mensagem do Sistema */
.wa-msg-system {
  align-self: center;
  background: rgba(51, 65, 85, 0.4);
  border: 1px solid rgba(51, 65, 85, 0.6);
  color: var(--text-muted, #94a3b8);
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 9999px;
  text-align: center;
  margin: 6px 0;
}

/* Banner de Aviso de Atendimento */
.wa-chat-banner {
  padding: 8px 16px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--panel-border, #334155);
}

.wa-chat-banner.banner-closed {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted, #94a3b8);
}

.wa-chat-banner.banner-bot {
  background: rgba(139, 92, 246, 0.12);
  color: #c4b5fd;
}

.wa-chat-banner.banner-waiting {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

/* Área de Input e Envio */
.wa-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.8);
  border-top: 1px solid var(--panel-border, #334155);
  flex-shrink: 0;
}

.wa-message-textarea {
  flex: 1;
  background: #0f172a;
  border: 1px solid var(--panel-border, #334155);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--text-main, #f8fafc);
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.wa-message-textarea:focus {
  border-color: var(--accent-blue, #38bdf8);
}

.wa-btn-send {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  height: 44px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* Responsividade Mobile/Tablet */
@media (max-width: 768px) {
  .wa-layout {
    flex-direction: column;
  }
  .wa-sidebar {
    width: 100%;
    max-width: none;
    height: 45%;
    border-right: none;
    border-bottom: 1px solid var(--panel-border, #334155);
  }
  .wa-chat-panel {
    height: 55%;
  }
}

/* ============================================================================
   ANEXOS: arrastar e soltar, colar (Ctrl+V) e clipe
   ============================================================================ */
.wa-active-chat {
  position: relative;
}

.wa-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.15);
  border: 2px dashed var(--accent-blue, #38bdf8);
  border-radius: 8px;
  pointer-events: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main, #f8fafc);
}

.wa-drop-overlay.hidden,
.wa-attach-preview.hidden {
  display: none !important;
}

.wa-attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.8);
  border-top: 1px solid var(--panel-border, #334155);
  font-size: 0.82rem;
  color: var(--text-main, #f8fafc);
}

.wa-attach-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 6px 10px;
  background: #0f172a;
  border: 1px solid var(--panel-border, #334155);
  border-radius: 8px;
}

.wa-attach-chip img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
}

.wa-attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-attach-size {
  color: var(--text-muted, #94a3b8);
  white-space: nowrap;
}

.wa-attach-remove {
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
}

.wa-attach-remove:hover {
  color: #f43f5e;
}

.wa-btn-attach {
  height: 44px;
  width: 44px;
  padding: 0;
  font-size: 1.1rem;
  flex-shrink: 0;
  align-self: flex-end;
}

.wa-media-img {
  display: block;
  max-width: 260px;
  max-height: 260px;
  border-radius: 8px;
  margin-bottom: 6px;
}

.wa-media-doc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  max-width: 280px;
}

a.wa-media-doc:hover {
  background: rgba(0, 0, 0, 0.35);
}

.wa-media-doc-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.wa-media-doc-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wa-media-doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.wa-media-doc-sub {
  font-size: 0.72rem;
  opacity: 0.75;
}

.wa-media-download {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent-blue, #38bdf8);
  margin-bottom: 4px;
}

.wa-media-player {
  display: block;
  max-width: 260px;
  margin-bottom: 6px;
}
