/* ─────────────────────────────────────────────────────────────────────────────
   CPC Bot — Design System & Custom Premium CSS
   ───────────────────────────────────────────────────────────────────────────── */

/* Reset & Configurações de Fonte */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Color Palette - HSL (Dark Mode Premium) */
  --bg-app: hsl(222, 47%, 6%);
  --bg-sidebar: hsl(222, 47%, 10%);
  --bg-card: hsla(222, 47%, 13%, 0.85);
  --bg-card-hover: hsla(222, 47%, 16%, 0.95);
  --bg-element: hsl(222, 47%, 16%);
  --bg-element-light: hsl(222, 47%, 20%);

  --border-color: hsla(217, 40%, 80%, 0.08);
  --border-hover: hsla(217, 100%, 75%, 0.2);

  --color-primary: hsl(217, 90%, 61%); /* Royal Blue Neon */
  --color-primary-rgb: 59, 130, 246;
  --color-success: hsl(142, 70%, 45%); /* Emerald Green */
  --color-success-rgb: 16, 185, 129;
  --color-warning: hsl(38, 92%, 50%); /* Amber Yellow */
  --color-danger: hsl(0, 84%, 60%); /* Red Coral */

  --text-main: hsl(210, 40%, 98%);
  --text-muted: hsl(215, 20%, 65%);
  --text-dark: hsl(222, 47%, 25%);

  /* Layout Dimensions */
  --sidebar-width: 260px;
  --header-height: 70px;

  /* System Tokens */
  --font-display:
    "Outfit", "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.15);

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: var(--font-body);
  background: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ─── Layout Geral (Sidebar + Principal) ─── */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* Sidebar Estilizada */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 24px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.sidebar-logo {
  height: 40px;
  width: auto;
  border-radius: var(--radius-sm);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Navegação da Sidebar */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-element);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(var(--color-primary-rgb), 0.15);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  background: var(--color-primary);
  border-radius: 0 4px 4px 0;
}

.nav-icon {
  font-size: 18px;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.3);
}

/* Footer da Sidebar (Status de Conexão) */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.connection-status-panel {
  background: var(--bg-element);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.status-dot.connected {
  background: var(--color-success);
  box-shadow: 0 0 10px var(--color-success);
  animation: pulse-glow 2s infinite;
}

.status-dot.connecting {
  background: var(--color-warning);
  animation: pulse-fade 1s infinite;
}

.status-dot.qr {
  background: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary);
  animation: pulse-glow 2s infinite;
}

.status-dot.disconnected {
  background: var(--color-danger);
}

.status-text {
  font-size: 12px;
  font-weight: 600;
}

.btn-restart-mini {
  background: hsla(0, 0%, 100%, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-restart-mini:hover {
  background: var(--bg-element-light);
  border-color: var(--text-muted);
}

.btn-logout {
  margin-top: 12px;
  width: 100%;
  background: hsla(0, 0%, 100%, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-logout:hover {
  background: hsla(0, 84%, 60%, 0.12);
  border-color: hsla(0, 84%, 60%, 0.4);
  color: var(--color-danger);
}

/* Área de Conteúdo Principal */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 32px 40px 60px;
}

/* Abas */
.tab-content {
  animation: fade-in-up 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.tab-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.tab-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.date-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ─── Cartões & Dashboard ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
}

.stat-icon-wrapper {
  font-size: 28px;
  background: var(--bg-element);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
}

.stat-details {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

/* Customização de Cards Estatísticos */
.stat-card.total .stat-icon-wrapper {
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.1);
}
.stat-card.confirmed .stat-icon-wrapper {
  color: var(--color-success);
  background: rgba(16, 185, 129, 0.1);
}
.stat-card.review .stat-icon-wrapper {
  color: var(--color-warning);
  background: rgba(245, 158, 11, 0.1);
}
.stat-card.pending .stat-icon-wrapper {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.1);
}
.stat-card.presencial .stat-icon-wrapper {
  color: hsl(270, 85%, 65%);
  background: rgba(139, 92, 246, 0.1);
}
.stat-card.online .stat-icon-wrapper {
  color: hsl(180, 85%, 50%);
  background: rgba(6, 182, 212, 0.1);
}

.dashboard-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Cartões Padrão */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.card-body {
  padding: 24px;
}

/* Painel de Conexão WhatsApp */
.connection-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 0;
}

.state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.state-icon.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.state-icon.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.state-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.state-description {
  color: var(--text-muted);
  max-width: 320px;
  font-size: 13px;
  line-height: 1.6;
}

.qr-description {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.qr-container {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: inline-block;
  margin-bottom: 20px;
}

.qr-container img {
  width: 200px;
  height: 200px;
  display: block;
}

.qr-steps {
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-element);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 360px;
}

.qr-steps p {
  margin-bottom: 6px;
}

.qr-steps p:last-child {
  margin-bottom: 0;
}

/* Spinner e Animações */
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--bg-element);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.instruction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.instruction-list li {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.inst-num {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-primary);
  font-family: var(--font-display);
  font-weight: 700;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.inst-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

.inst-text strong {
  color: var(--text-main);
}

/* ─── Botões Customizados ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(var(--color-primary-rgb), 0.35);
  margin-top: 8px;
}

.btn-primary:hover {
  background: hsl(217, 95%, 68%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(var(--color-primary-rgb), 0.5);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-element);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-element);
  color: var(--text-main);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* ─── Tela de Login ─── */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(
      1100px 560px at 50% -12%,
      hsla(217, 90%, 61%, 0.18),
      transparent 60%
    ),
    radial-gradient(
      820px 480px at 50% 118%,
      hsla(217, 90%, 61%, 0.1),
      transparent 55%
    ),
    var(--bg-app);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  padding: 40px 36px 30px;
  text-align: center;
  animation: loginIn 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes loginIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  margin: 0 auto 18px;
  border-radius: var(--radius-md);
}

