/* ============================================================
   WA Disparador — Premium Dark Mode UI
   ============================================================ */

/* ── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Zinc neutral palette (cohesive) ─ */
  --bg:    #09090b;
  --bg2:   #18181b;
  --bg3:   #27272a;
  --bg4:   #3f3f46;
  --border:  rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.12);

  --text:  #fafafa;
  --text2: #a1a1aa;
  --text3: #52525b;

  /* Brand accent — Emerald (one color everywhere) */
  --accent:      #10b981;
  --accent-dim:  rgba(16,185,129,.12);
  --accent-glow: 0 0 20px rgba(16,185,129,.25);

  /* Secondary */
  --purple:      #8b5cf6;
  --purple-dim:  rgba(139,92,246,.12);

  /* Semantic colors */
  --green:     #22c55e;
  --green-dim: rgba(34,197,94,.12);
  --green-wa:  #25D366;
  --blue:      #3b82f6;
  --blue-dim:  rgba(59,130,246,.12);
  --red:       #ef4444;
  --red-dim:   rgba(239,68,68,.10);
  --amber:     #f59e0b;
  --amber-dim: rgba(245,158,11,.10);
  --indigo:    #6366f1;
  --indigo-dim:rgba(99,102,241,.12);
  --teal:      #14b8a6;
  --teal-dim:  rgba(20,184,166,.12);

  --sidebar: 260px;
  --r: 12px;
  --r-sm: 8px;
  --r-lg: 16px;

  --shadow:    0 4px 24px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 48px rgba(0,0,0,.7);
  --glow-green:  0 0 24px rgba(37,211,102,.2);
  --glow-purple: 0 0 24px rgba(139,92,246,.25);
}

html { font-size: 14px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-wa); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LAYOUT ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(0,0,0,0.3);
}

