/* ── CSS VARIABLES (used in JS inline styles) ─────────────────────────── */
:root {
  --bg:         #070918;
  --bg-card:    #0d1117;
  --bg-input:   #111827;
  --bg-elevated:#161c2c;
  --border:     rgba(51,65,85,0.4);
  --border-strong: rgba(51,65,85,0.7);
  --text:       #e2e8f0;
  --text-dim:   #94a3b8;
  --text-muted: #64748b;
  --primary:    #3b82f6;
  --success:    #22c55e;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --warning-bg: rgba(245,158,11,0.08);
  --danger-bg:  rgba(239,68,68,0.08);
}

/* ── BUTTONS ─────────────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success,
.btn-warning,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 14px;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary  { background: #2563eb; color: #fff; }
.btn-primary:hover  { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { background: #1e293b; color: #94a3b8; border: 1px solid rgba(51,65,85,0.6); }
.btn-secondary:hover { background: #263548; color: #e2e8f0; }

.btn-danger   { background: rgba(239,68,68,0.1); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-success  { background: rgba(34,197,94,0.1); color: #22c55e; border: 1px solid rgba(34,197,94,0.2); }
.btn-success:hover { background: rgba(34,197,94,0.2); }

.btn-warning  { background: rgba(245,158,11,0.1); color: #f59e0b; border: 1px solid rgba(245,158,11,0.2); }
.btn-warning:hover { background: rgba(245,158,11,0.2); }

.btn-ghost    { background: transparent; color: #64748b; }
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }

.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

/* ── BADGES ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-blue   { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.badge-green  { background: rgba(34,197,94,0.1);   color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.badge-red    { background: rgba(239,68,68,0.1);   color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-yellow { background: rgba(245,158,11,0.1);  color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.badge-gray   { background: rgba(100,116,139,0.1); color: #94a3b8; border: 1px solid rgba(100,116,139,0.2); }
.badge-purple { background: rgba(139,92,246,0.1);  color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); }
.badge-cyan   { background: rgba(6,182,212,0.1);   color: #22d3ee; border: 1px solid rgba(6,182,212,0.2); }

/* ── SPINNER ─────────────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.06);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ─────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  color: #64748b;
  font-size: 13px;
  text-align: center;
  gap: 8px;
}

/* ── TABLE UTILITIES ─────────────────────────────────────────────────── */
.table-actions { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }

.client-info { display: flex; align-items: center; gap: 10px; }
.client-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #1e3a5f, #1d4ed8);
  color: #93c5fd; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; text-transform: uppercase;
}
.client-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }

