/* ═══════════════════════════════════════════════════════════
   WhatsApp Center — Design System
   Paleta: Primário #6C5CE7 | Secundário #00B894
   Font: Inter
═══════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --primary: #6C5CE7;
  --primary-hover: #5a4bd1;
  --primary-light: rgba(108, 92, 231, 0.15);
  --secondary: #00B894;
  --secondary-hover: #00a381;
  --danger: #D63031;
  --warning: #FDCB6E;
  --info: #0984E3;
  --success: #00B894;

  --sidebar-width: 260px;
  --topbar-height: 64px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --transition: 0.2s ease;

  /* Dark theme (default) */
  --bg-body: #0f0e17;
  --bg-card: #1a1a2e;
  --bg-sidebar: #13131f;
  --bg-topbar: #16162a;
  --bg-input: #1e1e35;
  --bg-hover: rgba(108, 92, 231, 0.1);
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --border-color: rgba(255, 255, 255, 0.07);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] {
  --bg-body: #f0f2f8;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-topbar: #ffffff;
  --bg-input: #f8f9fe;
  --bg-hover: rgba(108, 92, 231, 0.06);
  --text-primary: #1a1a2e;
  --text-secondary: #555577;
  --text-muted: #9999bb;
  --border-color: rgba(0, 0, 0, 0.07);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ── Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg-body);
  color: var(--text-primary);
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Login ─────────────────────────────────────────────── */
.login-wrapper {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  min-height: 100vh;
}

.login-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.3) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(0, 184, 148, 0.2) 0%, transparent 50%),
              linear-gradient(135deg, #0f0e17 0%, #1a1432 50%, #0f1622 100%);
}

.login-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.04) 1px, transparent 0);
  background-size: 40px 40px;
}

.login-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px; padding: 1.5rem;
}

.glass-card {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(108,92,231,0.1);
}

.login-logo {
  text-align: center; margin-bottom: 2rem;
}

.logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 2rem; color: white;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(108, 92, 231, 0.4);
}

.login-logo h1 {
  font-size: 1.5rem; font-weight: 700;
  color: var(--text-primary); margin: 0;
}

.login-logo p {
  color: var(--text-secondary); font-size: 0.85rem; margin: 0.25rem 0 0;
}

.login-wrapper .form-control {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-radius: var(--border-radius-sm);
  height: 54px;
}

