/* ============================================================
   Mebbi SaaS — Design System
   ============================================================ */

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

:root {
  --primary:        #36B76B;
  --primary-light:  #D4F1E0;
  --primary-dark:   #2A9056;
  --secondary:      #F4A13A;
  --secondary-light:#FEF3C7;
  --mebbi:          #52177d;
  --mebbi-light:    #EDE9FE;

  --bg-app:         #F9FAFB;
  --bg-white:       #FFFFFF;
  --bg-hover:       #F3F4F6;

  --text-heading:   #111827;
  --text-body:      #374151;
  --text-muted:     #6B7280;
  --text-subtle:    #9CA3AF;

  --border:         #E5E7EB;
  --border-light:   #F0F0F0;

  --shadow-sm:      0 1px 2px rgba(0,0,0,.05);
  --shadow-md:      0 4px 6px rgba(0,0,0,.07);

  --radius-sm:  6px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  --sidebar-w: 220px;
  --ai-w:      340px;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg-app); color: var(--text-body); font-size: 14px; line-height: 1.5; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeInUp   { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes slideInR   { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:translateX(0); } }
@keyframes slideInL   { from { opacity:0; transform:translateX(-16px); } to { opacity:1; transform:translateX(0); } }
@keyframes growUp     { from { transform:scaleY(0); } to { transform:scaleY(1); } }
@keyframes progressFill { from { width:0; } to { width:var(--target); } }
@keyframes pulse      { 0%,100% { opacity:1; } 50% { opacity:.5; } }
@keyframes spin       { to { transform:rotate(360deg); } }

.fade-up  { animation: fadeInUp 0.5s ease-out both; animation-delay: var(--delay, 0s); }
.slide-in { animation: slideInR 0.4s ease-out both; }

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.sidebar-nav { flex: 1; padding: 12px 8px; }

.nav-group { margin-bottom: 20px; }

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 8px 6px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-heading); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--mebbi);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name  { display: block; font-size: 12px; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: 10px; color: var(--text-subtle); }

.btn-logout {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.btn-logout svg { width: 16px; height: 16px; fill: currentColor; }
.btn-logout:hover { color: #EF4444; background: #FEF2F2; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-width: 0;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title    { font-size: 22px; font-weight: 700; color: var(--text-heading); letter-spacing: -.025em; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Date Filter ──────────────────────────────────────────── */
.date-filter-group {
  position: relative;
  list-style: none; /* remove marker do <details> em alguns browsers */
}
/* Remove o triângulo padrão do <details> */
.date-filter-group summary { list-style: none; }
.date-filter-group summary::-webkit-details-marker { display: none; }

.date-filter-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  font-size: 13px; font-weight: 500; color: var(--text-body);
  cursor: pointer; transition: border-color .15s;
  user-select: none;
}
.date-filter-btn:hover { border-color: var(--primary); }
.date-filter-btn svg { width: 15px; height: 15px; fill: var(--text-muted); }
.date-filter-btn .chevron { width: 16px; height: 16px; }

.date-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 200px;
  z-index: 9999;
}
/* Mostra dropdown quando <details> está aberto */
.date-filter-group[open] .date-dropdown { display: block; }
.date-dropdown.open { display: block; }

.date-option {
  display: block;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-body);
  text-decoration: none;
  transition: background .15s;
}
.date-option:hover { background: var(--bg-hover); }
.date-option.active { color: var(--primary); font-weight: 600; background: var(--primary-light); }