.main-content {
  margin-left: var(--sidebar);
  flex: 1;
  min-height: 100vh;
  padding: 32px 36px;
  max-width: calc(100vw - var(--sidebar));
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.logo-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  box-shadow: var(--accent-glow);
}
.logo-text { display: flex; flex-direction: column; }
.logo-name { font-weight: 800; font-size: 1rem; color: var(--text); line-height: 1.2; letter-spacing: -0.01em; }
.logo-tag {
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  position: relative;
  width: 100%;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(249,115,22,0.35);
  font-weight: 600;
}
.nav-item.active .nav-icon { stroke: #fff; }
.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-alert {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--amber);
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 8px var(--amber);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
  50% { opacity: .6; transform: translateY(-50%) scale(.8); }
}

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid var(--border);
}
.connection-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--bg3);
  font-size: 0.8rem;
  font-weight: 500;
}
.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  transition: background .3s;
}
.conn-label { color: var(--text2); }
.conn-dot.connected { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn-dot.error { background: var(--red); }
.conn-dot.warning { background: var(--amber); }

/* ── PAGE HEADER ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 0.85rem;
  color: var(--text2);
  margin-top: 4px;
}

/* ── TAB SECTIONS ─────────────────────────────────────────── */
.tab-section { display: none; }
.tab-section.active { display: block; animation: fadeUp .25s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: #1a1730;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--r-lg);
  padding: 24px;
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: rgba(255,255,255,0.14); box-shadow: 0 4px 24px rgba(0,0,0,0.3); }
.card.card-inner {
  background: #221f3d;
  border-radius: var(--r);
  padding: 16px;
}

.card-header {
  margin-bottom: 20px;
}
.card-header:has(.card-desc) { margin-bottom: 14px; }
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.card-title-sm {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.card-desc {
  font-size: 0.8rem;
  color: var(--text2);
  margin-top: 3px;
}
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-3 { margin-bottom: 12px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background: rgba(30, 27, 75, 0.4);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--r-lg);
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  opacity: 0.7;
  transition: opacity .3s;
}
.stat-card:hover { 
  border-color: rgba(255,255,255,0.12); 
  transform: translateY(-4px); 
  box-shadow: 0 12px 40px rgba(0,0,0,0.4); 
  background: rgba(30, 27, 75, 0.6);
}

/* Elegant stat cards */
.stat-card.stat-coral::before  { background: linear-gradient(90deg, #f97316 0%, #ef4444 100%); }
.stat-card.stat-teal::before   { background: linear-gradient(90deg, #06b6d4 0%, #0891b2 100%); }
.stat-card.stat-purple::before { background: linear-gradient(90deg, #8b5cf6 0%, #6d28d9 100%); }
.stat-card.stat-green::before  { background: linear-gradient(90deg, #10b981 0%, #059669 100%); }
.stat-card.stat-indigo::before { background: linear-gradient(90deg, #6366f1 0%, #4338ca 100%); }
.stat-card.stat-pink::before   { background: linear-gradient(90deg, #ec4899 0%, #be185d 100%); }

.stat-card[class*='stat-'] .stat-label { 
  color: rgba(255,255,255,0.65); 
  font-size: 0.85rem; 
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.stat-card[class*='stat-'] .stat-value { 
  color: #fff; 
  font-size: 1.85rem; 
  font-weight: 700;
  margin-top: 4px;
  display: block;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  color: #fff;
  backdrop-filter: blur(4px);
}
.stat-icon--blue   { background: var(--blue-dim);   color: var(--blue); }
.stat-icon--green  { background: var(--green-dim);  color: var(--green); }
.stat-icon--purple { background: var(--purple-dim); color: var(--purple); }
.stat-icon--red    { background: var(--red-dim);    color: var(--red); }
.stat-icon--indigo { background: var(--indigo-dim); color: var(--indigo); }
.stat-icon--teal   { background: var(--teal-dim);   color: var(--teal); }
.stat-card[class*='stat-'] .stat-icon { background: rgba(255,255,255,0.2); color: #fff; }

/* ── CHARTS GRID ──────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 20px;
  align-items: stretch;
}
.chart-card {
  display: flex;
  flex-direction: column;
}
.chart-container {
  position: relative;
  width: 100%;
  height: 250px;
  margin-top: 15px;
}

@media (max-width: 1000px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}


.stat-body { display: flex; flex-direction: column; }
.stat-label { font-size: 0.73rem; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--text); line-height: 1.1; letter-spacing: -0.02em; }

/* ── TABLES ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r); }
.table-sm { max-height: 220px; overflow-y: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.table thead {
  position: sticky; top: 0;
  background: #221f3d;
  z-index: 1;
}
.table th {
  padding: 11px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  white-space: nowrap;
}
.table td {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle;
  color: var(--text);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,0.03); }
.cell-empty {
  text-align: center;
  color: var(--text3);
  padding: 32px !important;
  font-style: italic;
}

/* ── CAMPAIGN NAME / RATE ─────────────────────────────────── */
.camp-name { font-weight: 600; }
.rate-wrap { display: flex; align-items: center; gap: 8px; }
.rate-bar {
  height: 5px; width: 60px;
  background: var(--bg4);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.rate-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-wa));
  border-radius: 999px;
  transition: width .4s ease;
}
.rate-text { font-size: 0.8rem; color: var(--text2); white-space: nowrap; }

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-gray { background: var(--bg4); color: var(--text2); }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  box-shadow: 0 2px 12px rgba(249,115,22,.35);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(249,115,22,.45);
  filter: brightness(1.05);
}

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text2);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text); border-color: rgba(255,255,255,0.18); }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-xl {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 1rem;
  border-radius: var(--r);
  margin-top: 4px;
}

.btn-danger-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--red-dim);
  background: var(--red-dim);
  color: var(--red);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
}
.btn-danger-sm:hover { background: rgba(239,68,68,.25); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all .18s;
  text-decoration: none;
  margin-right: 4px;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }

/* ── FORMS ────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group-sm { gap: 4px; margin-bottom: 10px; }

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.form-hint {
  font-size: 0.75rem;
  color: var(--text3);
  line-height: 1.4;
}
.form-hint code {
  background: var(--bg4);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--green-wa);
}

.form-input, .form-select {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.1);
  background: #221f3d;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: all .18s;
  outline: none;
  width: 100%;
}
.form-input:focus, .form-select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139,92,246,.18);
}
.form-input::placeholder { color: var(--text3); }

.form-textarea {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.1);
  background: #221f3d;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
  min-height: 100px;
  transition: all .18s;
  outline: none;
  width: 100%;
  line-height: 1.6;
}
.form-textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139,92,246,.18);
}
.form-textarea::placeholder { color: var(--text3); }

.form-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b95a9' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-select option { background: var(--bg3); color: var(--text); }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.input-eye {
  position: relative;
  display: flex;
  align-items: center;
}
.input-eye .form-input { padding-right: 42px; }
.eye-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color .18s;
}
.eye-btn:hover { color: var(--text2); }

/* ── TYPE TOGGLE ──────────────────────────────────────────── */
.type-toggle {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 3px;
}
.type-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
}
.type-btn.active {
  background: var(--bg4);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.type-btn:hover:not(.active) { color: var(--text); }

/* ── UPLOAD ZONE ──────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--green-wa);
  background: var(--green-dim);
}
.upload-icon { color: var(--text3); }
.upload-zone:hover .upload-icon { color: var(--green-wa); }
.upload-title { font-weight: 600; color: var(--text); font-size: 0.9rem; }
.upload-hint { font-size: 0.75rem; color: var(--text3); }
.upload-hint code { background: var(--bg3); padding: 1px 5px; border-radius: 4px; color: var(--text2); }

.csv-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--green-dim);
  border-radius: var(--r-sm);
  border: 1px solid rgba(37,211,102,.2);
  font-size: 0.82rem;
  color: var(--green);
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ── VAR CHIPS ────────────────────────────────────────────── */
.var-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.chips-label { font-size: 0.75rem; color: var(--text3); font-weight: 500; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--purple-dim);
  color: var(--purple);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(139,92,246,.2);
  transition: all .18s;
  font-family: monospace;
}
.chip:hover { background: rgba(139,92,246,.3); transform: scale(1.05); }

/* ── MESSAGE PREVIEW ──────────────────────────────────────── */
.msg-preview {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.preview-label {
  padding: 8px 14px;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text3);
  background: var(--bg4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.preview-bubble {
  padding: 14px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.preview-bubble strong { color: var(--green-wa); }
.preview-bubble em.var-ph { color: var(--purple); font-style: normal; }

/* ── RANGE SLIDER ─────────────────────────────────────────── */
.range-input {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--bg4);
  outline: none;
  cursor: pointer;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--green-wa);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(37,211,102,.4);
  border: 2px solid var(--bg2);
  transition: all .18s;
}
.range-input::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range-hints {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text3);
  margin-top: 4px;
}

/* ── INFO BOXES ───────────────────────────────────────────── */
.info-box {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--blue-dim);
  border: 1px solid rgba(59,130,246,.2);
  font-size: 0.8rem;
  color: var(--blue);
  line-height: 1.5;
}
.info-box svg { flex-shrink: 0; margin-top: 2px; }
.info-box p { margin: 0; }

.warning-box {
  background: var(--amber-dim);
  border-color: rgba(245,158,11,.2);
  color: var(--amber);
}

/* ── GUIDE CARD ───────────────────────────────────────────── */
.guide-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  counter-reset: guide;
  margin-bottom: 18px;
}
.guide-list li {
  counter-increment: guide;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--text2);
  line-height: 1.5;
}
.guide-list li::before {
  content: counter(guide);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg4);
  color: var(--text3);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.guide-list li strong { color: var(--text); }
.guide-list li code {
  background: var(--bg4);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--green-wa);
}

/* ── TEMPLATES GRID ───────────────────────────────────────── */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.template-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  cursor: pointer;
  transition: all .2s;
}
.template-card:hover {
  border-color: var(--green-wa);
  transform: translateY(-2px);
  box-shadow: var(--glow-green);
}
.template-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.template-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.3;
}
.template-body {
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.55;
  margin-bottom: 12px;
  min-height: 40px;
}
.template-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.template-meta {
  font-size: 0.72rem;
  color: var(--text3);
}
.template-use-btn {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--green-wa);
  font-weight: 600;
}

