/* ZapBolt — zapbolt.com.br — Alberto Tijunelis Neto */

/* =============================================
   CSS VARIABLES — LIGHT / DARK
   ============================================= */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f8ff;
  --bg-tertiary: #eef2ff;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.08);
  --text-primary: #0a0f1e;
  --text-secondary: #3a4a7a;
  --text-muted: #8a9abf;
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-soft: rgba(79,70,229,0.10);
  --zap: #25D366;
  --zap-dark: #128C7E;
  --zap-light: #DCF8C6;
  --bolt: #F59E0B;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
  --sidebar-width: 260px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg-primary: #080c1a;
  --bg-secondary: #0e1428;
  --bg-tertiary: #0a1020;
  --surface: #111827;
  --border: rgba(255,255,255,0.08);
  --text-primary: #e8eaf6;
  --text-secondary: #8a9abf;
  --text-muted: #3a4a7a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99,102,241,0.15);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
}

/* =============================================
   RESET & BASE
   ============================================= */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

img {
  max-width: 100%;
  display: block;
}

/* =============================================
   LAYOUT — SIDEBAR + MAIN
   ============================================= */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

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

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

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

.sidebar-brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-brand-slogan {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  user-select: none;
}

.sidebar-nav-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 14px;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}

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

.sidebar-user-email {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.sidebar-theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.sidebar-theme-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* --- Main Content --- */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.main-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

.main-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.main-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 24px 28px;
}

/* =============================================
   CARDS
   ============================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

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

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-card-icon.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.stat-card-icon.success {
  background: rgba(34,197,94,0.1);
  color: var(--success);
}

.stat-card-icon.warning {
  background: rgba(245,158,11,0.1);
  color: var(--warning);
}

.stat-card-icon.info {
  background: rgba(59,130,246,0.1);
  color: var(--info);
}

.stat-card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* =============================================
   BUTTONS
   ============================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-secondary:hover {
  background: var(--accent);
  color: #fff;
}

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

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #16a34a;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* =============================================
   FORMS
   ============================================= */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg fill='%238a9abf' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-char-count {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 2px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Chip buttons */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.chip:hover,
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* =============================================
   MODALS
   ============================================= */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

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

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

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

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

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Large modal */
.modal-lg {
  max-width: 720px;
}

/* =============================================
   TABS
   ============================================= */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* =============================================
   BADGES
   ============================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background: rgba(34,197,94,0.1);
  color: var(--success);
}

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

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

