/* ==========================================================================
   WhatsApp Coexistence Cloud Panel - Estilos Globais & Design System
   ========================================================================== */

:root {
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Paleta de Cores Premium */
  --bg-gradient: radial-gradient(circle at top left, #0e121a, #07090d);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  
  --primary-green: #25D366;       /* Verde WhatsApp clássico */
  --secondary-teal: #128C7E;     /* Teal escuro para realces */
  --accent-neon: #00ff7f;        /* Verde Neon para status de atividade */
  --active-blue: #3b82f6;        /* Azul elétrico para badges */
  --danger-red: #ef4444;         /* Vermelho para expiração da janela */
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --bubble-client: rgba(255, 255, 255, 0.07);
  --bubble-api: rgba(37, 211, 102, 0.15);
  --bubble-cell: rgba(18, 140, 126, 0.25);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Background dinâmico */
.glass-bg {
  position: absolute;
  top: 10%;
  left: 20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(37, 211, 102, 0.08) 0%, rgba(18, 140, 126, 0.02) 70%, transparent 100%);
  filter: blur(80px);
  z-index: 0;
  pointer-events: none;
}

/* Container Principal */
.app-container {
  width: 95vw;
  max-width: 1400px;
  height: 90vh;
  max-height: 900px;
  background: rgba(10, 14, 23, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  z-index: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.app-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 22, 36, 0.4);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-green), var(--secondary-teal));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 15px rgba(37, 211, 102, 0.4);
}

.logo-icon svg {
  width: 24px;
  height: 24px;
}

.logo-area h1 {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(120deg, #fff, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-area .subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 2px;
}

/* Status do Servidor */
.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(37, 211, 102, 0.06);
  border: 1px solid rgba(37, 211, 102, 0.2);
  border-radius: 50px;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  background-color: var(--accent-neon);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-neon);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(0, 255, 127, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(0, 255, 127, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(0, 255, 127, 0); }
}

.status-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-neon);
}

/* Layout do Painel */
.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100% - 85px);
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--glass-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(10, 15, 26, 0.2);
  overflow-y: auto;
}

.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: var(--transition-smooth);
}

.onboarding-card {
  border-left: 4px solid var(--primary-green);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-header h3 {
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.2px;
}

.card-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-green), var(--secondary-teal));
  color: #0b0f19;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: #fff;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger-red);
}

.btn-danger:hover {
  background: var(--danger-red);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
}

/* Modal CoEx Onboarding */
.coex-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 5, 8, 0.85);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.coex-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: rgba(18, 25, 41, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 440px;
  box-shadow: var(--shadow-premium);
  position: relative;
  text-align: center;
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.close-btn:hover {
  color: #fff;
}

.modal-content h4 {
  font-family: var(--font-title);
  font-size: 18px;
  color: #fff;
  margin-bottom: 16px;
}

.qr-container {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-md);
  display: inline-block;
  margin: 10px auto 20px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  min-height: 200px;
  min-width: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-container img {
  display: block;
  max-width: 100%;
}

.instructions-list {
  text-align: left;
  margin-top: 20px;
  border-top: 1px solid var(--glass-border);
  padding-top: 16px;
}

.instructions-list h5 {
  font-size: 12px;
  color: #fff;
  margin-bottom: 8px;
}

.instructions-list ol {
  font-size: 11px;
  color: var(--text-secondary);
  padding-left: 16px;
  line-height: 1.6;
}

.instructions-list li {
  margin-bottom: 6px;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(37, 211, 102, 0.1);
  border-top-color: var(--primary-green);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Lista de Chats */
.chats-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chats-card .card-header {
  margin-bottom: 12px;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.chats-card .badge {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.chats-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.empty-state {
  text-align: center;
  padding: 40px 10px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 12px;
}

.empty-state .hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Item de Chat */
.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(37, 211, 102, 0.3);
}

.chat-item.active {
  background: rgba(37, 211, 102, 0.06);
  border-color: var(--primary-green);
  box-shadow: 0 0 10px rgba(37, 211, 102, 0.15);
}

.avatar {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.chat-item-details {
  flex: 1;
  overflow: hidden;
}

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

.chat-item-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.chat-item-time {
  font-size: 10px;
  color: var(--text-muted);
}

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

/* Área de Chat Central */
.chat-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(6, 9, 15, 0.2);
}

.chat-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
}

.placeholder-content {
  text-align: center;
  max-width: 420px;
  padding: 20px;
}

.icon-chat-placeholder {
  font-size: 60px;
  color: var(--text-muted);
  margin-bottom: 16px;
  opacity: 0.3;
}

.placeholder-content h3 {
  font-family: var(--font-title);
  font-size: 18px;
  color: #fff;
  margin-bottom: 8px;
}

.placeholder-content p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Janela de Chat Ativo */
.chat-window {
  height: 100%;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  padding: 0;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 22, 36, 0.3);
}

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

.contact-info h4 {
  font-family: var(--font-title);
  font-size: 15px;
  color: #fff;
}

.window-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.badge-success {
  background: rgba(37, 211, 102, 0.15);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: var(--primary-green);
}

.badge-expired {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger-red);
}

.time-left {
  font-size: 10px;
  color: var(--text-muted);
}

/* Área de Mensagens */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.3) 0%, rgba(6, 9, 15, 0.4) 100%);
}

.msg-wrapper {
  display: flex;
  width: 100%;
}

.msg-wrapper.incoming {
  justify-content: flex-start;
}

.msg-wrapper.outgoing {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 65%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Balão Cliente */
.incoming .msg-bubble {
  background: var(--bubble-client);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

/* Balão API */
.outgoing.api-sent .msg-bubble {
  background: var(--bubble-api);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Balão Celular (CoEx Echo) */
.outgoing.cell-sent .msg-bubble {
  background: var(--bubble-cell);
  border: 1px solid rgba(18, 140, 126, 0.4);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 9px;
  color: var(--text-muted);
}

.sender-tag {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sender-tag.client {
  color: var(--text-secondary);
}

.sender-tag.api {
  color: var(--primary-green);
}

.sender-tag.cell {
  color: #54c7ec;
}

.hidden {
  display: none !important;
}

/* Rodapé do Chat */
.chat-footer {
  padding: 16px 24px;
  background: rgba(10, 15, 26, 0.5);
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.send-form {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-container {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  display: flex;
  align-items: center;
}

.input-container input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 0;
}

.input-container input::placeholder {
  color: var(--text-muted);
}

.btn-send-icon {
  width: 38px;
  height: 38px;
  background: var(--primary-green);
  color: #0b0f19;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-send-icon:hover {
  background: #00ff7f;
  transform: scale(1.05);
}

.btn-send-icon svg {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

/* Aviso de Template (Janela Fechada) */
.template-warning {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
}

.template-warning p {
  font-size: 11px;
  color: #fda4af;
  line-height: 1.5;
}

.template-selector {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.template-selector select {
  background: rgba(15, 22, 36, 0.8);
  border: 1px solid var(--glass-border);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  font-family: var(--font-body);
}