.date-custom-range { padding: 10px 16px; border-top: 1px solid var(--border); }
.custom-range-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.date-input { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; font-family: var(--font); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover  { opacity: .88; }
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary svg { width: 14px; height: 14px; fill: #fff; }

.btn-ghost  { background: transparent; border: 1px solid var(--border); color: var(--text-body); }
.btn-full   { width: 100%; justify-content: center; }
.btn-sm     { padding: 5px 10px; font-size: 11px; }

.btn-icon { width: 30px; height: 30px; border: none; background: none; cursor: pointer; border-radius: var(--radius-sm); font-size: 15px; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.btn-icon:hover { background: var(--bg-hover); }
.btn-icon-green:hover { background: var(--primary-light); }
.btn-icon-orange:hover { background: var(--secondary-light); }
.btn-icon-red:hover { background: #FEF2F2; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.card-title  { font-size: 14px; font-weight: 600; color: var(--text-heading); flex: 1; }
.card-link   { font-size: 12px; color: var(--primary); text-decoration: none; font-weight: 600; display: block; margin-top: 16px; }
.card-link-sm{ font-size: 12px; color: var(--primary); text-decoration: none; font-weight: 600; }

/* ── KPI Grid ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-grid-6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 1400px) { .kpi-grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-label  { font-size: 12px; font-weight: 500; color: var(--text-muted); }

.kpi-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.kpi-icon svg { width: 16px; height: 16px; fill: currentColor; }

.icon-green  { background: var(--primary-light); color: var(--primary); }
.icon-orange { background: var(--secondary-light); color: var(--secondary); }
.icon-purple { background: var(--mebbi-light); color: var(--mebbi); }
.icon-blue   { background: #DBEAFE; color: #2563EB; }

.kpi-value {
  font-size: 28px; font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -.05em;
  line-height: 1.1;
  margin-bottom: 4px;
}
.kpi-trend   { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.kpi-sources { font-size: 10px; color: var(--text-subtle); }

/* ── Trend Badges ─────────────────────────────────────────── */
.trend-badge, .badge-success, .badge-danger, .badge-neutral {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
}
.badge-success, .trend-badge.badge-success { background: var(--primary-light); color: var(--primary); }
.badge-danger  { background: #FEF2F2; color: #EF4444; }
.badge-neutral { background: var(--bg-hover); color: var(--text-muted); }

/* ── Charts ───────────────────────────────────────────────── */
.charts-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.chart-card { flex: 1; padding: 20px; }
.chart-big  { flex: 2.2; }
.chart-small{ flex: 1; }

.chart-wrapper { position: relative; height: 220px; }
.chart-wrapper canvas { width: 100% !important; height: 100% !important; }

.chart-legend {
  display: flex; align-items: center;
  font-size: 11px; color: var(--text-muted);
  font-weight: 500;
}
.legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.donut-legend { margin-top: 12px; font-size: 11px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; }

/* ── Progress ─────────────────────────────────────────────── */
.progress-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 1200px) { .progress-row { grid-template-columns: 1fr 1fr; } }

.progress-card { }
.progress-metrics { display: flex; flex-direction: column; gap: 12px; margin-bottom: 4px; }

.progress-item {}
.progress-label-row {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  margin-bottom: 5px;
}
.progress-label-row span:last-child { font-weight: 600; color: var(--text-heading); }

.progress-bar-track {
  height: 7px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transform-origin: left;
  animation: progressFill .8s ease-out both;
  animation-delay: calc(var(--delay, 0s) + 0.4s);
  width: var(--target, 50%);
}
.progress-bar-fill.green  { background: var(--primary); }
.progress-bar-fill.orange { background: var(--secondary); }

/* ── Status Dots ──────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.green  { background: var(--primary); }
.status-dot.orange { background: var(--secondary); }
.status-dot.gray   { background: var(--text-subtle); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-body);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.row-inactive td { opacity: .5; }

.table-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 0 !important;
  font-style: italic;
}

.table-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.search-input, .select-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px; font-family: var(--font);
  color: var(--text-body);
  background: var(--bg-white);
  outline: none;
}
.search-input:focus, .select-input:focus { border-color: var(--primary); }
.select-input-sm { padding: 4px 6px; font-size: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font); background: var(--bg-white); }

.table-pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; font-size: 12px; }

/* ── Score Badge ──────────────────────────────────────────── */
.score-badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.score-hot   { background: #FEE2E2; color: #DC2626; }
.score-warm  { background: var(--secondary-light); color: var(--secondary); }
.score-cold  { background: var(--bg-hover); color: var(--text-muted); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 12px; font-weight: 600; color: var(--text-body); margin-bottom: 6px; }
.form-input  {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px; font-family: var(--font);
  color: var(--text-heading);
  background: var(--bg-white);
  transition: border-color .15s;
  outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(54,183,107,.1); }
.form-hint   { color: var(--text-subtle); font-weight: 400; margin-left: 4px; }
.form-hint-link { color: var(--primary); text-decoration: none; font-size: 11px; margin-left: 6px; }
.form-hint-link:hover { text-decoration: underline; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  margin-bottom: 16px;
}
.alert-success { background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--primary); }
.alert-danger  { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }

/* ── Conversion Types ─────────────────────────────────────── */
.conversion-types {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.conv-type-card {
  flex: 1; min-width: 140px;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-app);
}
.conv-type-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.conv-type-label { font-size: 11px; color: var(--text-muted); }
.conv-type-value { font-size: 22px; font-weight: 700; color: var(--text-heading); }

/* ── Funnel ───────────────────────────────────────────────── */
.funnel-wrapper { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.funnel-stage   { display: flex; align-items: center; gap: 12px; }
.funnel-bar {
  height: 28px;
  width: var(--pct, 100%);
  background: var(--color, var(--primary));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  opacity: .85;
  transition: width .6s ease-out;
}
.funnel-label { display: flex; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; }
.funnel-name  { color: var(--text-muted); }
.funnel-val   { font-weight: 700; color: var(--text-heading); }

/* ── Admin / Users ────────────────────────────────────────── */
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-avatar-sm {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--mebbi);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

.role-badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.role-admin   { background: var(--mebbi-light); color: var(--mebbi); }
.role-visitor { background: var(--bg-hover); color: var(--text-muted); }

.status-pill {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.pill-active   { background: var(--primary-light); color: var(--primary-dark); }
.pill-inactive { background: #FEF2F2; color: #EF4444; }

.badge-you {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
}

.action-btns { display: flex; align-items: center; gap: 4px; }

.roles-comparison {
  display: flex; gap: 20px; flex-wrap: wrap;
}
.role-info { flex: 1; min-width: 200px; }
.role-info h4 { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: var(--text-heading); }
.role-info ul { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-body); }

/* ── Settings ─────────────────────────────────────────────── */
.settings-service-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.settings-service-icon svg { width: 20px; height: 20px; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }

.settings-form { }
.settings-actions { display: flex; align-items: center; gap: 10px; }

.api-status { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; margin-left: auto; }
.api-status .status-dot { margin-right: 2px; }

.api-test-result { margin-top: 10px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  place-items: center;
}
.modal-overlay.open { display: grid; }

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 460px;
  max-width: 95vw;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  animation: fadeInUp .3s ease-out;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text-heading); }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); border-radius: var(--radius-sm); padding: 2px 6px; }
.modal-close:hover { background: var(--bg-hover); }
.modal-form { }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ── AI Panel ─────────────────────────────────────────────── */
.ai-panel {
  width: var(--ai-w);
  min-width: var(--ai-w);
  background: var(--bg-white);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInR .4s ease-out;
}

.ai-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.ai-header-left { display: flex; align-items: center; gap: 8px; }
.ai-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-md);
  background: var(--mebbi-light);
  color: var(--mebbi);
  display: flex; align-items: center; justify-content: center;
}
.ai-icon svg { width: 16px; height: 16px; fill: currentColor; }
.ai-panel-title { font-size: 14px; font-weight: 700; color: var(--text-heading); }

