/* ============================================================
   Aripel Atendimento — Design System v2
   Paleta: Azul Royal · Azul Água · Verde Floresta · Verde Limão
   ============================================================ */

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-royal:    #1d4ed8;
  --brand-sky:      #0ea5e9;
  --brand-aqua:     #06b6d4;
  --brand-forest:   #15803d;
  --brand-lime:     #65a30d;
  --brand-mint:     #10b981;

  /* Derived */
  --color-brand:    var(--brand-sky);
  --color-primary:  var(--brand-royal);
  --color-success:  var(--brand-mint);
  --color-warning:  #f59e0b;
  --color-danger:   #ef4444;
  --color-info:     var(--brand-aqua);

  /* Neutral scale */
  --n-50:   #f8fafc;
  --n-100:  #f1f5f9;
  --n-200:  #e2e8f0;
  --n-300:  #cbd5e1;
  --n-400:  #94a3b8;
  --n-500:  #64748b;
  --n-600:  #475569;
  --n-700:  #334155;
  --n-800:  #1e293b;
  --n-900:  #0f172a;
  --n-950:  #020617;

  /* Surfaces (light) */
  --bg-base:        #f1f5f9;
  --bg-surface:     #ffffff;
  --bg-elevated:    #ffffff;
  --bg-overlay:     rgba(15,23,42,.5);
  --border:         #e2e8f0;
  --border-focus:   var(--color-brand);

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  /* Sidebar */
  --sidebar-bg:     #0f172a;
  --sidebar-border: rgba(255,255,255,.07);
  --sidebar-text:   #94a3b8;
  --sidebar-hover:  rgba(255,255,255,.06);
  --sidebar-active-bg: rgba(14,165,233,.12);
  --sidebar-active-text: #e0f2fe;
  --sidebar-active-border: var(--brand-sky);

  /* Sizes */
  --sidebar-w:  240px;
  --header-h:   56px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.12), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl:  0 25px 50px rgba(0,0,0,.15);

  /* Transitions */
  --t-fast:  100ms ease;
  --t:       160ms ease;
  --t-slow:  260ms ease;

  /* Typography */
  --font:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

/* ── Dark mode ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-base:      #0f172a;
  --bg-surface:   #1e293b;
  --bg-elevated:  #273344;
  --border:       #2a3a50;
  --text-primary: #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:   #64748b;
  --n-100:        #1e293b;
  --n-200:        #2a3a50;
}

/* ── Reset ─────────────────────────────────────────────────── */
.aripel-body, .aripel-body * { box-sizing: border-box; margin: 0; padding: 0; }
.aripel-body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

/* ── App shell ─────────────────────────────────────────────── */
#ar-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ───────────────────────────────────────────────── */
#ar-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--sidebar-border);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
#ar-sidebar::-webkit-scrollbar { width: 4px; }
#ar-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.ar-sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ar-sidebar-brand-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--brand-sky), var(--brand-royal));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ar-sidebar-brand-logo svg { width: 18px; height: 18px; color: #fff; }
.ar-sidebar-brand-name { font-size: 14px; font-weight: 700; color: #f1f5f9; }
.ar-sidebar-brand-sub  { font-size: 10px; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: .6px; }

.ar-nav { flex: 1; padding: 8px 0; }
.ar-nav-label {
  padding: 10px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #475569;
}
.ar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--t), color var(--t);
  font-size: 13.5px;
  font-weight: 400;
  border-left-width: 0;
  position: relative;
}
.ar-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.ar-nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.ar-nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 500;
}
.ar-nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px; top: 0; bottom: 0;
  width: 3px;
  background: var(--sidebar-active-border);
  border-radius: 0 2px 2px 0;
}
.ar-nav-item.active svg { opacity: 1; }

