/* ============================================
   Fusion AI — AI Chat SaaS Design System
   Premium dark theme with glassmorphism
   ============================================ */

/* Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
  /* Background */
  --bg-primary: #0a0a1a;
  --bg-secondary: #0f0f23;
  --bg-tertiary: #1a1a2e;
  --bg-card: rgba(26, 26, 46, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);
  --bg-input: rgba(255, 255, 255, 0.05);

  /* Accent */
  --accent-primary: #667eea;
  --accent-secondary: #764ba2;
  --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --accent-gradient-hover: linear-gradient(135deg, #7b93ff 0%, #8b5fbf 100%);
  --accent-glow: rgba(102, 126, 234, 0.3);

  /* Text */
  --text-primary: #e8e8f0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-accent: #667eea;

  /* Status */
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;

  /* Borders */
  --border-color: rgba(255, 255, 255, 0.06);
  --border-glass: rgba(255, 255, 255, 0.1);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(102, 126, 234, 0.15);

  /* Spacing */
  --sidebar-width: 280px;
  --header-height: 64px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: #7b93ff;
}

img {
  max-width: 100%;
  height: auto;
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Animated Background ── */
.bg-animated {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-animated::before,
.bg-animated::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.bg-animated::before {
  width: 400px;
  height: 400px;
  background: var(--accent-primary);
  top: -100px;
  right: -100px;
  opacity: 0.08;
}

.bg-animated::after {
  width: 500px;
  height: 500px;
  background: var(--accent-secondary);
  bottom: -150px;
  left: -100px;
  opacity: 0.06;
  animation-delay: -10s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }

  33% {
    transform: translate(30px, -30px) rotate(5deg);
  }

  66% {
    transform: translate(-20px, 20px) rotate(-3deg);
  }
}

/* ── Typography ── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 {
  font-size: 2.25rem;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.375rem;
}

h4 {
  font-size: 1.125rem;
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Form Controls ── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--danger);
  margin-top: 4px;
}

/* ── Glass Card ── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all var(--transition-base);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-free {
  background: rgba(107, 114, 128, 0.2);
  color: var(--text-secondary);
}

.badge-pro {
  background: rgba(102, 126, 234, 0.2);
  color: var(--accent-primary);
}

.badge-business {
  background: rgba(251, 191, 36, 0.2);
  color: var(--warning);
}

.badge-success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.badge-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

/* ── Tables ── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.data-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.data-table th.sortable {
  position: relative;
  padding-right: 32px;
  user-select: none;
}

.data-table th.sortable:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.data-table th.sortable::after {
  content: '↕';
  position: absolute;
  right: 12px;
  opacity: 0.3;
  font-size: 0.75rem;
}

.data-table th.sortable.sort-asc::after {
  content: '↑';
  opacity: 1;
  color: var(--accent-primary);
}

.data-table th.sortable.sort-desc::after {
  content: '↓';
  opacity: 1;
  color: var(--accent-primary);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text-primary);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
  min-width: 280px;
  max-width: 420px;
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-warning {
  border-left: 3px solid var(--warning);
}

.toast-info {
  border-left: 3px solid var(--info);
}

@keyframes toastIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.25rem;
}

.modal-close:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* ── Progress Bar ── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-glass);
  border-radius: 100px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 100px;
  transition: width var(--transition-slow);
}

.progress-fill.warning {
  background: linear-gradient(135deg, var(--warning), #f59e0b);
}

.progress-fill.danger {
  background: linear-gradient(135deg, var(--danger), #ef4444);
}

/* ── Spinner ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-glass);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Avatar ── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
  flex-shrink: 0;
}

.avatar-user {
  background: var(--accent-gradient);
  color: #fff;
}

.avatar-ai {
  background: linear-gradient(135deg, #34d399, #059669);
  color: #fff;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 1.25rem;
}

/* ============================================
   LANDING PAGE
   ============================================ */
.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 10, 26, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}

.landing-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 800;
}

.landing-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.landing-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 20px 60px;
  max-width: 800px;
  margin: 0 auto;
}

.landing-hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

.landing-hero p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
  line-height: 1.7;
  max-width: 600px;
}

.landing-hero-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 60px 40px 80px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.feature-card {
  text-align: center;
  padding: 32px 24px;
}

.feature-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.feature-card h3 {
  margin-bottom: 10px;
  font-size: 1.125rem;
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* ============================================
   AUTH PAGES (Login / Register)
   ============================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 40px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .landing-logo {
  justify-content: center;
  margin-bottom: 8px;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.auth-title {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 28px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* ============================================
   CHAT INTERFACE
   ============================================ */
.chat-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.chat-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-base);
  z-index: 100;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.new-chat-btn {
  width: 100%;
  padding: 10px;
  background: var(--bg-glass);
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.new-chat-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
  color: var(--text-secondary);
  position: relative;
}

.conversation-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.conversation-item.active {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.conversation-item .conv-icon {
  font-size: 1rem;
  opacity: 0.6;
  flex-shrink: 0;
}

.conversation-item .conv-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item .conv-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.conversation-item:hover .conv-delete {
  opacity: 1;
}

.conversation-item .conv-delete:hover {
  color: var(--danger);
}

/* Sidebar User Section */
.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-plan {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-user-actions {
  display: flex;
  gap: 4px;
}

.sidebar-user-actions .btn-ghost {
  padding: 6px;
  font-size: 1rem;
}

/* Chat Main Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.chat-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 8px;
}

.chat-header-title {
  font-size: 1rem;
  font-weight: 600;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--bg-glass);
  border-radius: 100px;
}

.token-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.token-dot.warning {
  background: var(--warning);
}

.token-dot.danger {
  background: var(--danger);
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.chat-empty-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: var(--shadow-glow);
}

.chat-empty h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.chat-empty p {
  color: var(--text-secondary);
  max-width: 400px;
  margin-bottom: 28px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 600px;
}

.suggestion-chip {
  padding: 10px 18px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 100px;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.suggestion-chip:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Message Bubbles */
.message {
  display: flex;
  gap: 14px;
  max-width: 800px;
  animation: messageIn 0.3s ease;
}

.message-user {
  flex-direction: row-reverse;
  margin-left: auto;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-content {
  flex: 1;
  max-width: 680px;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.message-user .message-bubble {
  background: var(--accent-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-ai .message-bubble {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-bottom-left-radius: 4px;
}

.message-bubble p {
  margin-bottom: 10px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: 'Fira Code', 'Consolas', monospace;
}

.message-bubble pre {
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  position: relative;
}

.message-bubble pre code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message-user .message-meta {
  justify-content: flex-end;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Chat Input Area */
.chat-input-area {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color var(--transition-fast);
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  outline: none;
  resize: none;
  line-height: 1.5;
  max-height: 150px;
  padding: 6px 0;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.send-btn {
  width: 38px;
  height: 38px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1.125rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.send-btn:hover {
  box-shadow: 0 4px 12px var(--accent-glow);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
  max-width: 800px;
  margin: 0 auto;
}

.model-selector label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.model-selector select {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  color: var(--text-secondary);
  padding: 4px 28px 4px 12px;
  font-size: 0.75rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.model-selector select option {
  background: var(--bg-secondary);
}

/* ============================================
   PROFILE PAGE
   ============================================ */
.page-layout {
  min-height: 100vh;
  padding-top: var(--header-height);
}

.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(10, 10, 26, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-header .sidebar-logo {
  margin-bottom: 0;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-nav a {
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.page-nav a:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.page-nav a.active {
  background: var(--bg-glass-hover);
  color: var(--accent-primary);
}

.page-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-title {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.page-subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* Profile Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-card .stat-detail {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ============================================
   ADMIN DASHBOARD
   ============================================ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-base);
}

.admin-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
}

.admin-nav-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.admin-nav-item.active {
  background: rgba(102, 126, 234, 0.1);
  color: var(--accent-primary);
}

.admin-nav-item .nav-icon {
  font-size: 1.125rem;
  width: 24px;
  text-align: center;
}

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
}

.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.admin-page-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* Admin Stats Row */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.admin-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 1024px) {
  .admin-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .admin-stats {
    grid-template-columns: 1fr;
  }
}

.admin-stat-card {
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.admin-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.admin-stat-icon.purple {
  background: rgba(102, 126, 234, 0.15);
  color: var(--accent-primary);
}

.admin-stat-icon.green {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.admin-stat-icon.yellow {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.admin-stat-icon.red {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.admin-stat-info .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.admin-stat-info .stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Search & Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 16px 10px 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

.search-input:focus {
  border-color: var(--accent-primary);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  transition: all var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle input:checked+.toggle-slider {
  background: var(--accent-primary);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(20px);
}

/* ── Sidebar overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1024px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
    padding: 24px 16px;
  }
}

@media (max-width: 768px) {

  /* Landing */
  .landing-nav {
    padding: 16px 20px;
  }

  .landing-hero h1 {
    font-size: 2.25rem;
  }

  .landing-hero p {
    font-size: 1rem;
  }

  .landing-features {
    grid-template-columns: 1fr;
    padding: 40px 20px 60px;
  }

  /* Chat */
  .chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-input-area {
    padding: 12px 16px 16px;
  }

  .message-bubble {
    padding: 12px 14px;
    font-size: 0.875rem;
  }

  .token-indicator span {
    display: none;
  }

  /* Page layout */
  .page-header {
    padding: 0 16px;
  }

  .page-nav {
    display: none;
  }

  .page-content {
    padding: 24px 16px;
  }

  .page-title {
    font-size: 1.375rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Admin */
  .admin-stats {
    grid-template-columns: 1fr 1fr;
  }

  .admin-page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-bar {
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .landing-hero h1 {
    font-size: 1.75rem;
  }

  .landing-hero-actions {
    flex-direction: column;
    width: 100%;
  }

  .landing-hero-actions .btn {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 28px 20px;
  }

  .suggestion-chips {
    flex-direction: column;
    align-items: stretch;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
    font-size: 0.8125rem;
  }
}

/* ── Utility Classes ── */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.mb-3 {
  margin-bottom: 24px;
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.gap-1 {
  gap: 8px;
}

.gap-2 {
  gap: 16px;
}

.hidden {
  display: none !important;
}

/* Voice Chat */
.mic-btn,
.tts-toggle {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  padding: 8px;
  border-radius: var(--radius-sm);
  position: relative;
}

.mic-btn:hover,
.tts-toggle:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.mic-btn.recording {
  color: var(--danger);
  animation: pulse 1.5s infinite;
}

.tts-toggle.muted {
  color: var(--text-muted);
}

.tts-toggle.muted::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 100%;
  background: var(--danger);
  transform: rotate(45deg);
  top: 0;
  left: 50%;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
}