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

:root {
  --bg: #080810;
  --bg2: #0d0d1a;
  --bg3: #12122a;
  --card: #0f0f20;
  --card2: #141428;
  --border: #1e1e3a;
  --border2: #252545;
  --primary: #6366f1;
  --primary-glow: #6366f140;
  --secondary: #8b5cf6;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Inter', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── BACKGROUND GRID ─────────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(99,102,241,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; position: relative; z-index: 1; }

/* ── NAVBAR ──────────────────────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(8,8,16,0.8);
  backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 100;
}
.nav-brand {
  font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  text-decoration: none;
}
.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a { color: var(--text2); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }

/* ── HERO ────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center; padding: 6rem 1.5rem 4rem;
  position: relative;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--primary-glow); border: 1px solid var(--primary);
  color: var(--primary); font-size: 0.8rem; font-weight: 600;
  padding: 0.35rem 0.9rem; border-radius: 100px;
  margin-bottom: 2rem; letter-spacing: 0.05em; text-transform: uppercase;
}
.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800; letter-spacing: -0.03em; line-height: 1.1;
  margin-bottom: 1.5rem;
}
.hero h1 span {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub {
  font-size: 1.1rem; color: var(--text2); max-width: 600px; margin: 0 auto 3rem;
  font-weight: 400; line-height: 1.7;
}
.hero-glow {
  position: absolute; top: 10%; left: 50%; transform: translateX(-50%);
  width: 600px; height: 400px;
  background: radial-gradient(ellipse, rgba(99,102,241,0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── STATS BAR ───────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex; justify-content: center; gap: 3rem;
  padding: 1.5rem; margin-bottom: 4rem;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.stat { text-align: center; }
.stat-num { font-size: 1.8rem; font-weight: 800; color: var(--primary); font-family: var(--mono); }
.stat-label { font-size: 0.75rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── SECTION HEADERS ─────────────────────────────────────────────────────── */
.section-title {
  font-size: 1.8rem; font-weight: 700; text-align: center;
  margin-bottom: 0.5rem; letter-spacing: -0.02em;
}
.section-sub { text-align: center; color: var(--text2); margin-bottom: 3rem; }

/* ── TEMPLATE CARDS ──────────────────────────────────────────────────────── */
.templates-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem; margin-bottom: 6rem;
}
.template-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 2rem;
  cursor: pointer; transition: all 0.3s ease;
  position: relative; overflow: hidden;
  text-decoration: none; color: inherit;
  display: block;
}
.template-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--primary-glow), transparent);
  opacity: 0; transition: opacity 0.3s;
}
.template-card:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: 0 20px 60px rgba(99,102,241,0.15); }
.template-card:hover::before { opacity: 1; }
.template-card-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; margin-bottom: 1.2rem;
  background: var(--card2); border: 1px solid var(--border2);
}
.template-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.template-card p { font-size: 0.88rem; color: var(--text2); line-height: 1.6; }
.template-card-badge {
  display: inline-block; margin-top: 1rem;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.25rem 0.65rem; border-radius: 100px;
  background: var(--primary-glow); color: var(--primary); border: 1px solid var(--primary);
}
.template-card-badge.coming { background: rgba(100,116,139,0.1); color: var(--text3); border-color: var(--border2); cursor: default; }
.template-card.disabled { opacity: 0.6; pointer-events: none; }

/* ── FEATURES ────────────────────────────────────────────────────────────── */
.features { padding: 5rem 0; border-top: 1px solid var(--border); }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; }
.feature-item {
  padding: 1.5rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px;
}
.feature-icon { font-size: 1.5rem; margin-bottom: 0.8rem; }
.feature-item h4 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.feature-item p { font-size: 0.85rem; color: var(--text2); }