.ar-nav-badge {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

.ar-sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.ar-user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t);
}
.ar-user-chip:hover { background: var(--sidebar-hover); }
.ar-user-chip-info { flex: 1; min-width: 0; }
.ar-user-chip-name  { color: #e2e8f0; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-user-chip-role  { color: #64748b; font-size: 11px; }

/* ── Main content ──────────────────────────────────────────── */
#ar-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
#ar-content { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
#ar-content.chat-view { overflow: hidden; display: flex; flex-direction: column; }
/* ── Topbar ────────────────────────────────────────────────── */
#ar-topbar {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}
.ar-topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.ar-topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ── Page content ──────────────────────────────────────────── */
#ar-content.chat-view { overflow: hidden; display: flex; flex-direction: column; }
.ar-page { padding: 24px; max-width: 100%; }
.ar-page-full { padding: 0; flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

/* ── Avatar ────────────────────────────────────────────────── */
.ar-avatar {
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-sky), var(--brand-royal));
  font-size: calc(var(--av-size, 36px) * .38);
  width: var(--av-size, 36px);
  height: var(--av-size, 36px);
}
.ar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ar-avatar-24 { --av-size: 24px; }
.ar-avatar-32 { --av-size: 32px; }
.ar-avatar-40 { --av-size: 40px; }
.ar-avatar-48 { --av-size: 48px; }
.ar-avatar-56 { --av-size: 56px; }
.ar-avatar-80 { --av-size: 80px; }

/* ── Buttons ───────────────────────────────────────────────── */
.ar-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  font-size: 13.5px; font-weight: 500; font-family: var(--font);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t), border-color var(--t), box-shadow var(--t), opacity var(--t);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  user-select: none;
}
.ar-btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.ar-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.ar-btn-sm { padding: 5px 11px; font-size: 12.5px; }
.ar-btn-lg { padding: 11px 22px; font-size: 15px; }
.ar-btn-icon { padding: 7px; border-radius: var(--radius-sm); }
.ar-btn-icon-sm { padding: 5px; border-radius: var(--radius-sm); }