.login-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 30px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
}

.login-form .form-control {
  padding: 12px 16px;
  font-size: 14px;
  background: var(--bg-app);
}

.login-error {
  display: none;
  font-size: 13px;
  color: var(--color-danger);
  background: hsla(0, 84%, 60%, 0.1);
  border: 1px solid hsla(0, 84%, 60%, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.login-submit {
  width: 100%;
  padding: 13px 20px;
  font-size: 14px;
  margin-top: 10px;
}

.login-footer {
  margin-top: 28px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.65;
}

/* ─── Filtros e Tabelas ─── */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.filter-bar .search-box {
  max-width: 100%;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-actions .form-control {
  flex: 1;
  min-width: 160px;
}

.search-box {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.form-control {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--color-primary);
  background: var(--bg-element);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

select.form-control {
  appearance: none;
  cursor: pointer;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239096b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

.card-table {
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  padding: 16px 24px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.01);
}

.data-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.text-right {
  text-align: right;
}

.table-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 48px !important;
}

/* Badges de Status */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge.pending {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.badge.review {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.badge.confirmed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

/* ─── Workspace do Chat (Visualizador de Atendimentos) ─── */
/* Aba de Atendimentos em tela cheia, estilo WhatsApp: sem padding, altura total */
.main-content.chats-mode {
  padding: 0;
  height: 100vh;
  overflow: hidden;
}
.main-content.chats-mode #tab-chats {
  height: 100%;
}
.main-content.chats-mode .chat-workspace {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.chat-workspace {
  display: flex;
  height: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.chat-sidebar {
  width: 340px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.01);
}

.chat-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.chat-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* Contador de conversas que precisam de atenção (topo da lista) */
.attention-count {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  font-size: 12px;
  font-weight: 700;
  color: var(--color-warning);
}
.attention-count.hidden {
  display: none;
}

/* Ponto pulsante de atenção */
.attention-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-warning);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55);
  animation: attention-pulse 1.8s infinite;
}

@keyframes attention-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

/* Etiqueta "precisa de atendimento" dentro do item da lista */
.attention-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-warning);
}

.chats-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.loading-state {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  font-size: 13px;
}

/* Cards de Contato Individual */
.chat-item {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 6px;
  border: 1px solid transparent;
}

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

.chat-item.active {
  background: rgba(var(--color-primary-rgb), 0.12);
  border-color: rgba(var(--color-primary-rgb), 0.2);
}

/* Conversa que precisa de atendimento humano: acento âmbar + fundo */
.chat-item.needs-attention {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.22);
  box-shadow: inset 3px 0 0 var(--color-warning);
}
.chat-item.needs-attention:hover {
  background: rgba(245, 158, 11, 0.14);
}
.chat-item.needs-attention.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.45);
}

.chat-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-item-name {
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.chat-item-time {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-item-message {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item.active .chat-item-message {
  color: hsl(210, 40%, 80%);
}

/* Janela de Conversa (Direita) */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.15);
}

.chat-blank {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px;
}

.chat-blank-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 320px;
}

.chat-blank-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.chat-blank h4 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.chat-blank p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-actions {
  margin-left: auto;
}

/* Botão voltar (só no mobile) */
.chat-back-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.chat-back-btn:hover {
  background: var(--bg-element);
}

