@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #19092e; /* Very dark depth background */
  --bg-secondary: #2d1050; /* Deep Violet: Hero background, footer, depth */
  --bg-tertiary: #421875; /* Depth/mid purple border/card blend */
  
  --border-color: rgba(221, 200, 240, 0.15); /* Pale Lilac transparent */
  --border-focus: #7a3ab0; /* Mid Purple: Hover states, section labels */
  
  --text-primary: #ddc8f0; /* Pale Lilac: Backgrounds, icon wraps, badges */
  --text-secondary: #b080d0; /* Soft Lavender: Highlights, hero text gradient */
  --text-muted: #6b6b8a; /* Slate Gray: Body text */
  
  --accent-purple: #5a2090; /* Royal Purple: Primary brand, buttons, accents */
  --accent-violet: #7a3ab0; /* Mid Purple: Hover states */
  --accent-gradient: linear-gradient(135deg, #5a2090, #b080d0); /* Royal Purple to Soft Lavender */
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

body.light-mode {
  --bg-primary: #f5f2f9; /* Pale Lilac/lavender tinted background */
  --bg-secondary: #ffffff;
  --bg-tertiary: #ddc8f0; /* Pale Lilac: Backgrounds, icon wraps, badges */
  
  --border-color: rgba(90, 32, 144, 0.15); /* Royal Purple transparent */
  --border-focus: #5a2090; /* Royal Purple */
  
  --text-primary: #2d1050; /* Deep Violet: Hero background, footer, depth */
  --text-secondary: #5a2090; /* Royal Purple: Primary brand */
  --text-muted: #6b6b8a; /* Slate Gray: Body text */
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}


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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-purple);
}

/* App Layout */
.app-container {
  display: flex;
  height: 100vh;
  max-width: 100%;
  overflow: hidden;
}


/* Sidebar */
aside.sidebar {
  width: 260px;
  height: 100%;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
  overflow-y: auto;
}

aside.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 32px;
}

aside.sidebar .nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

aside.sidebar .nav-links li a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all 0.2s ease;
}

aside.sidebar .nav-links li a:hover,
aside.sidebar .nav-links li.active a {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

aside.sidebar .nav-links li.active a {
  border-left: 3px solid var(--accent-purple);
}

aside.sidebar .user-info {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.user-meta {
  overflow: hidden;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Main Content Area */
main.main-content {
  flex-grow: 1;
  padding: 40px;
  overflow-y: auto;
  height: 100%;
  width: 100%;
}

/* Tab Panel Transitions */
.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

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

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

/* Header Elements */
.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title h1 {
  font-size: 28px;
  font-weight: 700;
}

.page-title p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Cards & Glassmorphism */
.grid-cols-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(90, 32, 144, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-purple);
  font-size: 20px;
}

.stat-data h3 {
  font-size: 24px;
  font-weight: 700;
}

.stat-data p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* General Layouts */
.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
}

.content-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
}

.content-box h2 {
  font-size: 18px;
  margin-bottom: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 12px 16px;
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent-purple);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s ease;
}

.btn:disabled {
  cursor: not-allowed !important;
  opacity: 0.6;
  filter: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

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

.btn-danger:hover {
  filter: brightness(1.1);
}

/* Lists & Tables */
.table-container {
  overflow-x: auto;
}

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

table.data-table th, 
table.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

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

table.data-table tbody tr {
  transition: background-color 0.2s ease;
}

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

.badge {
  display: inline-flex;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: rgba(90, 32, 144, 0.15); color: var(--accent-purple); }

/* Billing Trial Alert */
.trial-banner {
  background: linear-gradient(90deg, rgba(90, 32, 144, 0.15), rgba(176, 128, 208, 0.15));
  border: 1px solid var(--border-focus);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Floating Chat Page & Standalone Chat Design */
.chat-container {
  max-width: 800px;
  margin: 40px auto;
  height: 600px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

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

.chat-body {
  flex-grow: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
}

.msg {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

.msg-visitor {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.msg-assistant {
  background: var(--msg-asst-bg, rgba(90, 32, 144, 0.1));
  border: 1px solid var(--msg-asst-border, rgba(90, 32, 144, 0.2));
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

/* Widget Styles for Embeds */
.captivate-widget-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent-gradient);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999999;
  transition: transform 0.2s ease;
}

.captivate-widget-bubble:hover {
  transform: scale(1.05);
}

.captivate-widget-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 520px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-main);
  color: var(--text-primary);
}

/* Stylish Dialog Modals */
.stylish-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.stylish-dialog-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.stylish-dialog {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 440px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stylish-dialog-overlay.active .stylish-dialog {
  transform: scale(1);
}
.stylish-dialog-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.stylish-dialog-body p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.stylish-dialog-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.stylish-dialog-footer .btn {
  padding: 8px 16px;
  font-size: 13px;
}

/* Mobile Responsiveness Rules */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  aside.sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
  }
  aside.sidebar .logo {
    margin-bottom: 16px;
    justify-content: center;
  }
  aside.sidebar .nav-links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
  aside.sidebar .nav-links li a {
    padding: 8px 12px;
    font-size: 13px;
  }
  aside.sidebar .nav-links li.active a {
    border-left: none;
    border-bottom: 3px solid var(--accent-purple);
  }
  aside.sidebar .user-info {
    margin-top: 16px;
    padding-top: 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
  }
  aside.sidebar .user-info button {
    width: auto !important;
  }
  main.main-content {
    padding: 20px 16px;
    height: auto;
    overflow-y: visible;
  }
  .content-grid {
    grid-template-columns: 1fr !important;
    gap: 20px;
    width: 100%;
  }
  .content-box {
    padding: 16px;
    width: 100%;
    overflow: hidden;
  }
  .table-container {
    width: 100%;
    overflow-x: auto;
    display: block;
    -webkit-overflow-scrolling: touch;
  }
  table.data-table {
    min-width: 650px;
  }
  table.data-table th, 
  table.data-table td {
    padding: 10px 8px;
    font-size: 13px;
  }
  .grid-cols-4 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    gap: 16px;
  }
  .trial-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .trial-banner button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  aside.sidebar .nav-links {
    grid-template-columns: 1fr 1fr;
    display: grid;
  }
  aside.sidebar .nav-links li a {
    justify-content: center;
  }
  aside.sidebar .user-info {
    flex-direction: column;
    align-items: stretch;
  }
  aside.sidebar .user-info button {
    width: 100% !important;
  }
  .grid-cols-4 {
    grid-template-columns: 1fr !important;
  }
  .header-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .header-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