/* ── CAMPAIGN LAYOUT ──────────────────────────────────────── */
.campaign-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}
.campaign-col-left, .campaign-col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── PROGRESS ─────────────────────────────────────────────── */
.progress-card { padding: 28px; }
.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  gap: 16px;
}
.progress-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.progress-sub { font-size: 0.82rem; color: var(--text2); margin-top: 3px; }
.progress-counters { display: flex; gap: 12px; flex-shrink: 0; }
.counter-sent { font-weight: 700; color: var(--green); font-size: 0.95rem; }
.counter-failed { font-weight: 700; color: var(--red); font-size: 0.95rem; }

.prog-bar-wrap {
  height: 10px;
  background: var(--bg4);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
.prog-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-wa));
  border-radius: 999px;
  transition: width .35s ease;
  box-shadow: 0 0 10px rgba(37,211,102,.3);
}
.prog-pct {
  text-align: right;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 16px;
}

.prog-log {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  background: var(--bg);
}
.log-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  animation: slideIn .15s ease;
}
.log-entry.log-sent { background: rgba(34,197,94,.06); }
.log-entry.log-failed { background: rgba(239,68,68,.06); }
.log-icon { font-size: 0.8rem; flex-shrink: 0; }
.log-entry.log-sent .log-icon { color: var(--green); }
.log-entry.log-failed .log-icon { color: var(--red); }
.log-phone { color: var(--text); font-family: monospace; }
.log-name { color: var(--text2); }
.log-sid { color: var(--text3); font-size: 0.7rem; margin-left: auto; font-family: monospace; }
.log-error { color: var(--red); font-size: 0.72rem; margin-left: auto; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.prog-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ── SINGLE SEND ──────────────────────────────────────────── */
.single-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.single-log {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.single-log-entry {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.5;
  animation: slideIn .2s ease;
}
.single-log-entry.ok { border-color: rgba(34,197,94,.2); background: rgba(34,197,94,.05); }
.single-log-entry.err { border-color: rgba(239,68,68,.2); background: rgba(239,68,68,.05); }

/* ── TWO COL LAYOUT ───────────────────────────────────────── */
.two-col-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.guide-card { align-self: start; }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; animation: fadeIn .2s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 780px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text2);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .18s;
}
.modal-close:hover { background: var(--bg4); color: var(--text); }
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.modal-stat {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}
.modal-stat span { font-size: 0.73rem; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; }
.modal-stat strong { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.text-green { color: var(--green) !important; }
.text-red { color: var(--red) !important; }
.text-muted { color: var(--text2); }
.text-xs { font-size: 0.72rem; }

.modal-progress { margin-bottom: 16px; }
.modal-footer { margin-top: 16px; display: flex; gap: 10px; }

/* ── TOAST ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  opacity: 0;
  transform: translateX(20px);
  transition: all .25s ease;
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.toast-success .toast-icon { background: var(--green-dim); color: var(--green); }
.toast-error .toast-icon { background: var(--red-dim); color: var(--red); }
.toast-info .toast-icon { background: var(--blue-dim); color: var(--blue); }
.toast-warning .toast-icon { background: var(--amber-dim); color: var(--amber); }
.toast-success { border-color: rgba(34,197,94,.25); }
.toast-error { border-color: rgba(239,68,68,.25); }
.toast-info { border-color: rgba(59,130,246,.25); }
.toast-warning { border-color: rgba(245,158,11,.25); }

.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  background: none; border: none;
  color: var(--text3); cursor: pointer;
  font-size: 1rem; line-height: 1;
  padding: 2px; flex-shrink: 0;
  transition: color .18s;
}
.toast-close:hover { color: var(--text); }

/* ── LOADING / SPINNERS ───────────────────────────────────── */
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px;
  color: var(--text2);
  font-size: 0.85rem;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--bg4);
  border-top-color: var(--green-wa);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  padding: 40px;
  text-align: center;
  color: var(--red);
  font-size: 0.875rem;
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .campaign-grid { grid-template-columns: 1fr; }
  .two-col-layout { grid-template-columns: 1fr; }
  .single-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { width: 56px; }
  .sidebar-logo .logo-text,
  .nav-item span,
  .sidebar-footer .conn-label { display: none; }
  .sidebar-logo { padding: 16px 12px; justify-content: center; }
  .logo-icon { margin: 0; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-alert { right: 4px; top: 4px; }
  .main-content { margin-left: 56px; padding: 20px 16px; }
  :root { --sidebar: 56px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal-stats { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 16px 12px; }
}

/* ── NAV UNREAD BADGE ─────────────────────────────────────── */
.nav-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  animation: pulse 2s infinite;
}

