:root {
  --bg-dark: #090d16;
  --panel-bg: rgba(17, 25, 40, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --accent: #25d366; /* WhatsApp Green */
  --accent-gradient: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  --primary: #4f46e5; /* Indigo */
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --input-bg: rgba(255, 255, 255, 0.04);
  --input-text: white;
  --glow-left: rgba(37, 211, 102, 0.08);
  --glow-right: rgba(79, 70, 229, 0.08);
  --logo-gradient: linear-gradient(to right, #ffffff, #9ca3af);
  --btn-secondary-bg: rgba(255, 255, 255, 0.06);
  --header-bg: rgba(9, 13, 22, 0.8);
}

[data-theme="indigo"] {
  --bg-dark: #070913;
  --panel-bg: rgba(13, 17, 33, 0.75);
  --border-color: rgba(99, 102, 241, 0.12);
  --accent: #6366f1;
  --accent-gradient: linear-gradient(135deg, #818cf8 0%, #4f46e5 100%);
  --glow-left: rgba(99, 102, 241, 0.1);
  --glow-right: rgba(168, 85, 247, 0.1);
  --btn-secondary-bg: rgba(255, 255, 255, 0.06);
  --header-bg: rgba(7, 9, 19, 0.8);
}

[data-theme="sunset"] {
  --bg-dark: #0f0a05;
  --panel-bg: rgba(26, 17, 10, 0.75);
  --border-color: rgba(245, 158, 11, 0.1);
  --accent: #f59e0b;
  --accent-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  --glow-left: rgba(245, 158, 11, 0.08);
  --glow-right: rgba(239, 68, 68, 0.08);
  --btn-secondary-bg: rgba(255, 255, 255, 0.06);
  --header-bg: rgba(15, 10, 5, 0.8);
}

[data-theme="light"] {
  --bg-dark: #f8fafc;
  --panel-bg: rgba(255, 255, 255, 0.9);
  --border-color: rgba(0, 0, 0, 0.08);
  --accent: #0ea5e9;
  --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  --primary: #4f46e5;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --input-bg: rgba(0, 0, 0, 0.02);
  --input-text: #0f172a;
  --glow-left: rgba(14, 165, 233, 0.05);
  --glow-right: rgba(79, 70, 229, 0.05);
  --logo-gradient: linear-gradient(to right, #0f172a, #64748b);
  --btn-secondary-bg: rgba(0, 0, 0, 0.05);
  --header-bg: rgba(255, 255, 255, 0.8);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, var(--glow-left) 0px, transparent 50%),
    radial-gradient(at 100% 100%, var(--glow-right) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

header {
  backdrop-filter: blur(12px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0.65rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.logo-icon {
  background: var(--accent-gradient);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
}

.logo-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--logo-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Theme Selector UI dots */
.theme-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
}

.theme-dot:hover {
  transform: scale(1.2);
}

.theme-dot.active {
  border-color: white;
  box-shadow: 0 0 8px currentColor;
}

[data-theme="light"] .theme-dot.active {
  border-color: #0f172a;
}

.theme-dot.emerald {
  background-color: #25d366;
  color: #25d366;
}

.theme-dot.indigo {
  background-color: #6366f1;
  color: #6366f1;
}

.theme-dot.sunset {
  background-color: #f59e0b;
  color: #f59e0b;
}

.theme-dot.light {
  background-color: #cbd5e1;
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: #0ea5e9;
}

.logo-text span {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main-container {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 1rem auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .main-container {
    grid-template-columns: 320px 1fr;
  }
}

/* Glassmorphic Panel Cards */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
  min-width: 0;
}

.panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

/* Connection Card Details */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  align-self: flex-start;
}

.status-badge.connected {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.qr-ready {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.initializing {
  background: rgba(79, 70, 229, 0.15);
  color: #818cf8;
  border: 1px solid rgba(79, 70, 229, 0.3);
}

.status-badge.disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* QR Code Display Container */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  min-height: 250px;
}

#qr-canvas {
  background: white;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  margin-bottom: 1rem;
}

.qr-placeholder {
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.15);
  margin-bottom: 1rem;
  animation: pulse 2s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.08); opacity: 0.8; }
}

/* Sessions Table styling */
.table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.bot {
  background: rgba(37, 211, 102, 0.1);
  color: var(--accent);
  border: 1px solid rgba(37, 211, 102, 0.2);
}

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

/* Form styling */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

input, textarea, select {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  color: var(--input-text);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  color: white;
}

.btn-primary {
  background: var(--accent-gradient);
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35);
}

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

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

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

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-xs {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.actions-cell {
  display: flex;
  gap: 0.5rem;
}

/* Logs Modal & Overlay Panels */
.logs-panel {
  max-height: 350px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.log-item {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.log-item.inbound {
  border-left: 3px solid var(--accent);
}

.log-item.outbound {
  border-left: 3px solid var(--primary);
}

.log-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  justify-content: space-between;
}

.log-content {
  color: var(--text-main);
  white-space: pre-wrap;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  max-width: 600px;
  width: 100%;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
}

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

.modal-close {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.25rem;
}

.modal-close:hover {
  color: white;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* Footer styling */
footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 10000;
  max-width: 380px;
  width: 100%;
}

.toast {
  background: rgba(17, 25, 40, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.active {
  transform: translateX(0);
}

.toast-icon {
  font-size: 1.25rem;
}

.toast-success {
  border-left: 4px solid var(--success);
}
.toast-success .toast-icon {
  color: var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}
.toast-error .toast-icon {
  color: var(--danger);
}

.toast-info {
  border-left: 4px solid var(--primary);
}
.toast-info .toast-icon {
  color: var(--primary);
}

.toast-content {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  flex: 1;
}

.toast-close {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
}

.toast-close:hover {
  color: white;
}

/* Mobile responsive card list */
.sessions-cards {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.session-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
  gap: 0.5rem;
}

.session-card-detail {
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}

.session-card-detail span:last-child {
  color: var(--text-main);
  font-weight: 500;
  word-break: break-all;
}

.session-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Media query to switch table/cards */
@media (max-width: 768px) {
  .table-container {
    display: none;
  }
  .sessions-cards {
    display: flex;
  }
  header {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    text-align: center;
  }
  .logo-container {
    justify-content: center;
  }
  .main-container {
    padding: 0 1rem;
    margin: 1rem auto;
  }
  .panel {
    padding: 1.25rem;
  }
}

/* Dashboard Stats Grid */
.stats-grid {
  max-width: 1400px;
  width: 100%;
  margin: 1rem auto 0 auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .stats-grid {
    padding: 0 1rem;
    margin: 1rem auto 0 auto;
  }
}

.stat-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--accent);
}

.stat-card:nth-child(2) .stat-icon {
  color: #818cf8;
}

.stat-card:nth-child(3) .stat-icon {
  color: #f59e0b;
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

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

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
}

.stat-sub {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.15rem;
}

/* Provider Pill Header Badge */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.provider-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.provider-pill.meta {
  background: rgba(24, 119, 242, 0.15);
  color: #1877f2;
  border-color: rgba(24, 119, 242, 0.3);
}

.provider-pill.gupshup {
  background: rgba(14, 165, 233, 0.15);
  color: #0ea5e9;
  border-color: rgba(14, 165, 233, 0.3);
}

.provider-pill.whatsapp-web {
  background: rgba(37, 211, 102, 0.15);
  color: #25d366;
  border-color: rgba(37, 211, 102, 0.3);
}

select option {
  background-color: var(--bg-dark);
  color: white;
}

/* Stepper progress tracker styling */
.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.stepper-step::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border-color);
  z-index: 1;
}

.stepper-step:last-child::after {
  display: none;
}

.step-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  z-index: 2;
  transition: all 0.3s;
}

.step-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-align: center;
}

.stepper-step.completed .step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-dark);
}

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

.stepper-step.active .step-circle {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.stepper-step.active .step-label {
  color: var(--text-main);
  font-weight: 700;
}

/* Quick reply chips */
.quick-reply-chip {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.6rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.quick-reply-chip:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-dark);
}