.login-wrapper .form-control:focus {
  background: rgba(108, 92, 231, 0.1);
  border-color: var(--primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

.login-wrapper .form-floating label {
  color: var(--text-secondary);
  padding-left: 0.875rem;
}

.btn-toggle-pwd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 4px; z-index: 10;
}

.btn-login {
  height: 52px; font-size: 1rem; font-weight: 600; border-radius: var(--border-radius-sm);
  background: linear-gradient(135deg, var(--primary) 0%, #8b7cf0 100%);
  border: none; letter-spacing: 0.3px;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.5);
  background: linear-gradient(135deg, var(--primary-hover) 0%, #7a6adf 100%);
}

.login-footer {
  text-align: center; margin-top: 1.5rem;
  color: var(--text-muted); font-size: 0.75rem;
}

.login-logo-image {
  width: 160px;
  height: auto;
  object-fit: contain;
  margin-bottom: 1rem;
}

/* ── App Shell ─────────────────────────────────────────── */
.app-shell {
  display: flex; height: 100vh; overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  transition: transform var(--transition), width var(--transition);
  z-index: 200;
  overflow: hidden;
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-image {
  width: 40px;
  height: auto;
  object-fit: contain;
  display: block;
}

.sidebar-title {
  font-size: 1.1rem; font-weight: 700; color: var(--text-primary);
}

.sidebar-nav {
  flex: 1; padding: 1rem 0.75rem; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  position: relative; font-weight: 500;
  font-size: 0.9rem;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute; left: -0.75rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-icon { width: 18px; text-align: center; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--danger); color: white;
  border-radius: 20px; padding: 1px 7px; font-size: 0.7rem; font-weight: 600;
  min-width: 20px; text-align: center;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.nav-divider {
  height: 1px; background: var(--border-color);
  margin: 0.75rem 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex; align-items: center; gap: 0.75rem;
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #8b7cf0);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: 0.85rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 0.75rem; color: var(--text-secondary); }

/* ── Botão colapso sidebar (desktop) ───────────────────── */
.sidebar-collapse-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
  font-size: 0.7rem;
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
  background: var(--primary); color: white; border-color: var(--primary);
}

/* ── Sidebar collapsed ─────────────────────────────────── */
.sidebar.collapsed {
  width: 68px;
  min-width: 68px;
}
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .user-details,
.sidebar.collapsed .nav-badge {
  display: none;
}
.sidebar.collapsed .sidebar-logo {
  justify-content: center;
}
.sidebar.collapsed .sidebar-header {
  padding: 1.25rem 0.75rem 1rem;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
}
.sidebar.collapsed .sidebar-collapse-btn {
  margin: 0 auto;
}
.sidebar.collapsed #sidebarCollapseIcon {
  transform: rotate(180deg);
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.625rem;
  gap: 0;
}
.sidebar.collapsed .nav-item span:not(.nav-icon):not(.nav-badge) {
  display: none;
}
.sidebar.collapsed .nav-icon {
  width: 20px; text-align: center;
}
.sidebar.collapsed .nav-divider {
  margin: 0.5rem 0.5rem;
}
.sidebar.collapsed .sidebar-footer {
  display: flex; justify-content: center; padding: 1rem 0.5rem;
}
.sidebar.collapsed .user-info {
  justify-content: center;
}
/* Tooltip nativo ao recolher */
.sidebar.collapsed .nav-item {
  position: relative;
}

/* ── Main Wrapper ──────────────────────────────────────── */
.main-wrapper {
  flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}

/* ── Topbar ────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; gap: 1rem;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
}

.topbar-left, .topbar-right {
  display: flex; align-items: center; gap: 0.75rem;
}

.breadcrumb-text {
  font-weight: 600; font-size: 1.05rem; color: var(--text-primary);
}

.btn-icon {
  width: 38px; height: 38px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  background: transparent; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition); position: relative;
}

.btn-icon:hover { background: var(--bg-hover); color: var(--primary); border-color: var(--primary); }

.topbar-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--danger); color: white;
  border-radius: 50%; width: 18px; height: 18px;
  font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.connection-status { display: flex; align-items: center; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  transition: background var(--transition);
}
.status-dot.connected { background: var(--secondary); box-shadow: 0 0 6px var(--secondary); }
.status-dot.disconnected { background: var(--text-muted); }

/* ── Tenant Selector ───────────────────────────────────── */
.tenant-selector { position: relative; }

.tenant-selector-btn {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 200px; max-width: 260px;
  transition: all var(--transition);
  text-align: left;
}
.tenant-selector-btn:hover,
.tenant-selector.open .tenant-selector-btn {
  border-color: var(--primary);
  background: var(--bg-hover);
}
.tenant-selector-icon {
  color: var(--primary); font-size: 0.85rem; flex-shrink: 0;
}
.tenant-selector-info {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0;
}
.tenant-selector-label {
  font-size: 0.8rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-primary);
}
.tenant-selector-cnpj {
  font-size: 0.7rem; color: var(--text-muted);
  white-space: nowrap;
}
.tenant-selector-chevron {
  font-size: 0.65rem; color: var(--text-muted);
  flex-shrink: 0; transition: transform var(--transition);
}
.tenant-selector.open .tenant-selector-chevron { transform: rotate(180deg); }

.tenant-selector-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  min-width: 280px; max-height: 320px;
  display: flex; flex-direction: column;
  z-index: 1050;
  animation: fadeIn 0.15s ease;
}
.tenant-selector-search {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.tenant-selector-search i { color: var(--text-muted); font-size: 0.8rem; flex-shrink: 0; }
.tenant-selector-search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 0.82rem;
}
.tenant-selector-search input::placeholder { color: var(--text-muted); }
.tenant-selector-items { overflow-y: auto; padding: 0.35rem 0; }
.tenant-selector-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  cursor: pointer; transition: background 0.15s;
}
.tenant-selector-item:hover { background: var(--bg-hover); }
.tenant-selector-item.active { background: var(--primary-light); }
.tenant-item-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: var(--primary);
}
.tenant-item-active .tenant-item-avatar { background: var(--primary); color: #fff; }
.tenant-item-info { flex: 1; min-width: 0; }
.tenant-item-name {
  font-size: 0.82rem; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tenant-item-cnpj { font-size: 0.72rem; color: var(--text-muted); }
.tenant-item-check { color: var(--primary); font-size: 0.8rem; }
.tenant-selector-empty {
  padding: 1rem; text-align: center;
  font-size: 0.82rem; color: var(--text-muted);
}

/* ── Page Content ──────────────────────────────────────── */
.page-content {
  flex: 1; overflow-y: auto; padding: 1.75rem;
  animation: fadeIn 0.3s ease;
}

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

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  font-weight: 600; color: var(--text-primary);
}

.card-body { padding: 1.25rem; }

/* ── KPI Cards ─────────────────────────────────────────── */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--kpi-color, var(--primary));
}

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--kpi-bg, var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; color: var(--kpi-color, var(--primary));
  margin-bottom: 0.875rem;
}

.kpi-value {
  font-size: 2rem; font-weight: 700; color: var(--text-primary);
  line-height: 1; margin-bottom: 0.25rem;
  transition: all 0.5s ease;
}

.kpi-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.kpi-subtitle { font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }

.kpi-trend {
  position: absolute; top: 1rem; right: 1rem;
  font-size: 0.75rem; font-weight: 600; padding: 2px 8px;
  border-radius: 20px;
}

.kpi-trend.up { background: rgba(0,184,148,0.15); color: var(--secondary); }
.kpi-trend.down { background: rgba(214,48,49,0.15); color: var(--danger); }

/* ── Skeleton Loading ──────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border-color) 25%, rgba(255,255,255,0.05) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--border-radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Form Controls ─────────────────────────────────────── */
.form-control, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition);
}

.form-control:focus, .form-select:focus {
  background: var(--bg-input);
  border-color: var(--primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.form-control::placeholder { color: var(--text-muted); }

.form-label { font-weight: 500; color: var(--text-primary); font-size: 0.85rem; margin-bottom: 0.4rem; }

.text-muted { color: var(--text-secondary) !important; }

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #8b7cf0);
  border: none; font-weight: 600; border-radius: var(--border-radius-sm);
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(108,92,231,0.3);
  color: #fff !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #7a6adf);
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(108,92,231,0.4);
}

.btn-success { background: var(--secondary); border-color: var(--secondary); }
.btn-success:hover { background: var(--secondary-hover); border-color: var(--secondary-hover); }

/* ── Status Badges ─────────────────────────────────────── */
.badge-waiting  { background: rgba(253,203,110,.15); color: var(--warning); border: 1px solid rgba(253,203,110,.3); }
.badge-bot      { background: rgba(108,92,231,.15); color: var(--primary); border: 1px solid rgba(108,92,231,.3); }
.badge-human    { background: rgba(9,132,227,.15); color: var(--info); border: 1px solid rgba(9,132,227,.3); }
.badge-closed   { background: rgba(99,110,114,.15); color: #636e72; border: 1px solid rgba(99,110,114,.3); }
.badge-integrated { background: rgba(0,184,148,.15);  color: var(--secondary); border: 1px solid rgba(0,184,148,.3); }
.badge-failed     { background: rgba(214,48,49,.15);   color: var(--danger);   border: 1px solid rgba(214,48,49,.3); }
.badge-integrated::before { animation: none; }
.badge-failed::before     { animation: none; }

.badge-status {
  padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
}

.badge-status::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s infinite;
}

.badge-closed::before { animation: none; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.8); }
}

/* ── WhatsApp Chat Bubbles ─────────────────────────────── */
.chat-container {
  height: 400px; overflow-y: auto;
  padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem;
  background: var(--bg-body); border-radius: var(--border-radius-sm);
}

.bubble {
  max-width: 75%; padding: 0.625rem 0.875rem;
  border-radius: 16px; position: relative;
}

.bubble-inbound {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.bubble-outbound {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), #7c6be0);
  color: white;
  border-bottom-right-radius: 4px;
}

.bubble-content { font-size: 0.875rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }

.bubble-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  margin-top: 3px; font-size: 0.7rem;
}

.bubble-inbound .bubble-meta { color: var(--text-muted); }
.bubble-outbound .bubble-meta { color: rgba(255,255,255,0.7); }

.bubble-sender {
  font-size: 0.72rem; font-weight: 600;
  margin-bottom: 2px; color: var(--primary);
}

.bubble-outbound .bubble-sender { color: rgba(255, 255, 255, 0.85); }
.bubble-bot .bubble-sender { color: var(--secondary); }

/* ── Queue Cards ───────────────────────────────────────── */
.queue-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  display: flex; align-items: center; gap: 1rem;
  transition: all var(--transition);
  cursor: pointer;
}

.queue-card:hover { border-color: var(--primary); transform: translateX(4px); }

.queue-position {
  width: 40px; height: 40px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; color: var(--primary);
  flex-shrink: 0;
}

.queue-info { flex: 1; min-width: 0; }
.queue-customer { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
.queue-phone { font-size: 0.8rem; color: var(--text-secondary); }
.queue-preview { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.queue-timer {
  font-size: 0.85rem; font-weight: 600;
  color: var(--warning);
  white-space: nowrap;
}

/* ── Agent Cards ───────────────────────────────────────── */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  transition: all var(--transition);
}

.agent-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.agent-avatar {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #8b7cf0);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; font-weight: 700; color: white;
  margin-bottom: 1rem;
}

.agent-name { font-weight: 700; font-size: 1rem; color: var(--text-primary); }
.agent-desc { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

.agent-stats {
  display: flex; gap: 1rem; margin-top: 1rem;
  padding-top: 1rem; border-top: 1px solid var(--border-color);
}

.agent-stat { text-align: center; flex: 1; }
.agent-stat-value { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.agent-stat-label { font-size: 0.7rem; color: var(--text-muted); }

.agent-load-bar {
  height: 4px; background: var(--border-color); border-radius: 2px; margin-top: 0.75rem; overflow: hidden;
}

.agent-load-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  transition: width 0.5s ease;
}

/* ── Tables ────────────────────────────────────────────── */
.table {
  color: var(--text-primary);
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255,255,255,0.02);
}

.table th {
  font-weight: 600; font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-secondary);
  border-color: var(--border-color); padding: 0.75rem 1rem;
  white-space: nowrap; background: var(--bg-card);
}