/* ── CHAT SECTION LAYOUT ──────────────────────────────────── */
.tab-chat-section {
  display: none;
  flex-direction: column;
  padding: 0 !important;
  height: 100vh;
  overflow: hidden;
}
.tab-chat-section.active { display: flex; }

/* Override main-content padding for chat tab */
.main-content:has(.tab-chat-section.active) { padding: 0; }

/* ── SYNC BAR ────────────────────────────────────────────── */
.sync-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  flex-shrink: 0;
}
.sync-bar-inner {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text2);
}
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sync-dot-anim {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text3);
  display: inline-block;
  transition: all 0.3s;
}
.sync-dot-anim.syncing {
  background-color: var(--blue);
  animation: syncPulse 1s infinite alternate;
  box-shadow: 0 0 8px var(--blue);
}
.sync-dot-anim.success {
  background-color: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.sync-dot-anim.error {
  background-color: var(--red);
  box-shadow: 0 0 6px var(--red);
}

@keyframes syncPulse {
  0% { opacity: 0.4; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.2); }
}


/* ── CHAT LAYOUT ──────────────────────────────────────────── */
.chat-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: 100%;
  
  /* WhatsApp Web Theme Variables */
  --wa-bg-sidebar: #111b21;
  --wa-bg-header: #202c33;
  --wa-bg-chat: #0b141a;
  --wa-bubble-in: #202c33;
  --wa-bubble-out: #005c4b;
  --wa-text-main: #e9edef;
  --wa-text-sub: #8696a0;
  --wa-input: #2a3942;
  --wa-hover: #202c33;
  --wa-active: #2a3942;
}

/* ── CONVERSATIONS PANE ───────────────────────────────────── */
.conv-pane {
  width: 30%;
  min-width: 300px;
  max-width: 420px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(134,150,160,0.15);
  background: var(--wa-bg-sidebar);
  overflow: hidden;
}
.conv-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--wa-bg-header);
  flex-shrink: 0;
}
.conv-pane-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--wa-text-main);
}
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px; height: 20px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}
.conv-search-wrap {
  padding: 8px 12px;
  flex-shrink: 0;
  background: var(--wa-bg-sidebar);
  border-bottom: 1px solid rgba(134,150,160,0.15);
}
.conv-search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: var(--wa-bg-header);
  color: var(--wa-text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}
.conv-search:focus { background: var(--wa-bg-header); }
.conv-search::placeholder { color: var(--wa-text-sub); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--wa-bg-sidebar);
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 0 14px;
  cursor: pointer;
  background: var(--wa-bg-sidebar);
  transition: background .15s;
  position: relative;
  height: 72px;
  flex-shrink: 0;
}
.conv-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 71px; /* Push past avatar */
  right: 0;
  height: 1px;
  background: rgba(134,150,160,0.15);
}
.conv-item:hover { background: var(--wa-hover); }
.conv-item.active { background: var(--wa-active); }
.conv-item.has-unread .conv-last-msg { color: var(--wa-text-main); font-weight: 600; }