/* ── FOOTER ──────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border); padding: 2rem 1.5rem;
  text-align: center; color: var(--text3); font-size: 0.85rem;
}
footer a { color: var(--primary); text-decoration: none; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; border-radius: 10px;
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  border: none; transition: all 0.2s; text-decoration: none; font-family: var(--sans);
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(99,102,241,0.4); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }
.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: rgba(239,68,68,0.2); }
.btn-sm { padding: 0.45rem 1rem; font-size: 0.82rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── GENERATE PAGE ───────────────────────────────────────────────────────── */
.gen-page { min-height: 100vh; display: flex; flex-direction: column; }
.gen-header { padding: 2rem 1.5rem 1rem; border-bottom: 1px solid var(--border); }
.gen-header .breadcrumb { font-size: 0.82rem; color: var(--text3); margin-bottom: 0.8rem; }
.gen-header .breadcrumb a { color: var(--primary); text-decoration: none; }
.gen-header h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; }
.gen-header p { color: var(--text2); font-size: 0.9rem; margin-top: 0.3rem; }
.gen-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.gen-form-panel { padding: 2.5rem 2rem; border-right: 1px solid var(--border); overflow-y: auto; }
.gen-preview-panel { padding: 2.5rem 2rem; background: var(--bg2); display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ── FORM STYLES ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text2); margin-bottom: 0.5rem; letter-spacing: 0.02em; }
.form-label span.req { color: var(--primary); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.75rem 1rem;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 10px; color: var(--text);
  font-family: var(--sans); font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-select option { background: var(--bg3); }
.form-hint { font-size: 0.78rem; color: var(--text3); margin-top: 0.4rem; }

.theme-picker { display: flex; gap: 0.75rem; margin-top: 0.5rem; }
.theme-opt {
  flex: 1; padding: 0.8rem; border-radius: 10px; border: 2px solid var(--border2);
  background: var(--bg3); cursor: pointer; transition: all 0.2s; text-align: center; font-size: 0.82rem;
}
.theme-opt:hover { border-color: var(--border); }
.theme-opt.active { border-color: var(--primary); background: var(--primary-glow); }
.theme-opt .theme-icon { font-size: 1.4rem; display: block; margin-bottom: 0.3rem; }
.theme-opt .theme-name { font-weight: 600; font-size: 0.8rem; }

/* ── PROGRESS / STATUS ───────────────────────────────────────────────────── */
.gen-status { display: none; text-align: center; padding: 2rem; }
.gen-status.show { display: block; }
.spinner {
  width: 48px; height: 48px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 1.2rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status-steps { list-style: none; text-align: left; max-width: 280px; margin: 1.5rem auto 0; }
.status-step { padding: 0.5rem 0; font-size: 0.85rem; color: var(--text3); display: flex; align-items: center; gap: 0.6rem; }
.status-step.done { color: var(--success); }
.status-step.active { color: var(--text); }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ── PREVIEW PANEL ───────────────────────────────────────────────────────── */
.preview-placeholder {
  text-align: center; padding: 3rem 2rem;
  border: 2px dashed var(--border2); border-radius: 16px;
  max-width: 320px; width: 100%;
}
.preview-placeholder .ph-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.preview-placeholder p { color: var(--text3); font-size: 0.88rem; }
.preview-ready { text-align: center; }
.preview-pdf-thumb {
  width: 200px; background: white; border-radius: 8px; padding: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5); margin: 0 auto 1.5rem; aspect-ratio: 0.707;
  display: flex; flex-direction: column; gap: 6px;
}
.thumb-line { height: 6px; border-radius: 3px; background: #e2e8f0; }
.thumb-line.heading { width: 60%; background: #6366f1; height: 8px; }
.thumb-line.short { width: 40%; }
.thumb-line.xs { width: 25%; }
.preview-filename { font-family: var(--mono); font-size: 0.78rem; color: var(--text3); margin-bottom: 1.5rem; }
.preview-info { font-size: 0.82rem; color: var(--text2); margin-bottom: 1.5rem; }

/* ── ERROR TOAST ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 9999;
  padding: 1rem 1.5rem; border-radius: 12px; font-size: 0.88rem; font-weight: 500;
  display: flex; align-items: center; gap: 0.6rem; max-width: 400px;
  animation: slideUp 0.3s ease; box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.toast-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.toast-success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
@keyframes slideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }

/* ── ADMIN STYLES ────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--card); border-right: 1px solid var(--border);
  padding: 1.5rem 0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-logo {
  padding: 0 1.5rem 1.5rem; font-size: 1.2rem; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}
.sidebar-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text3); padding: 0.5rem 1.5rem; }
.sidebar-link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.65rem 1.5rem; color: var(--text2); text-decoration: none;
  font-size: 0.88rem; font-weight: 500; transition: all 0.2s; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.sidebar-link:hover, .sidebar-link.active { background: var(--primary-glow); color: var(--primary); }
.sidebar-link svg { width: 16px; height: 16px; }
.admin-main { flex: 1; padding: 2rem; overflow-y: auto; }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.panel-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.3rem; letter-spacing: -0.02em; }
.panel-sub { color: var(--text2); font-size: 0.88rem; margin-bottom: 2rem; }

/* ── ADMIN CARDS ─────────────────────────────────────────────────────────── */
.admin-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; }
.admin-card-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem; }
.stat-card-num { font-size: 2rem; font-weight: 800; font-family: var(--mono); color: var(--primary); }
.stat-card-label { font-size: 0.78rem; color: var(--text3); margin-top: 0.2rem; text-transform: uppercase; letter-spacing: 0.06em; }

/* ── KEY ITEMS ───────────────────────────────────────────────────────────── */
.key-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.key-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.8rem 1rem; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px;
}
.key-item.disabled-key { opacity: 0.5; }
.key-label { font-weight: 600; font-size: 0.88rem; flex: 1; }
.key-meta { font-size: 0.75rem; color: var(--text3); font-family: var(--mono); }
.key-status { padding: 0.2rem 0.6rem; border-radius: 100px; font-size: 0.72rem; font-weight: 600; }
.status-ok { background: rgba(16,185,129,0.1); color: var(--success); }
.status-rl { background: rgba(239,68,68,0.1); color: var(--danger); }
.status-cd { background: rgba(245,158,11,0.1); color: var(--warning); }
.status-off { background: rgba(100,116,139,0.1); color: var(--text3); }