.table td {
  border-color: var(--border-color); padding: 0.75rem 1rem;
  color: var(--text-primary); vertical-align: middle;
}

.table tbody tr:hover td { background: var(--bg-hover); }

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--bg-input) !important; border-color: var(--border-color) !important;
  color: var(--text-primary) !important; border-radius: var(--border-radius-sm);
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate .paginate_button {
  color: var(--text-secondary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--primary) !important; border-color: var(--primary) !important; color: white !important;
  border-radius: var(--border-radius-sm);
}

/* ── Modals ────────────────────────────────────────────── */
.modal-content {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--border-radius); color: var(--text-primary);
}

.modal-header {
  border-bottom: 1px solid var(--border-color); padding: 1.25rem 1.5rem;
}

.modal-title { font-weight: 700; font-size: 1.1rem; }

.modal-footer {
  border-top: 1px solid var(--border-color); padding: 1rem 1.5rem;
}

.btn-close { filter: invert(1) opacity(0.6); }
[data-theme="light"] .btn-close { filter: none; }

/* ── Tab Navigation ────────────────────────────────────── */
.nav-tabs {
  border-bottom: 1px solid var(--border-color); margin-bottom: 1.5rem;
}

.nav-tabs .nav-link {
  color: var(--text-secondary); border: none; padding: 0.75rem 1.25rem;
  font-weight: 500; position: relative; border-radius: 0;
}

.nav-tabs .nav-link:hover { color: var(--primary); background: var(--bg-hover); }

.nav-tabs .nav-link.active {
  color: var(--primary); background: transparent; border: none;
}

.nav-tabs .nav-link.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: var(--primary); border-radius: 2px 2px 0 0;
}

/* ── Page Header ───────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}

.page-title {
  font-size: 1.4rem; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 0.625rem;
}

.page-title i { color: var(--primary); }

/* ── Toast / Notifications ─────────────────────────────── */
.toast-container { z-index: 9999; }

.toast {
  background: var(--bg-card); border: 1px solid var(--border-color);
  color: var(--text-primary); border-radius: var(--border-radius-sm);
  min-width: 280px;
}

.toast-header { background: transparent; border-bottom: 1px solid var(--border-color); color: var(--text-primary); }

/* ── Empty State ───────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--text-muted);
}

.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h5 { color: var(--text-secondary); font-size: 1rem; }
.empty-state p { font-size: 0.85rem; }

/* ── Sidebar overlay (mobile) ──────────────────────────── */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 199;
}

/* ── Range Input ───────────────────────────────────────── */
input[type="range"] { accent-color: var(--primary); }

/* ── Toasts ────────────────────────────────────────────── */
#toastContainer {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%;
    transform: translateX(-100%); z-index: 1050;
    box-shadow: var(--shadow);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay { z-index: 1040; }

  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .kpi-value { font-size: 1.5rem; }
}

/* ── Utilities ─────────────────────────────────────────── */
.text-primary-accent { color: var(--primary) !important; }
.text-secondary-accent { color: var(--secondary) !important; }
.fw-600 { font-weight: 600; }
.rounded-xl { border-radius: var(--border-radius) !important; }
.cursor-pointer { cursor: pointer; }

.separator { height: 1px; background: var(--border-color); margin: 1rem 0; }

/* ── Gauge / Progress ──────────────────────────────────── */
.gauge-wrapper {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.875rem; background: var(--bg-body);
  border-radius: var(--border-radius-sm); border: 1px solid var(--border-color);
}

.gauge-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.gauge-value { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }

/* ── Input group icons ─────────────────────────────────── */
.input-group-text {
  background: var(--bg-input); border-color: var(--border-color); color: var(--text-secondary);
}

/* ── Checkboxes, radios e switches ─────────────────────── */
.form-check-label {
  color: var(--text-primary);
  font-size: 0.875rem;
}

.form-check-input {
  background-color: var(--bg-input);
  border-color: var(--border-color);
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-check-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(108, 92, 231, 0.25);
}

/* ══════════════════════════════════════════════════════════
   ATENDIMENTOS — Layout 3 painéis (estilo messaging app)
══════════════════════════════════════════════════════════ */

/* page-content sem padding quando em modo atendimentos */
.page-content.atend-mode,
.page-content.chat-mode {
  padding: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Layout raiz */
.atend-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar esquerda ──────────────────────────────────── */
.atend-sidebar {
  width: 320px;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  background: var(--bg-card);
  overflow: hidden;
}

.atend-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  background: var(--bg-card);
}