.conv-avatar {
  width: 49px; height: 49px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-wa), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.conv-body { 
  flex: 1; 
  overflow: hidden; 
  display: flex; 
  flex-direction: column; 
  justify-content: center; 
  height: 100%;
}
.conv-name {
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--wa-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-last-msg {
  font-size: 0.85rem;
  color: var(--wa-text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.conv-last-msg.outbound::before { content: '✓ '; color: var(--wa-text-sub); }

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.conv-time { font-size: 0.75rem; color: var(--wa-text-sub); }
.conv-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #00a884;
  color: #111b21;
  font-size: 0.68rem;
  font-weight: 700;
}
.conv-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--wa-text-sub);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ── CHAT PANE ────────────────────────────────────────────── */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--wa-bg-chat);
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--wa-text-sub);
  text-align: center;
  padding: 40px;
  background: var(--wa-bg-sidebar); /* WhatsApp empty state uses sidebar bg */
}
.chat-empty-state h3 { font-size: 1rem; color: var(--wa-text-main); font-weight: 300; margin-top: 10px; }
.chat-empty-state p { font-size: 0.85rem; max-width: 320px; line-height: 1.6; }

.chat-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ── CHAT HEADER ──────────────────────────────────────────── */
.chat-head {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px 16px;
  background: var(--wa-bg-header);
  flex-shrink: 0;
  height: 60px;
}
.chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-wa), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}
.chat-contact { display: flex; flex-direction: column; justify-content: center; }
.chat-name { font-weight: 400; font-size: 1.05rem; color: var(--wa-text-main); }
.chat-phone { font-size: 0.8rem; color: var(--wa-text-sub); }

/* ── CHAT MESSAGES ────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 5%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--wa-bg-chat);
  /* WhatsApp classic doodle background encoded in SVG, but we use a subtle overlay or CSS pattern to keep it clean */
  background-image: 
    radial-gradient(circle at 100% 50%, rgba(255,255,255,0.02) 0%, transparent 60%),
    radial-gradient(circle at 0% 100%, rgba(255,255,255,0.015) 0%, transparent 60%);
}

/* Date separators */
.msg-date-sep {
  text-align: center;
  margin: 12px 0;
  display: flex;
  justify-content: center;
}
.msg-date-sep::before, .msg-date-sep::after { display: none; }
.msg-date-sep span {
  background: #182229;
  color: #8696a0;
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 8px;
  text-transform: uppercase;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

/* Bubbles */
.msg-row {
  display: flex;
  margin-bottom: 2px;
}
.msg-row.inbound { justify-content: flex-start; }
.msg-row.outbound { justify-content: flex-end; }

.msg-bubble {
  max-width: 65%;
  padding: 6px 7px 8px 9px;
  border-radius: 7.5px;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
}
.msg-row.inbound .msg-bubble {
  background: var(--wa-bubble-in);
  color: var(--wa-text-main);
  border-top-left-radius: 0;
}
.msg-row.outbound .msg-bubble {
  background: var(--wa-bubble-out);
  color: var(--wa-text-main);
  border-top-right-radius: 0;
}
.msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: -2px;
  float: right;
  margin-left: 10px;
}
.msg-time { font-size: 0.68rem; color: rgba(255,255,255,0.6); margin-top: 5px; }
.msg-row.inbound .msg-time { color: rgba(255,255,255,0.6); }
.msg-status {
  font-size: 0.7rem;
  color: #53bdeb; /* WhatsApp Blue Ticks */
  margin-top: 5px;
}

/* ── DISPARO BADGE ── */
.disparo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(37, 211, 102, 0.18);
  border: 1px solid rgba(37, 211, 102, 0.35);
  color: #25d366;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  margin-bottom: 5px;
  width: fit-content;
}
.disparo-badge svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.new-msg-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--green-dim);
  border: 1px solid rgba(37,211,102,.25);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 600;
  align-self: center;
  cursor: pointer;
  transition: all .18s;
  animation: bounce .5s ease;
}
.new-msg-indicator:hover { background: rgba(37,211,102,.25); }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ── CHAT INPUT BAR ───────────────────────────────────────── */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 16px;
  background: var(--wa-bg-header);
  flex-shrink: 0;
  min-height: 62px;
}
.chat-textarea {
  flex: 1;
  background: var(--wa-input);
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--wa-text-main);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  scrollbar-width: thin;
  margin-bottom: 2px;
}
.chat-textarea::placeholder { color: var(--wa-text-sub); }
.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--wa-text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .2s;
  margin-bottom: 6px;
}
.chat-send-btn:hover { color: var(--wa-text-main); }
.chat-send-btn:active { transform: scale(.96); }
.chat-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Adjust attachment buttons */
.chat-input-bar .btn-ghost {
  color: var(--wa-text-sub);
  margin-bottom: 6px;
}
.chat-input-bar .btn-ghost:hover {
  background: transparent;
  color: var(--wa-text-main);
}
/* ── CHAT MEDIA ATTACHMENTS ───────────────────────────────── */
.chat-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--r-sm);
  margin-bottom: 5px;
  cursor: pointer;
  display: block;
  transition: opacity 0.2s;
}
.chat-img:hover {
  opacity: 0.9;
}
.media-download-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--green-wa);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 5px;
  text-decoration: none;
}
.media-download-link:hover {
  background: var(--bg3);
}