.ar-btn-primary {
  background: var(--color-primary); color: #fff; border-color: var(--color-primary);
  box-shadow: 0 1px 2px rgba(29,78,216,.3);
}
.ar-btn-primary:hover { background: #1e40af; border-color: #1e40af; color: #fff; }

.ar-btn-brand {
  background: linear-gradient(135deg, var(--brand-sky), var(--brand-royal));
  color: #fff; border: none;
  box-shadow: 0 1px 3px rgba(14,165,233,.4);
}
.ar-btn-brand:hover { box-shadow: 0 4px 12px rgba(14,165,233,.4); transform: translateY(-1px); color: #fff; }

.ar-btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.ar-btn-danger  { background: var(--color-danger);  color: #fff; border-color: var(--color-danger); }
.ar-btn-warning { background: var(--color-warning); color: #fff; border-color: var(--color-warning); }

.ar-btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.ar-btn-outline:hover { background: var(--n-100); color: var(--text-primary); }

.ar-btn-ghost {
  background: transparent; border-color: transparent; color: var(--text-secondary);
}
.ar-btn-ghost:hover { background: var(--n-100); color: var(--text-primary); }

.ar-btn-danger-ghost { background: transparent; border-color: transparent; color: var(--color-danger); }
.ar-btn-danger-ghost:hover { background: #fef2f2; }

/* ── Cards ─────────────────────────────────────────────────── */
.ar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.ar-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.ar-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); flex: 1; }
.ar-card-body  { padding: 20px; }
.ar-card-footer { padding: 14px 20px; border-top: 1px solid var(--border); }

/* ── Forms ─────────────────────────────────────────────────── */
.ar-field { margin-bottom: 16px; }
.ar-label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 5px;
}
.ar-label .req { color: var(--color-danger); margin-left: 2px; }

.ar-input, .ar-select, .ar-textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}
.ar-input:focus, .ar-select:focus, .ar-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.ar-input.error { border-color: var(--color-danger); }
.ar-textarea { resize: vertical; min-height: 88px; }
.ar-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.ar-field-error { font-size: 11.5px; color: var(--color-danger); margin-top: 4px; }

/* ── Badges ────────────────────────────────────────────────── */
.ar-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.ar-badge-blue    { background: #dbeafe; color: #1d4ed8; }
.ar-badge-sky     { background: #e0f2fe; color: #0369a1; }
.ar-badge-green   { background: #dcfce7; color: #15803d; }
.ar-badge-lime    { background: #ecfccb; color: #4d7c0f; }
.ar-badge-yellow  { background: #fef9c3; color: #a16207; }
.ar-badge-red     { background: #fee2e2; color: #b91c1c; }
.ar-badge-purple  { background: #ede9fe; color: #6d28d9; }
.ar-badge-gray    { background: var(--n-100); color: var(--n-600); }
.ar-badge-outline { background: transparent; border: 1px solid currentColor; }

.ar-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ar-dot-green  { background: #22c55e; }
.ar-dot-red    { background: #ef4444; }
.ar-dot-yellow { background: #eab308; }
.ar-dot-blue   { background: var(--brand-sky); }
.ar-dot-gray   { background: var(--n-400); }

/* ── Table ─────────────────────────────────────────────────── */
.ar-table-wrap { overflow-x: auto; }
.ar-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ar-table th {
  padding: 10px 16px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); background: var(--n-50);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ar-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--n-100);
  color: var(--text-secondary); vertical-align: middle;
}
.ar-table tr:last-child td { border-bottom: none; }
.ar-table tbody tr { transition: background var(--t-fast); }
.ar-table tbody tr:hover td { background: var(--n-50); }

/* ── Modal ─────────────────────────────────────────────────── */
.ar-modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000; padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-slow);
  backdrop-filter: blur(4px);
}
.ar-modal-overlay.open { opacity: 1; pointer-events: all; }
.ar-modal {
  background: var(--bg-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); width: 100%; max-height: 92vh;
  display: flex; flex-direction: column;
  transform: scale(.96) translateY(8px);
  transition: transform var(--t-slow);
}
.ar-modal-overlay.open .ar-modal { transform: scale(1) translateY(0); }
.ar-modal-sm { max-width: 440px; }
.ar-modal-md { max-width: 600px; }
.ar-modal-lg { max-width: 820px; }
.ar-modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.ar-modal-title { font-size: 15px; font-weight: 600; flex: 1; }
.ar-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 5px; border-radius: var(--radius-sm);
  display: flex; align-items: center; transition: color var(--t), background var(--t);
}
.ar-modal-close:hover { color: var(--text-primary); background: var(--n-100); }
.ar-modal-close svg { width: 18px; height: 18px; }
.ar-modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.ar-modal-footer {
  padding: 16px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0;
}

/* ── Toasts ────────────────────────────────────────────────── */
#ar-toasts {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 99999; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.ar-toast {
  background: var(--n-900); color: #fff;
  padding: 11px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 13.5px;
  display: flex; align-items: center; gap: 9px;
  min-width: 240px; max-width: 380px;
  pointer-events: all;
  animation: arToastIn .22s cubic-bezier(.34,1.56,.64,1);
  border-left: 3px solid var(--border);
}
.ar-toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.ar-toast-success { border-left-color: var(--color-success); }
.ar-toast-error   { border-left-color: var(--color-danger); }
.ar-toast-warning { border-left-color: var(--color-warning); }
.ar-toast-info    { border-left-color: var(--brand-sky); }
@keyframes arToastIn { from { opacity: 0; transform: translateX(20px) scale(.95); } }

/* ── Loading / Spinner ─────────────────────────────────────── */
.ar-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--n-200);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: arSpin .65s linear infinite;
  display: inline-block; flex-shrink: 0;
}
.ar-spinner-sm  { width: 14px; height: 14px; border-width: 2px; }
.ar-spinner-lg  { width: 32px; height: 32px; border-width: 3px; }
.ar-spinner-white { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
@keyframes arSpin { to { transform: rotate(360deg); } }

.ar-skeleton {
  background: linear-gradient(90deg, var(--n-100) 25%, var(--n-200) 50%, var(--n-100) 75%);
  background-size: 200% 100%;
  animation: arSkeleton 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes arSkeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Alerts ────────────────────────────────────────────────── */
.ar-alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px; margin-bottom: 16px;
  border: 1px solid transparent;
}
.ar-alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.ar-alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.ar-alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.ar-alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.ar-alert-info    { background: #f0f9ff; color: #075985; border-color: #bae6fd; }

/* ── Empty state ───────────────────────────────────────────── */
.ar-empty {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.ar-empty-icon { color: var(--n-300); }
.ar-empty-icon svg { width: 48px; height: 48px; }
.ar-empty h3 { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.ar-empty p  { font-size: 13.5px; max-width: 320px; }

/* ── Stats ─────────────────────────────────────────────────── */
.ar-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.ar-stat-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: box-shadow var(--t);
}
.ar-stat-card:hover { box-shadow: var(--shadow-md); }
.ar-stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ar-stat-icon svg { width: 22px; height: 22px; }
.ar-stat-icon-blue   { background: #dbeafe; color: var(--brand-royal); }
.ar-stat-icon-sky    { background: #e0f2fe; color: #0369a1; }
.ar-stat-icon-green  { background: #dcfce7; color: var(--brand-forest); }
.ar-stat-icon-lime   { background: #ecfccb; color: var(--brand-lime); }
.ar-stat-icon-yellow { background: #fef9c3; color: #a16207; }
.ar-stat-icon-red    { background: #fee2e2; color: #b91c1c; }
.ar-stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.ar-stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ════════════════════════════════════════════════════════════
   CHAT INTERFACE
   ════════════════════════════════════════════════════════════ */

.ar-chat-shell { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* Conversation list */
.ar-conv-list {
  width: 320px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex; flex-direction: column;
}
.ar-conv-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.ar-conv-list-header h3 { font-size: 15px; font-weight: 700; flex: 1; }

.ar-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ar-search {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; background: var(--bg-base);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 11px center;
  outline: none; transition: border-color var(--t);
}
.ar-search:focus { border-color: var(--border-focus); background-color: var(--bg-surface); }

.ar-conv-filters {
  padding: 8px 12px;
  display: flex; gap: 6px;
  border-bottom: 1px solid var(--n-100);
  overflow-x: auto; flex-shrink: 0;
}
.ar-conv-filter {
  padding: 4px 12px; border-radius: 16px; border: 1px solid var(--border);
  background: transparent; font-size: 12px; cursor: pointer;
  color: var(--text-secondary); white-space: nowrap;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.ar-conv-filter.active {
  background: var(--color-primary); border-color: var(--color-primary); color: #fff;
}

.ar-conv-items { flex: 1; overflow-y: auto; }
.ar-conv-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; cursor: pointer;
  border-bottom: 1px solid var(--n-50);
  transition: background var(--t-fast);
  position: relative;
}
.ar-conv-item:hover   { background: var(--n-50); }
.ar-conv-item.active  { background: #eff6ff; border-right: 2px solid var(--color-primary); }
.ar-conv-item-body    { flex: 1; min-width: 0; }
.ar-conv-item-top     { display: flex; justify-content: space-between; align-items: center; }
.ar-conv-item-name    { font-size: 13.5px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.ar-conv-item-time    { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.ar-conv-item-bottom  { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.ar-conv-item-preview { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.ar-conv-unread {
  background: var(--brand-mint); color: #fff;
  font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* Chat area */
.ar-chat-area {
  flex: 1; display: flex; flex-direction: column;
  background: #f8fafc; min-width: 0;
  overflow: hidden;
}
.ar-chat-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-muted);
}
.ar-chat-placeholder svg { width: 64px; height: 64px; color: var(--n-300); }
.ar-chat-placeholder p { font-size: 15px; }

.ar-chat-header {
  background: var(--bg-surface); padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 11px;
  flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.ar-chat-header-info { flex: 1; min-width: 0; }
.ar-chat-header-name { font-size: 14px; font-weight: 600; }
.ar-chat-header-sub  { font-size: 12px; color: var(--text-muted); }
.ar-chat-header-actions { display: flex; gap: 6px; align-items: center; }

/* Messages */
.ar-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 3px;
  min-height: 0;
}
.ar-messages::-webkit-scrollbar { width: 4px; }
.ar-messages::-webkit-scrollbar-thumb { background: var(--n-200); border-radius: 4px; }

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

.ar-msg-bubble {
  max-width: 68%; padding: 7px 12px 5px;
  border-radius: 12px; font-size: 13.5px; line-height: 1.45;
  position: relative; word-break: break-word;
}
.ar-msg-in  .ar-msg-bubble { background: #fff; color: var(--text-primary); border-top-left-radius: 3px; box-shadow: var(--shadow-sm); }
.ar-msg-out .ar-msg-bubble { background: linear-gradient(135deg,#d1fae5,#a7f3d0); color: #064e3b; border-top-right-radius: 3px; }
.ar-msg-sys { justify-content: center; }
.ar-msg-sys .ar-msg-bubble { background: rgba(0,0,0,.05); color: var(--text-muted); font-size: 11.5px; text-align: center; border-radius: 12px; max-width: 80%; }

.ar-msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 3px; }
.ar-msg-time { font-size: 10px; color: rgba(0,0,0,.35); }
.ar-msg-status { font-size: 11px; }
.ar-msg-status.read { color: var(--brand-sky); }
.ar-msg-status.delivered { color: var(--n-400); }

/* Media in messages */
.ar-msg-img { max-width: 260px; border-radius: 8px; cursor: pointer; display: block; }
.ar-msg-video { max-width: 280px; border-radius: 8px; }
.ar-msg-audio { width: 220px; }
.ar-msg-doc {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  background: rgba(0,0,0,.05); border-radius: 8px; cursor: pointer;
  text-decoration: none; color: inherit;
}
.ar-msg-doc-name { font-size: 12.5px; font-weight: 500; }
.ar-msg-doc-size { font-size: 11px; color: var(--text-muted); }

/* Quoted message */
.ar-msg-quoted {
  border-left: 3px solid var(--brand-sky);
  padding: 4px 8px; border-radius: 4px;
  background: rgba(0,0,0,.05); margin-bottom: 6px;
  font-size: 12px; color: var(--text-muted);
}

/* Input area */
.ar-chat-input-area {
  background: var(--bg-surface); border-top: 1px solid var(--border);
  padding: 10px 14px; display: flex; align-items: flex-end; gap: 8px;
  flex-shrink: 0;
}
.ar-chat-input-wrap {
  flex: 1; background: var(--bg-base); border: 1px solid var(--border);
  border-radius: 22px; display: flex; align-items: flex-end;
  padding: 7px 14px; gap: 8px; transition: border-color var(--t);
}
.ar-chat-input-wrap:focus-within { border-color: var(--border-focus); }
.ar-chat-textarea {
  flex: 1; border: none; background: transparent; font-family: var(--font);
  font-size: 14px; resize: none; max-height: 120px; overflow-y: auto;
  color: var(--text-primary); outline: none; line-height: 1.45;
}
.ar-chat-textarea::placeholder { color: var(--text-muted); }
.ar-chat-action-btn {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 3px; display: flex; align-items: center; transition: color var(--t);
}
.ar-chat-action-btn:hover { color: var(--color-brand); }
.ar-chat-action-btn svg { width: 20px; height: 20px; }
.ar-chat-send {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-sky), var(--brand-royal));
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: 0 2px 8px rgba(14,165,233,.4);
  transition: transform var(--t), box-shadow var(--t);
  flex-shrink: 0;
}
.ar-chat-send:hover { transform: scale(1.08); box-shadow: 0 4px 14px rgba(14,165,233,.5); }
.ar-chat-send svg { width: 18px; height: 18px; }

/* Quick replies dropdown */
.ar-quick-dropdown {
  position: absolute; bottom: 100%; left: 0; right: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 200px; overflow-y: auto; z-index: 100;
}
.ar-quick-item {
  padding: 9px 14px; cursor: pointer; display: flex; gap: 10px;
  border-bottom: 1px solid var(--n-100); transition: background var(--t-fast);
}
.ar-quick-item:hover { background: var(--n-50); }
.ar-quick-shortcut { font-size: 12px; color: var(--brand-sky); font-weight: 600; flex-shrink: 0; }
.ar-quick-title    { font-size: 13px; color: var(--text-primary); }

/* Contact info panel */
.ar-contact-panel {
  width: 280px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-surface); overflow-y: auto;
  display: none;
}
.ar-contact-panel.open { display: block; }
.ar-contact-panel-head { text-align: center; padding: 24px 16px 16px; border-bottom: 1px solid var(--n-100); }
.ar-contact-panel-name { font-size: 16px; font-weight: 700; margin-top: 10px; }
.ar-contact-panel-phone { font-size: 12.5px; color: var(--text-muted); }
.ar-contact-info { padding: 16px; }
.ar-contact-info-row { margin-bottom: 14px; }
.ar-contact-info-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 3px; }
.ar-contact-info-value { font-size: 13.5px; color: var(--text-primary); }

/* ════════════════════════════════════════════════════════════
   WIZARD / SETUP
   ════════════════════════════════════════════════════════════ */

.ar-wizard-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px; background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f2240 100%);
}
.ar-wizard-box {
  background: var(--bg-surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 580px; overflow: hidden;
}
.ar-wizard-header {
  padding: 28px 32px;
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
  display: flex; align-items: center; gap: 16px;
}
.ar-wizard-logo {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--brand-sky), var(--brand-royal));
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
}
.ar-wizard-logo svg { width: 26px; height: 26px; color: #fff; }
.ar-wizard-header h1 { font-size: 20px; font-weight: 700; color: #fff; }
.ar-wizard-header p  { font-size: 13px; color: var(--n-400); margin-top: 2px; }

.ar-wizard-progress { padding: 0 32px 20px; background: linear-gradient(135deg, #0f172a, #1e3a5f); }
.ar-progress-bar { height: 4px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.ar-progress-fill { height: 100%; background: linear-gradient(90deg, var(--brand-sky), var(--brand-mint)); border-radius: 4px; transition: width .4s ease; }
.ar-progress-info { display: flex; justify-content: space-between; font-size: 11px; color: var(--n-500); margin-top: 6px; }

.ar-wizard-body { padding: 32px; }
.ar-wizard-step { display: none; }
.ar-wizard-step.active { display: block; }
.ar-wizard-step-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.ar-wizard-step-desc  { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }

.ar-wizard-footer {
  padding: 20px 32px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}

.ar-check-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ar-check-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 13.5px;
}
.ar-check-item.ok    { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.ar-check-item.fail  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.ar-check-item.pending { background: var(--n-50); color: var(--text-muted); }
.ar-check-item svg   { width: 16px; height: 16px; flex-shrink: 0; }

.ar-qr-frame {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; background: var(--n-50);
}
.ar-qr-frame img { max-width: 200px; border-radius: 8px; margin: 0 auto; display: block; }

/* ── Login page ─────────────────────────────────────────────── */
.ar-login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0c2240 100%);
  padding: 20px;
}
.ar-login-box {
  background: var(--bg-surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 400px; padding: 40px 36px;
}
.ar-login-logo { text-align: center; margin-bottom: 28px; }
.ar-login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--brand-sky), var(--brand-royal));
  border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.ar-login-logo-icon svg { width: 30px; height: 30px; color: #fff; }
.ar-login-logo h2 { font-size: 22px; font-weight: 700; }
.ar-login-logo p  { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ── Utilities ──────────────────────────────────────────────── */
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4  { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-xs  { font-size: 11.5px; }
.text-sm  { font-size: 12.5px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden   { display: none !important; }
.relative { position: relative; }
.w-full   { width: 100%; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; } .p-24 { padding: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }

/* ── Sidebar colapsável ─────────────────────────────────────── */
#ar-sidebar {
  transition: width var(--t-slow), min-width var(--t-slow);
}
#ar-shell.sidebar-collapsed #ar-sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
}
#ar-shell.sidebar-collapsed #ar-main {
  width: 100%;
}

/* Botão toggle fixo no topbar */
#ar-sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}
#ar-sidebar-toggle:hover { background: var(--n-100); color: var(--text-primary); }
#ar-sidebar-toggle svg  { width: 18px; height: 18px; }

/* ── Message status indicators (WhatsApp style) ──────────── */
.ar-msg-status          { font-size: 12px; margin-left: 4px; }
.ar-msg-status.pending  { color: var(--text-muted); }
.ar-msg-status.sent     { color: var(--text-muted); }
.ar-msg-status.delivered{ color: var(--n-400); }
.ar-msg-status.read     { color: var(--brand-sky); }

/* ── Sidebar submenu ─────────────────────────────────────── */
.ar-nav-submenu {
  margin: 2px 8px 6px 32px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ar-nav-sub-item {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.ar-nav-sub-item:hover  { background: var(--sidebar-hover); color: #e2e8f0; }
.ar-nav-sub-item.active { background: rgba(14,165,233,.1); color: #e0f2fe; font-weight: 500; }

/* ── Conversation list improvements ─────────────────────── */
.ar-conv-item-agent {
  font-size: 10px;
  color: var(--brand-sky);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ar-conv-item-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.ar-conv-group-icon {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Chat header improvements ────────────────────────────── */
.ar-chat-header-type {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
  background: var(--n-100);
  padding: 1px 6px;
  border-radius: 8px;
}

/* ── Audio player custom ─────────────────────────────────── */
.ar-msg-audio {
  width: 240px;
  height: 36px;
  border-radius: 18px;
  outline: none;
}
.ar-msg-audio::-webkit-media-controls-panel {
  background: rgba(0,0,0,.05);
  border-radius: 18px;
}

/* ── Document card ───────────────────────────────────────── */
.ar-msg-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0,0,0,.06);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  min-width: 200px;
  max-width: 280px;
}
.ar-msg-doc-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.ar-msg-doc-info { min-width: 0; }
.ar-msg-doc-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.ar-msg-doc-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Contact panel enriched ──────────────────────────────── */
.ar-cp-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--n-100);
  font-size: 13.5px;
}
.ar-cp-stat:last-child { border-bottom: none; }
.ar-cp-stat-label { color: var(--text-muted); font-size: 11px; min-width: 80px; }
.ar-cp-stat-val   { color: var(--text-primary); font-weight: 500; }