.badge-muted {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.badge-info {
  background: rgba(59,130,246,0.1);
  color: var(--info);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

/* =============================================
   TABLES
   ============================================= */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tr:hover {
  background: var(--accent-soft);
}

/* =============================================
   GRID LAYOUTS
   ============================================= */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* =============================================
   CONVERSATIONS LAYOUT
   ============================================= */

.conversations-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: calc(100vh - 130px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.conv-list-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conv-list-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.conv-list-filters {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.conv-list-filters .form-select,
.conv-list-filters .form-input {
  font-size: 12px;
  padding: 6px 10px;
}

.conv-list-body {
  flex: 1;
  overflow-y: auto;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.conv-item:hover,
.conv-item.active {
  background: var(--accent-soft);
}

.conv-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

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

.conv-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.conv-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

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

.conv-item-unread {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat panel */
.conv-chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

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

.conv-chat-header-text h3 {
  font-size: 15px;
  font-weight: 600;
}

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

.conv-chat-actions {
  display: flex;
  gap: 8px;
}

.conv-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-bubble.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble.bot {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble-time {
  font-size: 10px;
  color: inherit;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.conv-chat-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}

.conv-chat-footer .form-input {
  flex: 1;
}

.conv-chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--text-muted);
  font-size: 15px;
}

.conv-chat-empty .empty-icon {
  font-size: 48px;
  opacity: 0.4;
}

/* =============================================
   BOT CARDS
   ============================================= */

.bot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

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

.bot-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.bot-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.bot-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.bot-card-niche {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.bot-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.bot-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* =============================================
   KNOWLEDGE BASE
   ============================================= */

.kb-category {
  margin-bottom: 12px;
}

.kb-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.kb-category-header:hover {
  background: var(--accent-soft);
}

.kb-category-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.kb-category-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.kb-category-toggle {
  font-size: 14px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.kb-category.open .kb-category-toggle {
  transform: rotate(180deg);
}

.kb-items {
  display: none;
  padding: 4px 0;
}

.kb-category.open .kb-items {
  display: block;
}

.kb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 10px 40px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

.kb-item:last-child {
  border-bottom: none;
}

.kb-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.kb-item-actions button {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
}

.kb-item-actions button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.kb-item-actions button.danger:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.1);
}

/* =============================================
   STEPPER
   ============================================= */

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.stepper-step.active .stepper-circle,
.stepper-step.completed .stepper-circle {
  background: var(--accent);
  color: #fff;
}

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

.stepper-step.active .stepper-label {
  color: var(--accent);
}

.stepper-line {
  width: 40px;
  height: 2px;
  background: var(--border);
}

.stepper-step.completed ~ .stepper-line {
  background: var(--accent);
}

/* =============================================
   CHART CONTAINER
   ============================================= */

.chart-container {
  position: relative;
  width: 100%;
  height: 200px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* =============================================
   QR CODE BOX
   ============================================= */

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.qr-code-img {
  width: 220px;
  height: 220px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.qr-code-img img {
  width: 200px;
  height: 200px;
}

.qr-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.qr-status .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =============================================
   FLOATING TEST BUTTON + CHAT SIMULATOR
   ============================================= */

.fab-test {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
}

.fab-test:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79,70,229,0.4);
}

.chat-sim-overlay {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 160;
  width: 380px;
  max-height: 520px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

.chat-sim-overlay.active {
  display: flex;
}

.chat-sim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
}

.chat-sim-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.chat-sim-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-sim-header select {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}

.chat-sim-header select option {
  color: #000;
}

.chat-sim-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 2px;
  opacity: 0.8;
}

.chat-sim-header button:hover {
  opacity: 1;
}

.chat-sim-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
  max-height: 340px;
}

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

.chat-sim-footer input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
}

.chat-sim-footer input:focus {
  border-color: var(--accent);
}

.chat-sim-footer button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
}

.chat-sim-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 16px 8px;
}

.chat-sim-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  margin: 0 1px;
  animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

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

/* =============================================
   ACCORDION
   ============================================= */

.accordion-header {
  cursor: pointer;
  user-select: none;
}

.accordion-body {
  display: none;
}

.accordion.open .accordion-body {
  display: block;
}

/* =============================================
   COLOR PALETTE PICKER
   ============================================= */

.palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.palette-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--transition);
}

.palette-swatch:hover,
.palette-swatch.active {
  border-color: var(--text-primary);
  transform: scale(1.15);
}

/* =============================================
   PROGRESS BAR
   ============================================= */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* =============================================
   ALERTS
   ============================================= */

.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-info {
  background: rgba(59,130,246,0.1);
  color: var(--info);
  border: 1px solid rgba(59,130,246,0.2);
}

.alert-warning {
  background: rgba(245,158,11,0.1);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.2);
}

.alert-success {
  background: rgba(34,197,94,0.1);
  color: var(--success);
  border: 1px solid rgba(34,197,94,0.2);
}

.alert-danger {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.2);
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease forwards;
  animation-delay: 0s, 3s;
  max-width: 360px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* =============================================
   EMPTY STATE
   ============================================= */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 14px;
  margin-bottom: 16px;
}

/* =============================================
   SKELETON LOADING
   ============================================= */

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

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

/* =============================================
   LOGIN PAGE
   ============================================= */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

.login-logo p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-tabs {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.login-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.login-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.login-form {
  display: none;
}

.login-form.active {
  display: block;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--accent);
}