@media (max-width: 860px) {
  .conv-pane { width: 240px; }
  .chat-layout { flex-direction: column; height: auto; }
  .conv-pane { width: 100%; max-height: 200px; }
}

/* ── CHAT & CAMPAIGN CONTROLS ENHANCEMENTS ── */
.badge-pulse {
  animation: badgePulse 2s infinite;
}
@keyframes badgePulse {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.chat-window-banner {
  margin: 10px 14px 0;
  border-radius: var(--r-sm);
  line-height: 1.5;
}
.chat-window-banner.open {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.15);
  color: var(--green);
}
.chat-window-banner.closed {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.15);
  color: var(--amber);
}

.btn-icon--red {
  color: var(--red) !important;
  border-color: rgba(239, 68, 68, 0.15) !important;
}
.btn-icon--red:hover {
  background: var(--red-dim) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

/* ── ADVANCED ENHANCEMENTS: TABS, QUICK REPLIES, AUTOCOMPLETE ── */

/* Chat Tabs Styling */
.chat-tab-btn {
  transition: all 0.2s ease;
}
.chat-tab-btn:hover {
  background: var(--bg3) !important;
  color: var(--text) !important;
}
.chat-tab-btn.active {
  background: var(--bg4) !important;
  color: var(--green-wa) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Button Icon Only for attachments */
.btn-icon-only {
  transition: all 0.2s;
}
.btn-icon-only:hover {
  background: var(--bg4) !important;
  color: var(--green-wa) !important;
}

/* Floating Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  bottom: 100%;
  left: 10px;
  right: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1001;
  box-shadow: var(--shadow-lg);
  margin-bottom: 5px;
  backdrop-filter: blur(8px);
}
.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text2);
  display: flex;
  justify-content: space-between;
  transition: background 0.15s;
}
.autocomplete-item:hover, .autocomplete-item.active {
  background: var(--bg4);
  color: var(--text);
}
.autocomplete-item strong {
  color: var(--green-wa);
}

/* Variable Autocomplete inside Textarea */
.var-autocomplete-dropdown {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  max-height: 180px;
  overflow-y: auto;
  z-index: 1005;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}
.var-autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text2);
  transition: background 0.15s;
}
.var-autocomplete-item:hover, .var-autocomplete-item.active {
  background: var(--bg4);
  color: var(--text);
}

/* Quick Replies Config Row */
.qr-row {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  gap: 10px;
  align-items: center;
  background: var(--bg3);
  padding: 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

/* Campaign Metrics Card styling */
.progress-metrics {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* Log Filter buttons */
.log-filter-bar button {
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  transition: all 0.2s;
}
.log-filter-bar button.active {
  background: var(--green-dim);
  border-color: rgba(37, 211, 102, 0.3);
  color: var(--green-wa);
}

/* Real-time Checkmarks & Voice Recording Styles */
.msg-status {
  font-family: monospace;
  font-size: 0.72rem;
  margin-left: 4px;
}
.msg-status.status-sent { color: #8b95a9; }
.msg-status.status-delivered { color: #8b95a9; }
.msg-status.status-read { color: #22c55e; }
.msg-status.status-failed { color: var(--red); }

@keyframes pulseRed {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#chat-record-btn.recording {
  color: var(--red) !important;
  background: rgba(239, 68, 68, 0.15) !important;
  animation: pulseRed 1.5s infinite;
}


/* CRM Pane */
.crm-pane {
  display: none;
  width: 350px;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-direction: column;
}
.crm-pane.active {
  display: flex;
}


/* ── UNOFFICIAL MODULE STYLES ─────────────────────────────── */

/* Warning banner */
.unofficial-warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--r);
  font-size: 0.83rem;
  color: var(--amber);
  margin-bottom: 24px;
  line-height: 1.5;
}
.unofficial-warning-banner svg { flex-shrink: 0; margin-top: 1px; }

/* Layout grid */
.unofficial-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 860px;
}

/* Status badge */
.unofficial-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-left: auto;
}
.unofficial-badge.connected {
  background: var(--green-dim);
  color: var(--green);
  box-shadow: 0 0 12px rgba(34,197,94,.2);
}
.unofficial-badge.qr,
.unofficial-badge.connecting {
  background: var(--amber-dim);
  color: var(--amber);
  animation: pulse 1.5s infinite;
}
.unofficial-badge.disconnected {
  background: var(--red-dim);
  color: var(--red);
}

/* QR Code frame */
.qr-frame {
  display: inline-block;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
  animation: fadeUp .3s ease;
}

/* Connection card header with status badge */
.unofficial-conn-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Nav dot indicator */
.unofficial-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: none;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  flex-shrink: 0;
}

/* Unofficial campaign card header */
#unofficial-form-card .card-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

/* Anti-ban accordion */
.antiban-accordion { border-radius: 10px; overflow: visible; }

.antiban-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  text-align: left;
}
.antiban-toggle:hover { border-color: var(--border2); background: var(--bg4); }
.antiban-toggle.open { border-radius: 10px 10px 0 0; border-bottom-color: transparent; }