.atend-sidebar-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.atend-sidebar-title i { color: var(--primary); }

/* Busca */
.atend-search-wrap {
  position: relative;
  margin-bottom: 0.75rem;
}

.atend-search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.atend-search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.45rem 0.875rem 0.45rem 2rem;
  font-size: 0.83rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.atend-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

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

/* Tabs */
.atend-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-body);
  border-radius: var(--border-radius-sm);
  padding: 3px;
}

.atend-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 5px 4px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.atend-tab:hover { color: var(--primary); background: var(--bg-hover); }

.atend-tab.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

/* Lista de conversas */
.atend-list {
  flex: 1;
  overflow-y: auto;
}

.atend-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  text-align: center;
}

.atend-empty i { font-size: 2rem; opacity: 0.4; }
.atend-empty p { margin: 0; font-size: 0.82rem; }

/* Item de conversa */
.atend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
  position: relative;
}

.atend-item:hover { background: var(--bg-hover); }

.atend-item.active {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}

.atend-item.has-unread .atend-item-name { color: var(--text-primary); }

/* Avatar */
.atend-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

/* Dot de status no avatar */
.atend-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.dot-waiting  { background: var(--warning); }
.dot-bot      { background: var(--primary); }
.dot-human    { background: var(--info); }
.dot-closed   { background: var(--text-muted); }

/* Corpo do item */
.atend-item-body { flex: 1; min-width: 0; }

.atend-item-row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 3px;
}

.atend-item-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.atend-item-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.atend-item-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.atend-item-preview {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Badge de não lidos */
.atend-unread-badge {
  background: var(--secondary);
  color: white;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
  animation: pulse-badge 2s infinite;
}

/* Paginação da lista */
.atend-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.atend-pg-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--transition);
}

.atend-pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.atend-pg-btn:not(:disabled):hover { border-color: var(--primary); color: var(--primary); }

.atend-pg-info {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ── Painel central: chat ──────────────────────────────── */
.atend-chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-body);
  overflow: hidden;
}

/* Placeholder quando sem conversa selecionada */
.atend-chat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.atend-placeholder-icon {
  width: 80px; height: 80px;
  background: var(--primary-light);
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--primary);
}

.atend-chat-placeholder h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
}

.atend-chat-placeholder p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* Container interno do chat */
.atend-chat-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Header do chat */
.atend-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.atend-chat-hdr-info { flex: 1; min-width: 0; }

.atend-chat-name {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.atend-chat-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.atend-chat-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Área de mensagens */
.atend-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Input de resposta */
.atend-chat-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.atend-chat-input .form-control {
  border-radius: 20px;
  background: var(--bg-input);
  border-color: var(--border-color);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.atend-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(108,92,231,0.4);
}

.atend-send-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.06);
}

/* Botão de microfone */
.atend-mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  font-size: 0.8rem;
  white-space: nowrap;
  padding: 0 8px;
  min-width: 36px;
}

.atend-mic-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--primary);
}

.atend-mic-btn.recording {
  background: rgba(214, 48, 49, 0.15);
  border-color: #d63031;
  color: #d63031;
  width: auto;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 48, 49, 0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(214, 48, 49, 0); }
}

/* Botão de anexo de mídia */
.atend-attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.atend-attach-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--primary);
}

/* Mídia nas bolhas */
.bubble-media-img {
  max-width: 240px;
  max-height: 240px;
  border-radius: 10px;
  cursor: pointer;
  display: block;
  margin-bottom: 4px;
  object-fit: cover;
}

.bubble-media-audio {
  width: 240px;
  height: 36px;
  margin-bottom: 4px;
}

.bubble-media-video {
  max-width: 280px;
  max-height: 200px;
  border-radius: 10px;
  display: block;
  margin-bottom: 4px;
}

.bubble-media-doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(108, 92, 231, 0.12);
  color: var(--primary);
  font-size: 0.85rem;
  text-decoration: none;
  margin-bottom: 4px;
  word-break: break-all;
}

.bubble-outbound .bubble-media-doc {
  background: rgba(255,255,255,0.2);
  color: white;
}

.bubble-media-doc:hover { opacity: 0.85; }