/* =============================================
   TERMS PAGE
   ============================================= */

.terms-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 24px;
}

.terms-page h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.terms-page h2 {
  font-size: 20px;
  font-weight: 700;
  margin-top: 32px;
  margin-bottom: 12px;
  color: var(--accent);
}

.terms-page h3 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
}

.terms-page p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.terms-page ul {
  margin-bottom: 12px;
  padding-left: 24px;
}

.terms-page li {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* =============================================
   SCROLLBAR CUSTOM
   ============================================= */

::-webkit-scrollbar {
  width: 6px;
}

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

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

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

/* =============================================
   RESPONSIVE
   ============================================= */

/* Hamburger button — hidden by default on desktop */
.hamburger-btn {
  display: none !important;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-primary);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}
.sidebar-overlay.visible { display: block; }

/* Sidebar logo container */
.sidebar-logo {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Login logo container */
.login-logo img {
  height: 48px;
  width: auto;
  display: block;
  margin: 0 auto 12px;
}

/* Bots grid default */
.bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* Mobile < 768px */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: left 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    transform: none;
  }
  .sidebar.open { left: 0; }
  .hamburger-btn { display: flex !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 1rem; }
  .stats-grid,
  .metrics-grid { grid-template-columns: 1fr 1fr !important; }
  .grid-2,
  .grid-3 { grid-template-columns: 1fr; }
  .grid-cards,
  .bots-grid { grid-template-columns: 1fr !important; }
  .conversations-layout { grid-template-columns: 1fr !important; height: auto; }
  .conv-list-panel {
    max-height: 300px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .conv-chat-panel { min-height: 400px; }
  .conversation-detail {
    position: fixed; inset: 0; z-index: 500;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }
  .conversation-detail.open { transform: translateX(0); }
  .modal-content,
  .modal {
    width: 100% !important; height: 100% !important;
    max-height: 100vh !important; border-radius: 0 !important; margin: 0 !important;
  }
  .chat-sim-overlay {
    position: fixed !important; inset: 0 !important;
    width: 100% !important; height: 100% !important; border-radius: 0 !important;
    right: auto; left: auto; bottom: auto;
  }
  .btn-group { flex-direction: column; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  input, select, textarea { font-size: 16px !important; }
  .main-header { padding: 12px 16px; }
  .main-header h1 { font-size: 17px; }
  .mobile-menu-btn { display: none; }
  .qr-code-img { width: min(200px, 80vw); height: min(200px, 80vw); }
  .qr-code-img img { width: 100%; height: 100%; }
}

/* Tablet 768px–1279px */
@media (min-width: 768px) and (max-width: 1279px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; }
  .stats-grid,
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .bots-grid { grid-template-columns: repeat(2, 1fr); }
  .hamburger-btn { display: none !important; }
  .conversations-layout { grid-template-columns: 280px 1fr; }
}

/* Desktop 1280px+ */
@media (min-width: 1280px) {
  .sidebar { width: 240px; }
  .main-content { margin-left: 240px; }
  .stats-grid,
  .metrics-grid { grid-template-columns: repeat(4, 1fr); }
  .bots-grid { grid-template-columns: repeat(3, 1fr); }
  .hamburger-btn { display: none !important; }
}

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

  .login-card {
    padding: 28px 20px;
  }

  .fab-test {
    bottom: 16px;
    right: 16px;
    padding: 12px 18px;
    font-size: 13px;
  }
}

/* =============================================
   PRINT STYLES
   ============================================= */

@media print {
  .sidebar,
  .fab-test,
  .chat-sim-overlay,
  .toast-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }
}

/* =============================================
   SVG ICON ALIGNMENT
   ============================================= */

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-icon svg {
  vertical-align: middle;
}

.stat-card-icon svg {
  width: 24px;
  height: 24px;
}

.bot-card-icon svg {
  width: 20px;
  height: 20px;
}

/* =============================================
   UTILITY CLASSES
   ============================================= */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.w-full { width: 100%; }