.antiban-section {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.antiban-section:last-child { border-bottom: none; padding-bottom: 0; }
.antiban-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.antiban-hint {
  font-size: 0.76rem;
  color: var(--text3);
  margin-top: 8px;
  line-height: 1.4;
}

.antiban-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  transition: border-color .18s;
}
.antiban-option:hover { border-color: var(--border2); background: var(--bg4); }

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg4);
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 2px; top: 2px;
  border-radius: 50%;
  background: var(--text3);
  transition: .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--green-dim); border-color: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { background: var(--green); transform: translateX(16px); }

/* ── CHIP SLOTS ────────────────────────────────────────────── */
.chip-slot {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 160px;
  transition: border-color .2s;
}
.chip-slot.connected { border-color: rgba(37,211,102,0.35); background: rgba(37,211,102,0.04); }
.chip-slot.qr { border-color: rgba(245,158,11,0.35); }
.chip-slot.connecting { border-color: rgba(245,158,11,0.35); }

.chip-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.chip-slot-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}
.chip-slot-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chip-phone {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--green);
  font-weight: 600;
  letter-spacing: .02em;
}
.chip-warmup-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.chip-daily-bar {
  height: 4px;
  background: var(--bg4);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.chip-daily-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease;
  min-width: 3px;
}
.chip-daily-text {
  font-size: 0.75rem;
  color: var(--text3);
}
.chip-qr-wrap { flex: 1; }

/* Chip selector in form */
.chip-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .18s;
  user-select: none;
}
.chip-select-option:hover { border-color: var(--border2); }
.chip-select-option input[type="checkbox"] { accent-color: var(--green); width: 15px; height: 15px; }
.chip-sel-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

@media (max-width: 768px) {
  #chips-grid { grid-template-columns: 1fr !important; }
}