/* ── Painel direito: info ──────────────────────────────── */
.atend-info {
  width: 260px;
  min-width: 240px;
  border-left: 1px solid var(--border-color);
  background: var(--bg-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.atend-info-inner {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.atend-info-section {
  margin-bottom: 1rem;
}

.atend-info-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.atend-info-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.atend-info-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.atend-info-value {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.atend-info-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.75rem 0;
}

/* ── fw-700 utility ────────────────────────────────────── */
.fw-700 { font-weight: 700 !important; }

/* ── Responsivo ────────────────────────────────────────── */
@media (max-width: 1100px) {
  .atend-info { display: none; }
}

@media (max-width: 767px) {
  .atend-sidebar { width: 100%; max-width: 100%; }
  .atend-chat { display: none; }
  .atend-layout.chat-open .atend-sidebar { display: none; }
  .atend-layout.chat-open .atend-chat { display: flex; }
}

/* ════════════════════════════════════════════════════════════
   INTERNAL CHAT — Chat Interno entre Usuários
════════════════════════════════════════════════════════════ */

/* Layout raiz — ocupa toda a área de content */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
  background: var(--bg-body);
}

/* ── Sidebar de canais ──────────────────────────────────── */
.chat-sidebar {
  width: 300px;
  min-width: 260px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  overflow: hidden;
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.chat-sidebar-header h6 { font-size: .95rem; }

.chat-sidebar-header .btn-icon {
  color: var(--primary);
  border-color: transparent;
  background: transparent;
}
.chat-sidebar-header .btn-icon:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.chat-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.chat-search i { color: var(--text-muted); font-size: .85rem; }

.chat-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: .875rem;
  width: 100%;
}

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

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: .25rem 0;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}

.channel-item:hover { background: var(--bg-hover); }
.channel-item.active { background: var(--primary-light); }

.channel-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-group-icon { font-size: 1rem; }
.avatar-text { font-size: .85rem; font-weight: 700; }

.channel-info { flex: 1; min-width: 0; }

.channel-name-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .25rem;
}

.channel-name {
  font-weight: 500; font-size: .875rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.channel-time { font-size: .72rem; color: var(--text-muted); flex-shrink: 0; }

.channel-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .15rem;
}

.channel-preview {
  font-size: .8rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}

.channel-badge {
  background: var(--primary);
  color: #fff;
  font-size: .7rem; font-weight: 600;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.channel-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1rem; color: var(--text-muted);
  gap: .5rem; font-size: .875rem;
}

.channel-empty i { font-size: 2rem; }

.messages-loading,
.messages-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: .875rem;
}

/* ── Área principal ─────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-body);
}

.chat-empty-state {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: .75rem;
}

.chat-empty-state i {
  font-size: 3.5rem; color: var(--primary-light);
  background: var(--primary-light);
  width: 88px; height: 88px;
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  font-size: 2.2rem; color: var(--primary);
}

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

/* ── Header do canal ────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.25rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  min-height: 60px;
}

.channel-header-info {
  display: flex; flex-direction: column;
}

.channel-header-name {
  font-weight: 600; font-size: .9rem; line-height: 1.2;
}

.channel-header-sub { font-size: .78rem; color: var(--text-muted); }

/* ── Mensagens ──────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex; flex-direction: column; gap: .1rem;
  scroll-behavior: smooth;
}

.load-more-wrapper {
  display: flex; justify-content: center;
  padding: .5rem; margin-bottom: .5rem;
}

.msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  position: relative;
  margin-bottom: .35rem;
}

.msg-wrapper.msg-mine {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-wrapper.msg-theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-sender {
  font-size: .75rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: .15rem;
  padding-left: .25rem;
}

/* Reply bubble dentro da msg */
.reply-bubble {
  background: rgba(108, 92, 231, .12);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: .35rem .6rem;
  margin-bottom: .25rem;
  max-width: 100%;
}

.reply-bubble-sender { font-size: .72rem; color: var(--primary); font-weight: 600; display: block; }
.reply-bubble-text   { font-size: .78rem; color: var(--text-secondary); display: block;
                        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bolha de mensagem */
.msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px 14px 14px 4px;
  padding: .55rem .8rem;
  word-break: break-word;
  position: relative;
  max-width: 100%;
}

.msg-wrapper.msg-mine .msg-bubble {
  background: var(--primary);
  border-color: var(--primary);
  border-radius: 14px 14px 4px 14px;
  color: #fff;
}

