/* ==========================================================================
   LeadPulse CRM Dashboard — Dedicated Page Styles
   Full-page sidebar layout, KPI cards, leads table, analytics
   ========================================================================== */

:root {
  --crm-sidebar-width: 260px;
  --crm-bg: #F4F6F9;
  --crm-surface: #FFFFFF;
  --crm-border: #E2E8F0;
  --crm-text: #0F172A;
  --crm-text-secondary: #64748B;
  --crm-text-muted: #94A3B8;
  --crm-brand: #10B981;
  --crm-brand-dark: #059669;
  --crm-brand-light: #ECFDF5;
  --crm-danger: #DC2626;
  --crm-purple: #7C3AED;
  --crm-blue: #2563EB;
  --crm-orange: #EA580C;
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--crm-bg);
  color: var(--crm-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ==========================================================================
   AUTH GUARD LOADER
   ========================================================================== */
.auth-guard-loader {
  position: fixed; inset: 0; z-index: 99999;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  display: flex; align-items: center; justify-content: center;
}

.guard-spinner-card {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}

.guard-logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
}

.guard-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--crm-brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.guard-text {
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 500;
}

/* ==========================================================================
   LAYOUT — Sidebar + Main
   ========================================================================== */
.crm-app {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.crm-sidebar {
  width: var(--crm-sidebar-width);
  background: #0F172A;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: #FFFFFF;
}

.sidebar-title strong {
  color: var(--crm-brand);
}

.sidebar-subtitle {
  display: block;
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: #FFFFFF;
}

.sidebar-link.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--crm-brand);
}

.sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 15px;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--crm-brand);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--crm-brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 13px; font-weight: 600; color: #fff;
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 140px;
}

.sidebar-user-plan {
  font-size: 10px; font-weight: 700;
  color: var(--crm-brand);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.sidebar-action-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: rgba(255,255,255,0.5);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
}

.sidebar-action-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #FFFFFF;
}

/* MOBILE HEADER (hidden on desktop) */
.crm-mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: #0F172A;
  z-index: 90;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-btn {
  background: transparent; border: none;
  color: #fff; font-size: 20px; cursor: pointer;
  padding: 8px;
}

.mobile-brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-size: 15px; color: #fff; font-weight: 600;
}

.mobile-brand strong { color: var(--crm-brand); }
.mobile-brand img { border-radius: 8px; }

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

/* MAIN CONTENT */
.crm-main {
  margin-left: var(--crm-sidebar-width);
  flex: 1;
  padding: 24px;
  min-height: 100vh;
}

/* TOP BAR */
.crm-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--crm-text);
}

.topbar-date {
  font-size: 13px;
  color: var(--crm-text-muted);
}

.topbar-right {
  display: flex; gap: 8px;
}