/* WHATSAPP AUDIO PLAYER */
.wa-audio-player { display: flex; align-items: center; gap: 12px; min-width: 260px; padding: 5px; }
.wa-audio-player.inbound .wa-audio-avatar { order: 3; } .wa-audio-player.inbound .wa-play-btn { order: 1; } .wa-audio-player.inbound .wa-audio-track { order: 2; } .wa-audio-player.outbound .wa-audio-avatar { order: 1; } .wa-audio-player.outbound .wa-play-btn { order: 2; } .wa-audio-player.outbound .wa-audio-track { order: 3; }
.wa-audio-avatar { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.wa-audio-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.wa-mic-icon { position: absolute; bottom: 0px; left: -10px; width: 20px; height: 20px; background: white; border-radius: 50%; padding: 2px; }
.wa-audio-player.outbound .wa-mic-icon { right: -10px; left: auto; }
.wa-play-btn { background: transparent; border: none; cursor: pointer; color: var(--wa-text-main); padding: 0; width: 32px; height: 32px; flex-shrink: 0; display:flex; align-items:center; justify-content:center; }
.wa-audio-track { flex: 1; display: flex; flex-direction: column; justify-content: center; position: relative; }
.wa-waveform { position: relative; width: 100%; height: 30px; display: flex; align-items: center; }
.wa-waveform-bg { position: absolute; width: 100%; height: 16px; background: repeating-linear-gradient(90deg, #999 0px, #999 2.5px, transparent 2.5px, transparent 4.5px); opacity: 0.5; border-radius: 8px;}
.wa-audio-progress-bar { position: absolute; left: 0; height: 16px; background: repeating-linear-gradient(90deg, #53bdeb 0px, #53bdeb 2.5px, transparent 2.5px, transparent 4.5px); pointer-events: none; border-radius: 8px; }
.wa-audio-slider { position: absolute; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; margin: 0; left: 0; top: 0; }
.wa-audio-thumb { position: absolute; top: 50%; left: 0%; transform: translate(-50%, -50%); width: 12px; height: 12px; background: #53bdeb; border-radius: 50%; pointer-events: none; z-index: 5; transition: left 0.1s linear; }
.wa-audio-time { font-size: 11px; color: var(--wa-text-meta); margin-top: 4px; display: flex; justify-content: space-between;}


/* Chat Menu & Search */
.chat-menu-item { padding: 12px 24px; cursor: pointer; color: var(--text); }
.chat-menu-item:hover { background: var(--bg); }
.chat-search-item { padding: 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.2s; }
.chat-search-item:hover { background: var(--bg2); }
.chat-search-date { font-size: 0.75rem; color: var(--text3); margin-bottom: 4px; }
.chat-search-text { font-size: 0.9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ========================================================
   PREMIUM UX/UI: CHIP CONNECTION & UNOFFICIAL CAMPAIGN
   ======================================================== */

/* --- Chips Grid Premium --- */
.chip-slot {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.chip-slot:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Connecting Pulse Animation */
@keyframes pulseRing {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.5); opacity: 0; }
}
.pulse-ring {
  position: relative;
  width: 12px; height: 12px;
  border-radius: 50%;
  background-color: var(--amber);
}
.pulse-ring::before {
  content: '';
  position: absolute;
  left: -4px; top: -4px; right: -4px; bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--amber);
  animation: pulseRing 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

/* QR Code Glassmorphism */
.chip-qr-wrap {
  position: relative;
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}
.chip-qr-wrap img {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: opacity 0.3s ease;
}

/* --- Split Pane Layout for Unofficial Campaign --- */
.unofficial-split-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
@media (min-width: 992px) {
  .unofficial-split-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .unofficial-split-builder {
    flex: 1;
    min-width: 0; /* prevent flex overflow */
  }
  .unofficial-split-preview {
    width: 340px;
    position: sticky;
    top: 24px;
    flex-shrink: 0;
  }
}

/* --- Premium WhatsApp Live Preview Mockup --- */
.wa-mockup {
  background: #ece5dd;
  border-radius: 20px;
  border: 8px solid #111;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  height: 600px;
  position: relative;
}
.wa-mockup-header {
  background: #075E54;
  color: white;
  padding: 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 2;
}
.wa-mockup-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  position: relative;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 10h10v10H10z' fill='rgba(0,0,0,0.03)'/%3E%3C/svg%3E");
}
.wa-mockup-bubble {
  background: #DCF8C6;
  border-radius: 8px;
  border-top-right-radius: 0;
  padding: 8px 10px;
  max-width: 85%;
  margin-left: auto;
  font-size: 0.9rem;
  line-height: 1.4;
  color: #111;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  position: relative;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.wa-mockup-bubble::before {
  content: '';
  position: absolute;
  right: -8px;
  top: 0;
  width: 0;
  height: 0;
  border-left: 10px solid #DCF8C6;
  border-bottom: 10px solid transparent;
}
.wa-mockup-time {
  display: block;
  text-align: right;
  font-size: 0.65rem;
  color: rgba(0,0,0,0.45);
  margin-top: 4px;
}

/* --- Interactive Sliders --- */
.range-input {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  outline: none;
  transition: background 0.3s;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.1s, background 0.3s;
}
.range-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.range-input.safe::-webkit-slider-thumb { background: var(--green); }
.range-input.warn::-webkit-slider-thumb { background: var(--amber); }
.range-input.danger::-webkit-slider-thumb { background: var(--red); }

/* --- Fancy Upload Zone --- */
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
  transform: scale(1.02);
}
.upload-zone {
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
\n
/* Light Mode Theme */
.light-mode {
  --bg: #f4f7f6;
  --bg2: #ffffff;
  --bg3: #f9fbfc;
  --bg4: #f1f5f9;
  --border: rgba(0,0,0,0.1);
  --border2: rgba(0,0,0,0.15);
  --text: #1e293b;
  --text2: #475569;
  --text3: #64748b;
  --shadow: 0 4px 12px rgba(0,0,0,.05);
}

/* Skeleton Loaders */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  min-height: 20px;
}

/* Context Menu */
.context-menu {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 8px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  min-width: 150px;
}
.context-menu button {
  background: none; border: none; color: var(--text); padding: 8px 12px; text-align: left; cursor: pointer; border-radius: 4px;
}
.context-menu button:hover { background: var(--bg3); }

/* Drag & Drop Zone */
.dropzone {
  border: 2px dashed var(--border2);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  transition: all 0.3s;
  cursor: pointer;
  background: var(--bg3);
}
.dropzone.dragover {
  border-color: var(--green);
  background: var(--green-dim);
}

/* Toast Enhancements */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--bg2); border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 16px; border-radius: 8px; color: var(--text); display: flex; gap: 12px; align-items: center;
  animation: slideInRight 0.3s forwards, fadeOut 0.3s 2.7s forwards;
  min-width: 280px; border-left: 4px solid var(--blue);
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

/* Mobile Menu */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; width: 100%; padding: 16px; }
  .mobile-header { display: flex !important; }
}
.mobile-header {
  display: none; justify-content: space-between; align-items: center; padding-bottom: 16px;
}
/* ========================================= */
/* AI COACH BUBBLE (In-chat analysis)        */
/* ========================================= */
.ai-coach-bubble {
  background: var(--bg3);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-left: 4px solid #7c3aed;
  border-radius: 8px;
  padding: 16px;
  margin: 16px auto;
  max-width: 90%;
  color: var(--text);
  font-size: 0.9rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  position: relative;
  align-self: center;
  width: 100%;
}
.ai-coach-bubble h4 {
  margin: 0 0 10px 0;
  color: #7c3aed;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-coach-bubble .coach-content {
  line-height: 1.5;
  white-space: pre-wrap;
}
.ai-coach-bubble .coach-content p { margin-top: 0; margin-bottom: 8px; }
.ai-coach-bubble .coach-content strong { color: #a78bfa; font-weight: 600; }
.coach-loading {
  display: inline-flex;
  gap: 4px;
}
.coach-loading span {
  width: 6px;
  height: 6px;
  background: #7c3aed;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.coach-loading span:nth-child(1) { animation-delay: -0.32s; }
.coach-loading span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.msg-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}