.msg-text { font-size: .9rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg-wrapper.msg-mine .msg-text { color: #fff; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-top: .3rem;
  justify-content: flex-end;
}

.msg-time { font-size: .7rem; color: var(--text-muted); }
.msg-wrapper.msg-mine .msg-time { color: rgba(255,255,255,.6); }
.msg-status { font-size: .7rem; color: rgba(255,255,255,.6); }

/* Placeholder enquanto a mídia autentica e carrega */
.msg-media-pending {
  background: var(--bg-hover);
  border-radius: 10px;
  display: block;
}
img.msg-media-pending  { min-width: 120px; min-height: 80px; }
audio.msg-media-pending { min-width: 220px; height: 36px; }
video.msg-media-pending { min-width: 220px; min-height: 120px; }

/* Imagem */
.msg-image-wrap { display: flex; flex-direction: column; gap: .35rem; }
.msg-image {
  max-width: 280px; max-height: 280px;
  border-radius: 10px; cursor: zoom-in;
  object-fit: cover;
}
.msg-caption { font-size: .82rem; color: var(--text-secondary); }
.msg-wrapper.msg-mine .msg-caption { color: rgba(255,255,255,.75); }

/* Áudio */
.msg-audio { min-width: 260px; }
.msg-audio-player {
  display: block;
  width: 100%;
  min-width: 260px;
  height: 40px;
}

/* Arquivo */
.msg-file {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem .65rem;
  background: rgba(255,255,255,.04);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background var(--transition);
  min-width: 200px;
}

.msg-file:hover { background: rgba(255,255,255,.08); }
.msg-file-icon { font-size: 1.6rem; flex-shrink: 0; }
.msg-file-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msg-file-name { font-size: .82rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { font-size: .72rem; color: var(--text-muted); }

/* Sistema */
.msg-system {
  background: transparent;
  color: var(--text-muted);
  font-size: .78rem;
  text-align: center;
  padding: .25rem;
}

/* Ações da mensagem */
.msg-actions {
  display: flex;
  gap: .2rem;
  position: absolute;
  right: -68px; top: -4px;
  padding: 4px;          /* área invisível que cobre o gap entre bolha e botões */
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
  transition-delay: .15s; /* aguarda um pouco antes de esconder — tempo para o mouse chegar */
}

.msg-wrapper.msg-mine .msg-actions { right: auto; left: -68px; }

.msg-wrapper:hover .msg-actions,
.msg-actions:hover {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}

.btn-xs {
  width: 28px; height: 28px;
  padding: 0; font-size: .72rem;
}

/* Reações */
.reactions-row {
  display: flex; flex-wrap: wrap; gap: .25rem;
  margin-top: .2rem;
}

.reaction-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1px 7px;
  font-size: .78rem; cursor: pointer;
  transition: background var(--transition);
}

.reaction-chip:hover { background: var(--primary-light); }

/* Typing indicator */
.typing-indicator {
  display: flex; align-items: center;
  padding: .5rem .25rem;
}

.typing-bubble {
  display: flex; gap: 3px; align-items: center;
}

.typing-bubble span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-dot 1.4s infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: .2s; }
.typing-bubble span:nth-child(3) { animation-delay: .4s; }

@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Reply preview (antes do input) ─────────────────────── */
.reply-preview {
  display: flex; align-items: center;
  gap: .5rem;
  padding: .5rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  border-left: 3px solid var(--primary);
}

.reply-content { flex: 1; min-width: 0; }
.reply-sender  { font-size: .75rem; color: var(--primary); font-weight: 600; }
.reply-text    { font-size: .8rem; color: var(--text-secondary);
                  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Input area ─────────────────────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .75rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

/* Pill container que agrupa ícones + textarea + mic */
.chat-input-pill {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  padding: .35rem .5rem;
  transition: border-color var(--transition);
  min-height: 44px;
}

.chat-input-pill:focus-within { border-color: var(--primary); }

.chat-input-actions-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: .1rem;
  padding-right: .25rem;
}

/* Ícones compactos dentro da pill */
.btn-icon-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
  padding: 0;
}

.btn-icon-sm:hover { color: var(--primary); background: var(--primary-light); }

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  padding: .4rem .5rem;
  color: var(--text-primary);
  font-size: .9rem;
  resize: none;
  min-height: 28px;
  max-height: 120px;
  outline: none;
  line-height: 1.5;
  font-family: inherit;
  align-self: center;
}

.chat-textarea::placeholder { color: var(--text-muted); }

.btn-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  font-size: .95rem;
}

.btn-send:hover:not(:disabled) { background: var(--primary-hover); transform: scale(1.05); }
.btn-send:disabled { opacity: .35; cursor: not-allowed; transform: none; }

#btnRecord.recording { color: var(--danger) !important; animation: pulse 1s infinite; }

/* ── Info Panel (grupo) ─────────────────────────────────── */
.chat-info-panel {
  width: 280px;
  min-width: 260px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.info-panel-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border-color);
}

.info-panel-body { flex: 1; overflow-y: auto; padding: 1rem; }

.channel-avatar-lg {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; margin: 0 auto;
}

.members-list { margin-top: 1rem; }

.member-item {
  display: flex; align-items: center;
  gap: .65rem; padding: .45rem .25rem;
  border-bottom: 1px solid var(--border-color);
}

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

.member-info { flex: 1; min-width: 0; }
.member-name { font-size: .85rem; font-weight: 500;
               overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; }
.badge-role { font-size: .65rem; color: var(--primary); background: var(--primary-light);
              border-radius: 8px; padding: 0 5px; font-weight: 600; }

/* ── Emoji Picker ────────────────────────────────────────── */
.emoji-picker {
  position: fixed;
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: .5rem;
  display: flex; flex-wrap: wrap; gap: .25rem;
  box-shadow: var(--shadow);
  max-width: 200px;
}