/* Faixa de alerta: conversa que precisa de atendimento humano */
.chat-attention-banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--color-warning);
  font-size: 12.5px;
  font-weight: 600;
}
.chat-attention-banner.show {
  display: flex;
}

/* Pill de status de controle (bot x atendimento humano) */
.control-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(var(--color-primary-rgb), 0.15);
  color: hsl(217, 90%, 75%);
  border: 1px solid rgba(var(--color-primary-rgb), 0.25);
}
.control-pill.human {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
  border-color: rgba(245, 158, 11, 0.35);
}

.chat-header-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.chat-header-phone {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Área de Balões de Mensagem */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message-bubble {
  max-width: 65%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  position: relative;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.message-bubble.incoming {
  align-self: flex-start;
  background: var(--bg-element);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-color);
}

.message-bubble.outgoing {
  align-self: flex-end;
  background: rgba(var(--color-primary-rgb), 0.2);
  color: var(--text-main);
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(var(--color-primary-rgb), 0.15);
}

.message-bubble.bot {
  align-self: flex-end;
  background: hsla(222, 47%, 20%, 0.5);
  color: hsl(210, 40%, 85%);
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.message-sender {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}

.message-bubble.outgoing .message-sender {
  color: hsl(217, 90%, 75%);
}

.message-bubble.bot .message-sender {
  color: var(--color-warning);
}

.message-time {
  display: block;
  text-align: right;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Caixa de Digitação */
.chat-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  display: flex;
  gap: 12px;
}

.chat-footer input {
  flex: 1;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: all var(--transition-fast);
}

.chat-footer input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}

.btn-send {
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 0 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(var(--color-primary-rgb), 0.25);
  cursor: pointer;
}

.btn-send:hover {
  background: hsl(217, 95%, 68%);
  box-shadow: 0 6px 14px rgba(var(--color-primary-rgb), 0.4);
}

/* ─── Respostas Automáticas / Mensagens Editáveis ─── */
.messages-list {
  display: flex;
  flex-direction: column;
  padding: 8px;
}

.message-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  transition: all var(--transition-fast);
}

.message-row:last-child {
  margin-bottom: 0;
}

.message-row:hover {
  border-color: var(--border-hover);
  background: var(--bg-element);
}

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

.message-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.message-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Modal Premium ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}

#cancel-modal {
  z-index: 2000;
}

.modal {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  animation: scale-up 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.modal-hint {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.modal-textarea {
  width: 100%;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 16px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  outline: none;
  resize: vertical;
  transition: border-color var(--transition-fast);
}

.modal-textarea:focus {
  border-color: var(--color-primary);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(0, 0, 0, 0.1);
}

/* ─── Toasts & Utilitários de Animação ─── */
.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 300;
  backdrop-filter: blur(10px);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--color-success);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2);
}

.toast.error {
  border-color: var(--color-danger);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.2);
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Animações Keyframes */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scale-up {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-glow {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.95);
    box-shadow: 0 0 16px currentColor;
  }
}

@keyframes pulse-fade {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ═══ Ícones Lucide ═══ */
.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
  vertical-align: middle;
}
.nav-icon .lucide {
  width: 20px;
  height: 20px;
}
.btn .lucide,
.btn-sm .lucide,
.btn-restart-mini .lucide,
.btn-logout .lucide,
.icon-btn .lucide {
  width: 16px;
  height: 16px;
}

/* ═══ Sidebar retrátil ═══ */
.sidebar-brand {
  position: relative;
}
.sidebar-toggle {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.sidebar-toggle:hover {
  background: var(--bg-element);
  color: var(--text-main);
}
.btn-restart-mini,
.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

body.nav-collapsed .sidebar {
  width: 72px;
  padding: 24px 8px;
}
body.nav-collapsed .main-content {
  margin-left: 72px;
}
body.nav-collapsed .sidebar-brand-text,
body.nav-collapsed .nav-text,
body.nav-collapsed .nav-badge,
body.nav-collapsed .status-text,
body.nav-collapsed .btn-label {
  display: none;
}
body.nav-collapsed .sidebar-brand {
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 20px;
  justify-content: center;
}
body.nav-collapsed .sidebar-toggle {
  margin-left: 0;
}
body.nav-collapsed .nav-item {
  justify-content: center;
  padding: 12px;
}
body.nav-collapsed .connection-status-panel {
  align-items: center;
}
body.nav-collapsed .btn-restart-mini,
body.nav-collapsed .btn-logout {
  padding: 9px;
}

/* ═══ Badges de status adicionais ═══ */
.badge.cancelled {
  background: rgba(148, 163, 184, 0.18);
  color: hsl(215, 18%, 72%);
}
.badge.refund_pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}
.badge.refunded {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

/* ═══ Botão danger ═══ */
.btn-danger {
  background: var(--color-danger);
  color: #fff;
}
.btn-danger:hover {
  background: hsl(0, 84%, 66%);
  transform: translateY(-1px);
}

/* ═══ Ações na linha da tabela ═══ */
.row-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-element);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}
.icon-btn.success:hover {
  color: var(--color-success);
  border-color: rgba(16, 185, 129, 0.5);
}
.icon-btn.danger:hover {
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.5);
}