.ai-clear-btn {
  width: 28px; height: 28px;
  border: none; background: none; cursor: pointer;
  border-radius: var(--radius-sm); color: var(--text-subtle);
  display: flex; align-items: center; justify-content: center;
}
.ai-clear-btn:hover { background: var(--bg-hover); color: var(--text-muted); }
.ai-clear-btn svg { width: 16px; height: 16px; fill: currentColor; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}

.ai-message {
  display: flex;
  gap: 8px;
  animation: fadeInUp .3s ease-out;
}

.ai-msg-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.ai-message.user .ai-msg-avatar { background: var(--bg-hover); color: var(--text-muted); }
.ai-message.assistant .ai-msg-avatar { background: var(--mebbi); color: #fff; }

.ai-msg-bubble {
  flex: 1; min-width: 0;
  padding: 10px 12px;
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  font-size: 13px; line-height: 1.55;
}
.ai-message.user .ai-msg-bubble {
  background: var(--primary-light);
  color: var(--text-heading);
  border-radius: var(--radius-md) 0 var(--radius-md) var(--radius-md);
}
.ai-message.assistant .ai-msg-bubble {
  background: var(--bg-app);
  border: 1px solid var(--border);
  color: var(--text-body);
}
.ai-msg-bubble p { margin-bottom: 8px; }
.ai-msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg-bubble strong { color: var(--text-heading); font-weight: 600; }
.ai-msg-bubble ul { padding-left: 16px; margin-top: 4px; }
.ai-msg-bubble li { margin-bottom: 3px; }

/* Typing indicator */
.ai-typing-dots {
  display: flex; gap: 4px; padding: 4px 0;
}
.ai-typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-subtle);
  animation: pulse 1.2s ease-in-out infinite;
}
.ai-typing-dots span:nth-child(2) { animation-delay: .2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: .4s; }

/* AI Suggestion Buttons */
.ai-suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ai-suggest-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s;
  width: 100%;
}
.ai-suggest-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.ai-suggest-btn svg { width: 14px; height: 14px; fill: var(--primary); flex-shrink: 0; }
.ai-suggest-btn span { display: block; font-size: 12px; font-weight: 600; color: var(--text-heading); }
.ai-suggest-btn small { display: block; font-size: 10px; color: var(--text-muted); }

/* AI Input */
.ai-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-input-wrapper {
  display: flex; align-items: flex-end; gap: 8px;
}
#aiInput {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 13px; font-family: var(--font);
  color: var(--text-heading);
  resize: none; outline: none;
  min-height: 38px; max-height: 120px;
  line-height: 1.5;
  transition: border-color .15s;
}
#aiInput:focus { border-color: var(--primary); }