/* ── STATUS DOTS ─────────────────────────────────────────────────────── */
.whatsapp-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #94a3b8; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.connected    { background: #22c55e; box-shadow: 0 0 5px rgba(34,197,94,0.5); }
.status-dot.disconnected { background: #334155; }
.status-dot.connecting   { background: #f59e0b; animation: pulse-dot 1.2s ease-in-out infinite; }
.status-dot.qr_pending   { background: #3b82f6; animation: pulse-dot 1.2s ease-in-out infinite; }
.status-dot.authenticated{ background: #22c55e; animation: pulse-dot 1.2s ease-in-out infinite; }
.status-dot.auth_failed  { background: #ef4444; }
@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.8); }
}

/* ── TOGGLE SWITCH ───────────────────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #1e293b; border: 1px solid rgba(51,65,85,0.7);
  border-radius: 20px; transition: all 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  height: 14px; width: 14px; left: 2px; bottom: 2px;
  background: #475569; border-radius: 50%; transition: all 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.35); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); background: #22c55e; }

/* ── AGENT CARDS ─────────────────────────────────────────────────────── */
.agent-card {
  background: #0d1117; border: 1px solid rgba(51,65,85,0.5);
  border-radius: 12px; padding: 18px;
  display: flex; flex-direction: column; gap: 12px; transition: border-color 0.15s;
}
.agent-card:hover { border-color: rgba(59,130,246,0.3); }
.agent-card-header { display: flex; align-items: flex-start; justify-content: space-between; }
.agent-name { font-size: 15px; font-weight: 600; color: #e2e8f0; }
.agent-type-badge {
  display: inline-block; background: rgba(59,130,246,0.1);
  color: #60a5fa; border-radius: 4px; padding: 2px 8px;
  font-size: 11px; margin-top: 4px;
}
.agent-prompt-preview {
  font-size: 12.5px; color: #64748b; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; flex: 1;
}
.agent-card-footer {
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid rgba(51,65,85,0.3); padding-top: 12px;
}
.agent-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.active-toggle { display: flex; align-items: center; }
.add-agent-placeholder {
  background: transparent; border: 2px dashed rgba(51,65,85,0.5);
  border-radius: 12px; padding: 30px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; cursor: pointer;
  transition: all 0.15s; color: #64748b; text-align: center; min-height: 160px;
}
.add-agent-placeholder:hover { border-color: #3b82f6; color: #60a5fa; background: rgba(59,130,246,0.04); }
.add-agent-placeholder span  { font-size: 28px; font-weight: 300; }
.add-agent-placeholder strong{ font-size: 14px; font-weight: 600; }
.add-agent-placeholder small { font-size: 12px; }

/* ── TOAST ───────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 11px 16px; border-radius: 9px; font-size: 13px; font-weight: 500;
  max-width: 340px; min-width: 220px; border: 1px solid transparent;
  animation: toast-in 0.25s ease; backdrop-filter: blur(8px);
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } }
.toast.success { background: rgba(20,83,45,0.95);  border-color: rgba(34,197,94,0.3);  color: #bbf7d0; }
.toast.error   { background: rgba(127,29,29,0.95); border-color: rgba(239,68,68,0.3);  color: #fecaca; }
.toast.warning { background: rgba(92,45,5,0.95);   border-color: rgba(245,158,11,0.3); color: #fde68a; }

/* ── CONVERSATIONS ───────────────────────────────────────────────────── */
/* WhatsApp official dark mode palette */
.wa-layout       { background: #111B21; border-color: #222D35 !important; }
.wa-chat-bg      { background: #0B141A; }
.wa-left-panel   { background: #111B21; }
.wa-header       { background: #1F2C34; border-bottom: 1px solid #222D35; }

.conv-item { padding: 12px 14px; border-bottom: 1px solid #222D35; cursor: pointer; transition: background 0.12s; background: #111B21; }
.conv-item:hover  { background: #1F2C34; }
.conv-item.active { background: #2A3942; border-right: 3px solid #00A884; }
.conv-name    { font-size: 13px; font-weight: 600; color: #E9EDEF; }
.conv-time    { font-size: 10.5px; color: #8696A0; }
.conv-preview { font-size: 12px; color: #8696A0; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-messages { flex: 1; overflow-y: auto; padding: 16px 10%; display: flex; flex-direction: column; gap: 4px; background: #0B141A; }
.message-bubble {
  max-width: 65%; padding: 7px 12px 7px 12px;
  font-size: 13.5px; line-height: 1.5; word-break: break-word; position: relative;
}
/* Incoming (client) — dark bubble, left */
.message-bubble.user {
  background: #202C33; color: #E9EDEF;
  border-radius: 0 8px 8px 8px;
  align-self: flex-start;
  margin-bottom: 2px;
}
.message-bubble.user::before {
  content: ''; position: absolute; top: 0; left: -8px;
  border: 8px solid transparent; border-top-color: #202C33; border-right-color: #202C33;
  border-left: none; border-bottom: none;
}
/* Outgoing (bot) — green bubble, right */
.message-bubble.assistant {
  background: #005C4B; color: #E9EDEF;
  border-radius: 8px 0 8px 8px;
  align-self: flex-end;
  margin-bottom: 2px;
}
.message-bubble.assistant::before {
  content: ''; position: absolute; top: 0; right: -8px;
  border: 8px solid transparent; border-top-color: #005C4B; border-left-color: #005C4B;
  border-right: none; border-bottom: none;
}
.message-meta { font-size: 10.5px; color: #8696A0; margin-top: 2px; padding: 0 2px; }
.qr-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #64748b; font-size: 13px; }

/* ── DRIVE / FILES ───────────────────────────────────────────────────── */
.file-item {
  background: #0d1117; border: 1px solid rgba(51,65,85,0.5);
  border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; position: relative; cursor: pointer; transition: border-color 0.15s;
  text-align: center; overflow: hidden;
}
.file-item:hover { border-color: rgba(59,130,246,0.35); }
.file-item.has-attributes { border-color: rgba(59,130,246,0.25); }
.file-icon { font-size: 36px; }
.file-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.file-name { font-size: 12px; color: #94a3b8; word-break: break-all; line-height: 1.3; }
.file-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 3px; opacity: 0; transition: opacity 0.15s; }
.file-item:hover .file-actions { opacity: 1; }
.file-action-btn { width: 24px; height: 24px; border-radius: 5px; border: none; cursor: pointer; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.file-action-btn.edit   { background: rgba(59,130,246,0.15); color: #60a5fa; }
.file-action-btn.delete { background: rgba(239,68,68,0.12);  color: #f87171; }

/* ── FORM GROUP (JS-generated forms) ─────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }

/* ── AMOUNT COLORS ───────────────────────────────────────────────────── */
.amount-positive { color: #22c55e; }
.amount-negative { color: #ef4444; }

/* ── SUMMARY ROW (dashboard) ─────────────────────────────────────────── */
.summary-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid rgba(51,65,85,0.2); }
.summary-row:last-child { border-bottom: none; }

/* ── ACTIVITY ITEM ───────────────────────────────────────────────────── */
.activity-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(51,65,85,0.2); font-size: 13px; color: #94a3b8; }
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 14px; }