/* ═══ Página de detalhes da inscrição ═══ */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.detail-panel {
  width: 100%;
  max-width: 760px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fade-in-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-sidebar);
}
.detail-back {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  transition: background var(--transition-fast);
}
.detail-back:hover {
  background: var(--bg-element);
}
.detail-header-titles {
  flex: 1;
  min-width: 0;
}
.detail-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}
.detail-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.detail-body {
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 28px;
}
.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-field.full {
  grid-column: 1 / -1;
}
.detail-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.detail-field-value {
  font-size: 14px;
  color: var(--text-main);
  word-break: break-word;
}
.detail-field-value.reason {
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  color: hsl(38, 90%, 75%);
}
.detail-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  padding: 18px 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.12);
}
.detail-footer .btn {
  margin-top: 0;
}

/* ═══ Cabeçalho de impressão (oculto na tela) ═══ */
.print-header {
  display: none;
}

/* Media Queries Responsivas */
@media (max-width: 1024px) {
  .sidebar-logo {
    height: 36px;
  }
  .main-content {
    padding: 24px 20px;
  }
  .dashboard-panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .tab-header {
    flex-direction: column;
    gap: 16px;
  }

  /* Atendimentos em painel único (estilo WhatsApp mobile):
     mostra a lista; ao abrir uma conversa, desliza para ela. */
  .chat-sidebar {
    width: 100%;
    border-right: none;
  }
  .chat-window {
    display: none;
  }
  .chat-workspace.show-conversation .chat-sidebar {
    display: none;
  }
  .chat-workspace.show-conversation .chat-window {
    display: flex;
  }
  .chat-back-btn {
    display: inline-flex;
  }
  .message-bubble {
    max-width: 85%;
  }
  /* Evita estouro do cabeçalho com mais botões (assumir/devolver) */
  .chat-header {
    flex-wrap: wrap;
  }
  .chat-header-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Filtros empilham */
  .filter-actions {
    gap: 10px;
  }
  .filter-actions .form-control {
    min-width: 120px;
  }

  /* Detalhe ocupa a tela toda */
  .detail-overlay {
    padding: 0;
  }
  .detail-panel {
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }
  .detail-body {
    grid-template-columns: 1fr;
  }

  /* Tabela de inscrições vira cards */
  .card-table .table-responsive {
    overflow: visible;
  }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }
  .data-table thead {
    display: none;
  }
  .data-table tr {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 12px;
  }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 7px 0;
    border: none;
    text-align: right;
  }
  .data-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-align: left;
  }
  .data-table td.text-right {
    justify-content: flex-end;
  }
  .data-table td.text-right::before {
    display: none;
  }
  .data-table .row-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ═══ Impressão: apenas a lista filtrada de inscrições ═══ */
@media print {
  .sidebar,
  .tab-header,
  .filter-bar,
  .toast,
  .detail-overlay,
  .modal-overlay,
  .no-print {
    display: none !important;
  }

  body,
  .app-layout,
  .main-content,
  .card,
  .card-table {
    background: #fff !important;
    color: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
    box-shadow: none !important;
    border: none !important;
    backdrop-filter: none !important;
  }

  .print-header {
    display: block !important;
    margin: 0 0 14px;
    color: #000;
  }
  .print-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
  }
  .print-header .print-meta {
    font-size: 12px;
    color: #333;
  }

  /* Restaura o formato de tabela mesmo em telas estreitas */
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td,
  .data-table thead {
    display: revert !important;
  }
  .data-table {
    width: 100%;
    border-collapse: collapse;
  }
  .data-table thead {
    display: table-header-group !important;
  }
  .data-table tr {
    display: table-row !important;
    background: #fff !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .data-table th,
  .data-table td {
    display: table-cell !important;
    border: 1px solid #bbb;
    padding: 6px 8px;
    font-size: 11px;
    color: #000 !important;
    text-align: left !important;
  }
  .data-table td::before {
    display: none !important;
  }
  .data-table .no-print,
  .row-actions {
    display: none !important;
  }
  .badge {
    border: 1px solid #999;
    background: transparent !important;
    color: #000 !important;
  }
}