.btn-topbar {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  color: var(--crm-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-topbar:hover {
  background: var(--crm-text);
  color: #fff;
  border-color: var(--crm-text);
}

/* ==========================================================================
   TAB PANELS
   ========================================================================== */
.crm-tab-panel {
  display: none;
}

.crm-tab-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* ==========================================================================
   KPI CARDS
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  transition: box-shadow 0.2s ease;
}

.kpi-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.kpi-blue { background: #EFF6FF; color: #2563EB; }
.kpi-red { background: #FEF2F2; color: #DC2626; }
.kpi-green { background: #ECFDF5; color: #059669; }
.kpi-purple { background: #FAF5FF; color: #7C3AED; }

.kpi-label {
  font-size: 12px; color: var(--crm-text-muted);
  font-weight: 500; display: block;
}

.kpi-value {
  font-size: 24px; font-weight: 800;
  color: var(--crm-text);
  margin: 2px 0 0 0;
}

.kpi-hot { color: var(--crm-danger); }
.kpi-emerald { color: var(--crm-brand-dark); }

.kpi-trend {
  margin-left: auto;
  font-size: 12px; font-weight: 700;
  color: var(--crm-brand);
}

/* ==========================================================================
   LEADS TOOLBAR
   ========================================================================== */
.leads-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip-btn {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px; font-weight: 600;
  color: var(--crm-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  padding: 8px 14px;
  min-width: 280px;
}

.search-box i { color: var(--crm-text-muted); font-size: 14px; }

.search-box input {
  border: none; outline: none;
  font-size: 13px; width: 100%;
  background: transparent;
  font-family: var(--font-body);
}

/* ==========================================================================
   LEADS TABLE
   ========================================================================== */
.table-wrap {
  background: var(--crm-surface);
  border-radius: 16px;
  border: 1px solid var(--crm-border);
  overflow-x: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

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

.leads-table th {
  background: #F8FAFC;
  color: var(--crm-text-secondary);
  font-weight: 700;
  padding: 14px 16px;
  border-bottom: 1px solid var(--crm-border);
  white-space: nowrap;
}

.leads-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
  color: #1E293B;
}

.leads-table tr:hover { background: #F8FAFC; }
.leads-table tr:last-child td { border-bottom: none; }

.lead-name-cell {
  display: flex; align-items: center; gap: 10px;
}

.lead-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #EEF2FF;
  color: #4F46E5;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.lead-score-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 700; font-size: 12px;
}

.score-hot { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.score-warm { background: #FFFBEB; color: #D97706; border: 1px solid #FDE68A; }
.score-cold { background: #F0FDF4; color: #16A34A; border: 1px solid #BBF7D0; }

.btn-wa-chat {
  display: inline-flex; align-items: center; gap: 6px;
  background: #25D366; color: #fff;
  text-decoration: none; font-size: 12px; font-weight: 700;
  padding: 6px 12px; border-radius: 8px;
  transition: all 0.2s ease;
}

.btn-wa-chat:hover { background: #1EBE5D; transform: translateY(-1px); }

.crm-status-select {
  padding: 6px 8px; border-radius: 6px;
  border: 1px solid #CBD5E1;
  font-size: 12px; font-weight: 600; outline: none;
  background: var(--crm-surface);
}

/* Empty State */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--crm-text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; color: var(--crm-border); }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--crm-text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; max-width: 400px; margin: 0 auto; }

/* ==========================================================================
   ANALYTICS TAB
   ========================================================================== */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.analytics-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.analytics-card.full-width { grid-column: 1 / -1; }

.analytics-header h3 {
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}

.analytics-header h3 i { color: var(--crm-brand); }

/* Pipeline Chart */
.pipeline-chart { margin-top: 8px; }

.pipeline-bar {
  display: flex; height: 40px; border-radius: 12px;
  overflow: hidden; background: #F1F5F9;
}

.pipeline-segment {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  transition: width 0.5s ease;
  min-width: 40px;
}

.pipeline-segment.hot { background: #DC2626; }
.pipeline-segment.warm { background: #D97706; }
.pipeline-segment.cold { background: #2563EB; }
.pipeline-segment.converted { background: #059669; }

.pipeline-legend {
  display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px;
}

.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--crm-text-secondary);
}

.legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
}

.legend-dot.hot { background: #DC2626; }
.legend-dot.warm { background: #D97706; }
.legend-dot.cold { background: #2563EB; }
.legend-dot.converted { background: #059669; }

/* Perf Metrics */
.perf-metric {
  padding: 16px 0; border-bottom: 1px solid #F1F5F9;
}

.perf-metric:last-child { border-bottom: none; }

.perf-value {
  font-size: 28px; font-weight: 800; color: var(--crm-brand);
}

.perf-label {
  font-size: 13px; color: var(--crm-text-muted); margin-top: 2px;
}

/* Action list */
.action-list {
  list-style: none; padding: 0;
}

.action-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #F1F5F9;
  font-size: 14px; color: var(--crm-text-secondary);
}

.action-list li:last-child { border-bottom: none; }
.action-list li i { color: var(--crm-brand); }
.action-list li strong { margin-left: auto; color: var(--crm-text); }

/* ==========================================================================
   BOT CONFIG & SETTINGS TAB — LUXURY NEXT-GEN AESTHETIC
   ========================================================================== */
.config-container {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* 1. AI MAGIC HERO CARD */
.ai-magic-card {
  background: #FFFFFF;
  border: 1px solid #E8ECE9;
  border-radius: 24px;
  padding: 32px 36px;
  box-shadow: 0 10px 30px -4px rgba(15, 23, 42, 0.04), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
  position: relative;
  overflow: hidden;
}

.ai-magic-card::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.ai-magic-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #F5F3FF;
  color: #7C3AED;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 6px 14px;
  border-radius: 9999px;
  margin-bottom: 14px;
  border: 1px solid #EDE9FE;
}

.ai-magic-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: #0F172A;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.ai-magic-subtitle {
  font-size: 14px;
  color: #64748B;
  line-height: 1.5;
  margin-bottom: 22px;
  max-width: 680px;
}

.ai-prompt-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F8FAF9;
  border: 1.5px solid #E2E8F0;
  border-radius: 9999px;
  padding: 6px 8px 6px 20px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.02);
}

.ai-prompt-bar:focus-within {
  border-color: #7C3AED;
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.ai-prompt-icon {
  color: #8B5CF6;
  font-size: 16px;
  flex-shrink: 0;
}

.ai-prompt-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  font-family: var(--font-body);
  color: #0F172A;
  font-weight: 500;
}

.ai-prompt-input::placeholder {
  color: #94A3B8;
}

.btn-ai-magic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0F172A;
  color: #FFFFFF;
  border: none;
  border-radius: 9999px;
  padding: 12px 24px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-ai-magic:hover {
  background: #1E293B;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.2);
}

.ai-chip-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.ai-chip-label {
  font-size: 12px;
  font-weight: 600;
  color: #94A3B8;
  margin-right: 4px;
}

.ai-chip-item {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 9999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-chip-item:hover {
  background: #EDE9FE;
  border-color: #DDD6FE;
  color: #6D28D9;
  transform: translateY(-1px);
}

/* 2. REFERRAL LINK & QR CARD */
.referral-card-luxury {
  background: #FFFFFF;
  border: 1px solid #E8ECE9;
  border-radius: 24px;
  padding: 32px 36px;
  box-shadow: 0 10px 30px -4px rgba(15, 23, 42, 0.04), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
}

.referral-card-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #F1F5F9;
}

.referral-header-left {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.referral-icon-pill {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #ECFDF5;
  color: #059669;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.referral-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.referral-title-row h3 {
  font-size: 18px;
  font-weight: 800;
  color: #0F172A;
  margin: 0;
}

.referral-badge-pill {
  background: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
  padding: 3px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 800;
  font-family: monospace;
  letter-spacing: 0.5px;
}

.referral-subtitle {
  font-size: 13px;
  color: #64748B;
  margin: 0;
}

.referral-grid-split {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 28px;
  align-items: start;
}

.referral-left-details {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-field-luxury {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label-luxury {
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
}

.handle-input-group {
  display: flex;
  align-items: stretch;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  background: #F8FAF9;
  overflow: hidden;
  transition: all 0.2s ease;
}

.handle-input-group:focus-within {
  border-color: #059669;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
  background: #FFFFFF;
}

.handle-prefix {
  display: flex;
  align-items: center;
  background: #F1F5F9;
  border-right: 1.5px solid #E2E8F0;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: #64748B;
  font-family: monospace;
}

.handle-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font-size: 14px;
  font-family: monospace;
  font-weight: 700;
  color: #059669;
  outline: none;
}

.btn-handle-update {
  background: #059669;
  color: #FFFFFF;
  border: none;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-handle-update:hover {
  background: #047857;
}

.handle-feedback-pill {
  font-size: 12px;
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  width: fit-content;
}

.handle-feedback-pill.success {
  background: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
}

.handle-feedback-pill.error {
  background: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FECACA;
}

.link-copy-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F8FAF9;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  padding: 6px 8px 6px 16px;
  transition: all 0.2s;
}

.link-copy-container:focus-within {
  border-color: #0284C7;
  background: #FFFFFF;
}

.link-input-pill {
  flex: 1;
  border: none;
  background: transparent;
  font-family: monospace;
  font-size: 13px;
  color: #0284C7;
  font-weight: 600;
  outline: none;
}

.btn-copy-pill {
  background: #0F172A;
  color: #FFFFFF;
  border: none;
  border-radius: 9999px;
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-copy-pill:hover {
  background: #1E293B;
  transform: translateY(-1px);
}

.message-preview-card {
  background: #F0FDF4;
  border: 1.5px solid #DCFCE7;
  border-radius: 16px;
  padding: 16px 20px;
}

.preview-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #059669;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-bubble {
  font-size: 13px;
  color: #1E293B;
  font-weight: 500;
  font-style: italic;
  line-height: 1.4;
}

.qr-pedestal-card {
  background: #F8FAF9;
  border: 1.5px solid #E8ECE9;
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-frame {
  background: #FFFFFF;
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  width: 164px;
  height: 164px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #E2E8F0;
}

.qr-render-box {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-render-box svg,
#referral-qr-container svg {
  width: 140px !important;
  height: 140px !important;
  max-width: 100% !important;
  max-height: 100% !important;
  display: block !important;
}

.qr-loading-text {
  color: #64748B;
  font-size: 12px;
  font-weight: 600;
}

.btn-download-qr-pill {
  background: #0F172A;
  color: #FFFFFF;
  border: none;
  border-radius: 9999px;
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-download-qr-pill:hover {
  background: #1E293B;
  transform: translateY(-1px);
}

/* 3. BOT SETTINGS CARD */
.bot-settings-card-luxury {
  background: #FFFFFF;
  border: 1px solid #E8ECE9;
  border-radius: 24px;
  padding: 32px 36px;
  box-shadow: 0 10px 30px -4px rgba(15, 23, 42, 0.04), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
}

.settings-card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #F1F5F9;
}

.settings-icon-pill {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #F1F5F9;
  color: #0F172A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.settings-card-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 4px;
}

.settings-card-header p {
  font-size: 13px;
  color: #64748B;
  margin: 0;
}

.input-luxury, .select-luxury, .textarea-luxury {
  width: 100%;
  padding: 12px 16px;
  background: #F8FAF9;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  font-size: 14px;
  font-family: var(--font-body);
  color: #0F172A;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
}

.input-luxury:focus, .select-luxury:focus, .textarea-luxury:focus {
  border-color: #059669;
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.toggle-card-luxury {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  background: #F8FAF9;
  border: 1.5px solid #E8ECE9;
  border-radius: 18px;
  margin: 20px 0;
}

.form-actions-luxury {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

.btn-save-luxury {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 32px;
  background: #0F172A;
  color: #FFFFFF;
  border: none;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.15);
}

.btn-save-luxury:hover {
  background: #1E293B;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}

.btn-save-luxury:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Settings */
.settings-section {
  padding: 20px 0;
  border-bottom: 1px solid #F1F5F9;
}

.settings-section:last-child { border-bottom: none; }

.settings-section h4 {
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}

.settings-section h4 i { color: var(--crm-brand); }

.plan-badge-large {
  display: inline-block;
  background: var(--crm-brand-light);
  color: var(--crm-brand-dark);
  font-size: 13px; font-weight: 800;
  padding: 6px 16px; border-radius: 20px;
  letter-spacing: 0.5px;
}

.settings-hint {
  font-size: 13px; color: var(--crm-text-muted); margin-top: 10px;
}

.settings-hint a { color: var(--crm-brand); text-decoration: none; }
.settings-hint a:hover { text-decoration: underline; }

.btn-outline-danger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid #FECACA;
  color: var(--crm-danger);
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline-danger:hover {
  background: #FEF2F2;
}

/* ==========================================================================
   RESPONSIVE — Mobile
   ========================================================================== */
@media (max-width: 768px) {
  .crm-sidebar {
    transform: translateX(-100%);
  }

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

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

  .crm-mobile-header {
    display: flex;
  }

  .crm-main {
    margin-left: 0;
    padding: 72px 16px 24px 16px;
  }

  .topbar-title { font-size: 20px; }
  .btn-topbar-label { display: none; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }

  .search-box { min-width: unset; flex: 1; }

  .form-grid-2 { grid-template-columns: 1fr; }

  .analytics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .filter-chips { gap: 6px; }
  .chip-btn { padding: 6px 12px; font-size: 12px; }
}

/* ==========================================================================
   LEAD DETAIL SLIDE-OUT DRAWER (Inspired by Reference UI)
   ========================================================================== */
.lead-drawer {
  position: fixed;
  top: 0;
  right: -480px;
  width: 460px;
  max-width: 100vw;
  height: 100vh;
  background: #FFFFFF;
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 1px solid #E2E8F0;
}

.lead-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 24px;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F8FAFC;
}

.drawer-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.drawer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #10B981;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
}

.drawer-name {
  font-size: 18px;
  font-weight: 800;
  color: #0F172A;
}

.drawer-phone {
  font-size: 13px;
  color: #64748B;
  font-weight: 600;
}

.drawer-close-btn {
  background: #F1F5F9;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #64748B;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.drawer-close-btn:hover {
  background: #E2E8F0;
  color: #0F172A;
}

.drawer-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid #E2E8F0;
}

.btn-drawer-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-drawer-act.wa {
  background: #25D366;
  color: #FFFFFF;
  border: none;
}

.btn-drawer-act.wa:hover {
  background: #20BA5A;
}

.btn-drawer-act.call {
  background: #2563EB;
  color: #FFFFFF;
  border: none;
}

.btn-drawer-act.call:hover {
  background: #1D4ED8;
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-card {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 16px;
}

.drawer-card-title {
  font-size: 12px;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.drawer-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.drawer-meta-item strong {
  display: block;
  font-size: 14px;
  color: #0F172A;
}

.drawer-meta-item span {
  font-size: 12px;
  color: #64748B;
}

.drawer-transcript-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.drawer-msg.customer {
  align-self: flex-start;
  background: #F1F5F9;
  color: #0F172A;
  border-bottom-left-radius: 2px;
}

.drawer-msg.ai {
  align-self: flex-end;
  background: #DCFCE7;
  color: #14532D;
  border-bottom-right-radius: 2px;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
}

.drawer-overlay.visible {
  display: block;
}

.clickable-row {
  cursor: pointer;
  transition: background 0.15s;
}

.clickable-row:hover {
  background: #F8FAFC;
}

/* ==========================================================================
   FORM & ORPHANED STYLES COMPATIBILITY (LUXURY REFINEMENT)
   ========================================================================== */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 12px 16px;
  background: #F8FAF9;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  font-size: 14px;
  font-family: var(--font-body);
  color: #0F172A;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: #059669;
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.form-field input[readonly],
.form-field input:read-only {
  background: #F1F5F9;
  color: #475569;
  cursor: default;
  border-color: #E2E8F0;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: 1.5px solid var(--crm-border);
  color: var(--crm-text);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline:hover {
  background: var(--crm-brand-light);
  border-color: var(--crm-brand);
  color: var(--crm-brand-dark);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #CBD5E1;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 24px;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #FFFFFF;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #10B981;
}

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

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-info strong {
  font-size: 14px;
  font-weight: 700;
  color: #0F172A;
}

.toggle-info p {
  font-size: 13px;
  color: #64748B;
  margin: 0;
}

.config-card {
  background: #FFFFFF;
  border: 1px solid #E8ECE9;
  border-radius: 24px;
  padding: 32px 36px;
  box-shadow: 0 10px 30px -4px rgba(15, 23, 42, 0.04), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
}

.config-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #F1F5F9;
}

.config-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #F1F5F9;
  color: #0F172A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.config-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 4px;
}

.config-header p {
  font-size: 13px;
  color: #64748B;
  margin: 0;
}

.ai-magic-header {
  margin-bottom: 24px;
}

.label-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--crm-text-secondary);
  margin-left: 4px;
}

.kpi-body {
  flex: 1;
  min-width: 0;
}

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

.sidebar-user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.up,
.kpi-trend.up {
  color: var(--crm-brand);
}

.text-emerald {
  color: #059669 !important;
}

/* ==========================================================================
   PLAN EXPIRY BANNER
   ========================================================================== */
.plan-expiry-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: 12px;
  color: #92400E;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
}

.plan-expiry-banner[hidden] {
  display: none !important;
}

.plan-expiry-banner.expired {
  background: #FEE2E2;
  border-color: #FCA5A5;
  color: #991B1B;
}

.plan-expiry-banner a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}

.plan-expiry-banner a:hover {
  opacity: 0.85;
}

.plan-expiry-banner-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  opacity: 0.7;
}

.plan-expiry-banner-close:hover {
  opacity: 1;
}