.emoji-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; padding: 2px 4px;
  border-radius: 6px;
  transition: background var(--transition);
}

.emoji-btn:hover { background: var(--bg-hover); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .chat-info-panel { display: none !important; }
}

@media (max-width: 768px) {
  .chat-sidebar {
    position: absolute; left: 0; top: 0; bottom: 0;
    z-index: 100; transform: translateX(-100%);
    transition: transform .25s ease;
    width: 85vw !important;
  }
  .chat-sidebar.open { transform: translateX(0); }
  .chat-layout { position: relative; }
}

/* ── Reply-to: wrapper transparente ao flex layout ─────── */
.bubble-wrapper { display: contents; }

/* ── Reply-to: botão na linha de horário da bolha ───────── */
.bubble-reply-btn {
  opacity: 0; pointer-events: none;
  background: none; border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  font-size: .7rem;
  padding: 0 3px;
  line-height: 1;
  transition: opacity .15s, color .15s;
  order: -1; /* aparece antes do horário */
}
.bubble:hover .bubble-reply-btn { opacity: 1; pointer-events: auto; }
.bubble-reply-btn:hover { color: white; }
.bubble-inbound .bubble-reply-btn { color: var(--text-muted); }
.bubble-inbound .bubble-reply-btn:hover { color: var(--primary); }

/* ── Reply quote dentro da bolha ────────────────────────── */
.bubble-reply-quote {
  background: rgba(0,0,0,.12);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: .3rem .55rem;
  margin-bottom: .3rem;
  max-width: 100%;
  cursor: default;
}
.bubble-outbound .bubble-reply-quote {
  background: rgba(255,255,255,.15);
  border-left-color: rgba(255,255,255,.7);
}
.bubble-reply-quote-sender {
  font-size: .7rem; font-weight: 600; color: var(--primary);
  display: block; margin-bottom: 1px;
}
.bubble-outbound .bubble-reply-quote-sender { color: rgba(255,255,255,.85); }
.bubble-reply-quote-text {
  font-size: .75rem; color: var(--text-secondary);
  display: block; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.bubble-outbound .bubble-reply-quote-text { color: rgba(255,255,255,.75); }

/* ── Reply preview bar (acima do input) ─────────────────── */
#replyPreviewBar {
  display: none;
  align-items: center; gap: .5rem;
  padding: .4rem .75rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  border-left: 3px solid var(--primary);
}
#replyPreviewBar.visible { display: flex; }
#replyPreviewBar .rp-content { flex: 1; min-width: 0; }
#replyPreviewBar .rp-sender  { font-size: .72rem; color: var(--primary); font-weight: 600; display: block; }
#replyPreviewBar .rp-text    { font-size: .78rem; color: var(--text-secondary);
                                overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; }
#replyPreviewBar .rp-cancel  {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 1rem; padding: 0 .25rem; line-height: 1;
  flex-shrink: 0;
}
#replyPreviewBar .rp-cancel:hover { color: var(--danger); }

/* ── Reações de emoji nas bolhas de conversa ─────────────── */
/* .reactions-row e .reaction-chip já definidos no bloco de internal-chat; */
/* apenas precisamos do align-self por direção (bubble-wrapper tem display:contents) */
.reactions-row.reactions-inbound  { align-self: flex-start; margin-bottom: .35rem; }
.reactions-row.reactions-outbound { align-self: flex-end;   margin-bottom: .35rem; }

/* Reação enviada pelo atendente — borda colorida */
.reaction-chip-outbound { border-color: var(--primary); color: var(--primary); }

/* Botão reagir (ícone de emoji) ao lado do botão de responder */
.bubble-react-btn { color: var(--text-muted); }
.bubble-inbound .bubble-react-btn:hover { color: var(--primary); }
.bubble-outbound .bubble-react-btn { color: rgba(255,255,255,0.5); }
.bubble-outbound .bubble-react-btn:hover { color: white; }


/* ── Formatação WhatsApp (negrito, itálico, código) ─────── */
.bubble-content strong, .msg-text strong { font-weight: 700; }
.bubble-content em,     .msg-text em     { font-style: italic; }
.bubble-content s,      .msg-text s      { text-decoration: line-through; }

code.wa-code-inline {
  font-family: monospace;
  font-size: 0.88em;
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
  padding: 0 3px;
}
.bubble-outbound code.wa-code-inline { background: rgba(255,255,255,0.2); }

code.wa-code-block {
  display: block;
  font-family: monospace;
  font-size: 0.85em;
  background: rgba(0,0,0,0.08);
  border-radius: 6px;
  padding: 6px 8px;
  white-space: pre-wrap;
  margin-top: 2px;
}
.bubble-outbound code.wa-code-block { background: rgba(255,255,255,0.2); }