/* ── ADD KEY FORM ────────────────────────────────────────────────────────── */
.add-key-form { display: flex; gap: 0.75rem; align-items: flex-end; }
.add-key-form .form-group { flex: 1; margin-bottom: 0; }

/* ── LOGIN ───────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 400px;
}
.login-logo {
  font-size: 1.5rem; font-weight: 800; text-align: center; margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-sub { text-align: center; color: var(--text3); font-size: 0.85rem; margin-bottom: 2rem; }

/* ── TOGGLE SWITCH ───────────────────────────────────────────────────────── */
.switch { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.switch input { display: none; }
.switch-track {
  width: 40px; height: 22px; border-radius: 11px; background: var(--border2);
  position: relative; transition: background 0.2s;
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch-track::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: white;
  transition: transform 0.2s;
}
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch-label { font-size: 0.88rem; color: var(--text2); }

/* ── COLOR SWATCH ────────────────────────────────────────────────────────── */
.color-row { display: flex; align-items: center; gap: 0.75rem; }
.color-row input[type=color] { width: 40px; height: 40px; border: 1px solid var(--border2); border-radius: 8px; cursor: pointer; padding: 2px; background: var(--bg3); }

/* ── MISC ────────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.tag { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.72rem; font-weight: 600; }
.tag-primary { background: var(--primary-glow); color: var(--primary); }
.tag-groq { background: rgba(6,182,212,0.1); color: var(--accent); }
.mono { font-family: var(--mono); }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; } .items-center { align-items: center; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; } .justify-between { justify-content: space-between; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .gen-body { grid-template-columns: 1fr; }
  .gen-preview-panel { display: none; }
  .admin-sidebar { display: none; }
  .stats-bar { gap: 1.5rem; }
  .navbar { padding: 1rem; }
  .nav-links { display: none; }
}