.ai-send-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s;
}
.ai-send-btn:hover { opacity: .85; }
.ai-send-btn:disabled { opacity: .5; cursor: not-allowed; }
.ai-send-btn svg { width: 16px; height: 16px; fill: #fff; }

.ai-disclaimer { font-size: 10px; color: var(--text-subtle); margin-top: 6px; text-align: center; }

/* ── Login Page ───────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--mebbi) 0%, #2a0d4f 100%); }

.login-wrapper { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}

.login-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.login-logo-img { height: 48px; width: auto; }

.login-title { font-size: 22px; font-weight: 700; color: var(--text-heading); text-align: center; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 24px; }
.login-form { margin-top: 20px; }
.login-hint { font-size: 11px; color: var(--text-subtle); text-align: center; margin-top: 16px; line-height: 1.5; }

/* ── Text helpers ─────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.text-green { color: var(--primary); font-weight: 600; }
.text-orange{ color: var(--secondary); font-weight: 600; }
.text-red   { color: #EF4444; font-weight: 600; }

/* ── Markdown-like in AI ──────────────────────────────────── */
.ai-msg-bubble code {
  background: var(--bg-hover);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}

/* ── Not Configured Banner ────────────────────────────────── */
.not-configured-banner {
  background: #EFF6FF;
  border: 1px solid #93C5FD;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 12px;
  color: #1E40AF;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.not-configured-banner a { color: #1D4ED8; font-weight: 600; }

/* ── Demo Banner ──────────────────────────────────────────── */
.demo-banner {
  background: var(--secondary-light);
  border: 1px solid var(--secondary);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 12px;
  color: #92400E;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ── Conversation Modal ────────────────────────────────────── */
.conv-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.conv-modal-overlay.open { display: flex; }

.conv-modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
  width: 100%; max-width: 720px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.conv-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.conv-modal-title { font-size: 18px; font-weight: 700; color: var(--text-heading); }
.conv-modal-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.conv-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: 6px;
  display: flex; align-items: center; flex-shrink: 0;
}
.conv-modal-close:hover { background: var(--bg-hover); color: var(--text-body); }
.conv-modal-close svg { width: 20px; height: 20px; fill: currentColor; }

.conv-metrics {
  display: flex; gap: 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-app);
}
.conv-metric {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px;
  border-right: 1px solid var(--border);
  flex: 1; min-width: 120px;
}
.conv-metric:last-child { border-right: none; }
.conv-metric-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.conv-metric-val   { font-size: 13px; font-weight: 600; color: var(--text-heading); }

.conv-messages {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 12px;
  background: #F6F8FA;
}
.conv-loading {
  text-align: center; color: var(--text-muted);
  font-size: 13px; padding: 40px 0;
}

.chat-msg        { display: flex; }
.chat-msg-in     { justify-content: flex-start; }
.chat-msg-out    { justify-content: flex-end; }

.chat-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-msg-in  .chat-bubble {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg-out .chat-bubble {
  background: var(--mebbi);
  border-bottom-right-radius: 4px;
}

.chat-sender {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
}
.chat-msg-in  .chat-sender { color: var(--mebbi); }
.chat-msg-out .chat-sender { color: rgba(255,255,255,.75); }

.chat-text { font-size: 13px; line-height: 1.5; word-break: break-word; }
.chat-msg-in  .chat-text { color: var(--text-body); }
.chat-msg-out .chat-text { color: #fff; }

.chat-time { font-size: 10px; text-align: right; }
.chat-msg-in  .chat-time { color: var(--text-subtle); }
.chat-msg-out .chat-time { color: rgba(255,255,255,.6); }

.conv-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
  background: var(--bg-white);
}

/* ── Channel badge ────────────────────────────────────────── */
.channel-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,.06);
  color: #374151;
  border: 1px solid rgba(0,0,0,.1);
  white-space: nowrap;
}

/* ── Contactado ───────────────────────────────────────────── */
.contacted-yes { color: #36B76B; font-weight: 600; font-size: 13px; }
.contacted-no  { color: #9CA3AF; font-weight: 500; font-size: 13px; }

/* ── Text subtle ──────────────────────────────────────────── */
.text-subtle   { color: var(--text-subtle); font-size: 11px; }

/* "Ver conversa" button in table */
.conv-btn {
  background: var(--mebbi-light);
  color: var(--mebbi);
  border: 1px solid rgba(82,23,125,.2);
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.conv-btn:hover { background: var(--mebbi); color: #fff; }
.conv-btn svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }
