/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #4F46E5;
  --brand-dark:  #3730a3;
  --brand-light: #eef2ff;
  --success:     #059669;
  --danger:      #dc2626;
  --warning:     #d97706;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-300:    #d1d5db;
  --gray-400:    #9ca3af;
  --gray-500:    #6b7280;
  --gray-600:    #4b5563;
  --gray-700:    #374151;
  --gray-800:    #1f2937;
  --gray-900:    #111827;
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.05);
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Auth page ───────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f0f0ff 0%, #f9fafb 60%);
}

.auth-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--gray-100);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--brand-light);
  border-radius: 14px;
  margin-bottom: 14px;
  color: var(--brand);
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.3px;
}

.auth-logo p {
  font-size: 14px;
  color: var(--gray-400);
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  transition: background .15s, color .15s;
  user-select: none;
}

.auth-tab.active {
  background: #fff;
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  appearance: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--gray-300); }

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 110px;
  font-family: inherit;
  line-height: 1.6;
}

.char-count {
  font-size: 12px;
  color: var(--gray-400);
  text-align: right;
  margin-top: 4px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, opacity .15s, border-color .15s;
  letter-spacing: -.1px;
}

.btn svg { flex-shrink: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  width: 100%;
  box-shadow: 0 1px 3px rgba(79,70,229,.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
  box-shadow: 0 3px 8px rgba(79,70,229,.35);
}

.btn-outline {
  background: #fff;
  border: 1.5px solid var(--gray-200);
  color: var(--gray-700);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }

.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ── Dashboard layout ────────────────────────────────────────────────────── */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 248px;
  background: #fff;
  border-right: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-900);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.sidebar-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--brand);
  border-radius: 9px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: background .12s, color .12s;
  margin-bottom: 2px;
  user-select: none;
}

.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--brand-light); color: var(--brand); }
.nav-item.active svg { color: var(--brand); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-100);
}

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

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

.sidebar-user-info { min-width: 0; }
.sidebar-email {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 6px 0;
  transition: color .12s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.sidebar-logout:hover { color: var(--danger); }

/* ── Main content ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: 248px;
  flex: 1;
  padding: 36px 40px;
  max-width: calc(900px + 248px);
}

.page-header {
  margin-bottom: 28px;
}
.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.3px;
}
.page-header p {
  font-size: 14px;
  color: var(--gray-400);
  margin-top: 3px;
}

/* ── Section visibility ───────────────────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg { color: var(--gray-400); }

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon-violet { background: var(--brand-light); color: var(--brand); }
.stat-icon-green  { background: #f0fdf4; color: var(--success); }
.stat-icon-amber  { background: #fffbeb; color: var(--warning); }

.stat-label { font-size: 12px; font-weight: 500; color: var(--gray-400); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--gray-900); line-height: 1.1; }
.stat-sub   { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* ── Plan badge ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-free { background: var(--gray-100); color: var(--gray-600); }
.badge-pro  { background: #fef3c7; color: #92400e; }

/* ── Snippet box ──────────────────────────────────────────────────────────── */
.snippet-wrap {
  position: relative;
  margin: 14px 0;
}

.snippet-box {
  background: var(--gray-900);
  color: #a5f3fc;
  border-radius: var(--radius);
  padding: 16px 18px;
  font-family: "SF Mono", "Fira Code", "Fira Mono", monospace;
  font-size: 13px;
  overflow-x: auto;
  word-break: break-all;
  line-height: 1.7;
  border: 1px solid rgba(255,255,255,.04);
}

.snippet-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.7);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.snippet-copy-btn:hover { background: rgba(255,255,255,.18); color: #fff; }

/* ── Color row ────────────────────────────────────────────────────────────── */
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] {
  width: 44px; height: 40px; padding: 3px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  cursor: pointer;
  background: #fff;
}
.color-row input[type="text"] { flex: 1; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--gray-100);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

/* ── Plan cards ───────────────────────────────────────────────────────────── */
.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.plan-card {
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 2px solid var(--gray-200);
  transition: border-color .15s;
}

.plan-card.current { border-color: var(--brand); background: var(--brand-light); }

.plan-name { font-weight: 700; font-size: 15px; color: var(--gray-800); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.plan-name.pro-name { color: var(--brand); }

.plan-price {
  font-size: 32px;
  font-weight: 800;
  color: var(--gray-900);
  margin: 12px 0;
  line-height: 1;
}
.plan-price span { font-size: 15px; font-weight: 400; color: var(--gray-400); }

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--gray-600);
}

.plan-features li svg { color: var(--success); flex-shrink: 0; }

/* ── Recent conversations table ───────────────────────────────────────────── */
.conv-table { width: 100%; }

.conv-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}

.conv-row:last-child { border-bottom: none; }

.conv-session {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-700);
  font-family: monospace;
  font-size: 13px;
}

.conv-session svg { color: var(--gray-300); flex-shrink: 0; }

.conv-messages {
  font-size: 13px;
  color: var(--gray-500);
  white-space: nowrap;
}

.conv-date {
  font-size: 13px;
  color: var(--gray-400);
  white-space: nowrap;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 32px 24px;
  color: var(--gray-400);
}
.empty-state svg { margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Preview area ─────────────────────────────────────────────────────────── */
.preview-area {
  background: var(--gray-100);
  border-radius: var(--radius);
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px dashed var(--gray-300);
}

.preview-site-label {
  font-size: 13px;
  color: var(--gray-300);
  font-weight: 500;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.preview-widget-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
  cursor: pointer;
  color: #fff;
  transition: transform .2s;
}
.preview-widget-btn:hover { transform: scale(1.06); }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.section-divider {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-100);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .plan-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
