/* SmartBot SaaS — Global Styles */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --accent: #10b981;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-heading: #f8fafc;
  --border: #334155;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --radius: 12px;
  --radius-sm: 8px;
}

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

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

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg-input); color: var(--text); }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: var(--radius); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg-input); }

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

/* Form elements */
input, textarea, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}
textarea { min-height: 120px; resize: vertical; font-family: inherit; }
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-group { margin-bottom: 16px; }

/* Badge */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-active { background: #065f46; color: #6ee7b7; }
.badge-inactive { background: #7f1d1d; color: #fca5a5; }
.badge-warning { background: #78350f; color: #fde68a; }
.badge-info { background: #1e3a5f; color: #93c5fd; }

/* State badges */
.state-NEW_CHAT { background: #374151; color: #d1d5db; }
.state-WELCOME_SENT { background: #1e3a5f; color: #93c5fd; }
.state-AI_ACTIVE { background: #065f46; color: #6ee7b7; }
.state-HUMAN_NEEDED { background: #7f1d1d; color: #fca5a5; }

/* Sidebar layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  padding: 0 20px 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-heading);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  transition: all 0.15s;
  text-decoration: none;
}
.sidebar-link:hover { background: var(--bg-input); color: var(--text); text-decoration: none; }
.sidebar-link.active { background: var(--primary); color: white; }
.sidebar-link .icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-bottom {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px;
  max-width: 1200px;
}
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-heading);
}
.page-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-heading);
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tr:hover td { background: rgba(99, 102, 241, 0.05); }

/* Chat bubbles */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
}
.chat-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-input);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.chat-input-area input {
  flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* Loading */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 14px;
  z-index: 1000;
  animation: slideUp 0.3s ease-out;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
