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

:root {
  --background: #f7f5fb;
  --foreground: #4a4458;
  --muted-foreground: #6e6580;
  --card: #ffffff;
  --sidebar: #f0edf6;
  --border: #dcd6e6;
  --purple-50: #faf5ff;
  --purple-100: #f3e8ff;
  --purple-200: #e9d5ff;
  --purple-500: #a855f7;
  --purple-600: #9333ea;
  --purple-700: #7e22ce;
  --purple-800: #6b21a8;
  --radius: 12px;
  color-scheme: light;
}

body.dark {
  --background: #1c1a26;
  --foreground: #e6e1f0;
  --muted-foreground: #a79fbb;
  --card: #262331;
  --sidebar: #2a2735;
  --border: #3a3548;
  --purple-50: #2a2138;
  --purple-100: #33263f;
  color-scheme: dark;
}
body.dark .bg-dots {
  background-image: radial-gradient(#393e4a 1px, transparent 1px);
}
body.dark .navbar.scrolled {
  background: rgba(28, 26, 38, 0.9);
}
body.dark .kbd-hint kbd { background: #322c40; }
body.dark .template-btn { background: rgba(38, 35, 49, 0.8); }
body.dark .hero-logo img { filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4)); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
}

.bg-dots {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(#dadde2 1px, transparent 1px);
  background-size: 16px 16px;
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  padding: 1rem;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: all .2s ease;
}
.navbar.scrolled {
  background: rgba(247, 245, 251, 0.9);
  border-bottom: 1px solid rgba(168, 85, 247, 0.15);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.navbar-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.brand-logo-wrap { position: relative; display: flex; }
.brand-name {
  font-weight: 600;
  font-size: 1.125rem;
  background: linear-gradient(90deg, var(--purple-600), var(--purple-800));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-buttons { display: flex; gap: 0.75rem; align-items: center; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition: all .15s ease;
}
.theme-toggle:hover { background: var(--purple-50); }
.theme-toggle .icon-moon { display: none; }
body.dark .theme-toggle .icon-sun { display: none; }
body.dark .theme-toggle .icon-moon { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all .15s ease;
  border: 1px solid transparent;
}
.btn-outline {
  border-color: var(--purple-200);
  color: var(--purple-700);
  background: transparent;
}
.btn-outline:hover { background: var(--purple-50); }
.btn-primary {
  background: var(--purple-600);
  color: #fff;
}
.btn-primary:hover { background: var(--purple-700); }

/* Page / hero */
.page {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
}
.hero {
  padding: 12vh 0 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}
.hero-logo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-logo-glow {
  position: absolute;
  inset: -1rem;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.2);
  filter: blur(20px);
}
.hero-logo img { position: relative; z-index: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1)); }

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  max-width: 42rem;
  line-height: 1.15;
  background: linear-gradient(90deg, var(--purple-500), var(--purple-700));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
}
@media (min-width: 768px) {
  .hero-title { font-size: 3.75rem; }
}
.hero-subtitle {
  font-size: 1.125rem;
  text-align: center;
  color: var(--muted-foreground);
  max-width: 36rem;
  margin: 0;
}

/* Form */
.project-form { width: 100%; max-width: 48rem; display: flex; flex-direction: column; gap: 1.5rem; }
.form-box {
  position: relative;
  border: 1px solid var(--border);
  padding: 1.5rem;
  border-radius: 1rem;
  background: var(--sidebar);
  backdrop-filter: blur(4px);
  transition: all .2s ease;
}
.form-box.focused {
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
}
.prompt-textarea {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 1.125rem;
  font-family: inherit;
  color: var(--foreground);
  padding-top: 0.5rem;
  min-height: 4.5rem;
}
.form-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 1rem;
}
.kbd-hint {
  font-size: 11px;
  font-family: monospace;
  color: var(--muted-foreground);
}
.kbd-hint kbd {
  display: inline-block;
  padding: 0 0.4rem;
  height: 1.5rem;
  line-height: 1.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #eee9f5;
  font-size: 11px;
}
.submit-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: none;
  background: var(--purple-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
}
.submit-btn:hover:not(:disabled) { background: var(--purple-700); }
.submit-btn:disabled {
  background: #b9b3c6;
  opacity: .7;
  cursor: not-allowed;
}

.templates {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  max-width: 48rem;
}
@media (min-width: 768px) { .templates { display: flex; } }

.template-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--purple-200);
  background: rgba(255,255,255,0.8);
  font-size: 0.875rem;
  color: var(--foreground);
  cursor: pointer;
  transition: all .2s ease;
}
.template-btn:hover { background: var(--purple-50); }
.template-btn .emoji { margin-right: 0.5rem; }

.projects-list { padding: 2rem 0 5rem; }
.empty-state { text-align: center; color: var(--muted-foreground); }

/* Cookie banner */
.cookie-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  max-width: 42rem;
  margin: 0 auto 1rem;
  padding: 0 1rem;
}
.cookie-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.cookie-text {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  flex: 1 1 16rem;
}
.cookie-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.cookie-panel {
  margin-top: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  max-height: 60vh;
  overflow-y: auto;
}
.cookie-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.cookie-tab {
  border: none;
  background: transparent;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.cookie-tab.active {
  color: var(--purple-700);
  border-bottom-color: var(--purple-600);
  font-weight: 600;
}
.cookie-tab-content { display: none; font-size: 0.875rem; color: var(--foreground); line-height: 1.6; }
.cookie-tab-content.active { display: block; }
.cookie-tab-content h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.cookie-panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem 1rem;
}
.auth-brand { gap: 0.5rem; }
.auth-card {
  width: 100%;
  max-width: 26rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.auth-title { margin: 0 0 0.25rem; font-size: 1.5rem; font-weight: 700; text-align: center; }
.auth-subtitle { margin: 0 0 1.5rem; text-align: center; color: var(--muted-foreground); font-size: 0.9rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--muted-foreground); }
.auth-form input {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.95rem;
  font-family: inherit;
}
.auth-form input:focus { outline: none; border-color: var(--purple-500); }
.btn-block { width: 100%; padding: 0.65rem; font-size: 0.95rem; margin-top: 0.25rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: 0.85rem; color: var(--muted-foreground); }
.auth-footer a { color: var(--purple-600); text-decoration: none; font-weight: 600; }
.auth-error {
  background: #fdecec;
  border: 1px solid #f3b9b9;
  color: #a33;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.auth-error p { margin: 0.2rem 0; }
body.dark .auth-error { background: #3a2323; border-color: #6b3333; color: #f3b9b9; }

.user-pill {
  font-size: 0.85rem;
  color: var(--foreground);
  background: var(--purple-50);
  border: 1px solid var(--purple-200);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
}

/* Projects grid on home */
.projects-heading { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
}
.project-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  text-decoration: none;
  color: var(--foreground);
  transition: all .15s ease;
}
.project-card:hover { border-color: var(--purple-500); box-shadow: 0 2px 10px rgba(168,85,247,0.12); }
.project-card-prompt { margin: 0; font-size: 0.9rem; }
.project-card-status { font-size: 0.75rem; color: var(--muted-foreground); }

/* Project view page */
.project-page {
  max-width: 72rem;
  margin: 5.5rem auto 2rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.project-prompt { color: var(--muted-foreground); font-size: 0.9rem; }
.project-status {
  padding: 1rem;
  border-radius: 0.75rem;
  background: var(--sidebar);
  border: 1px solid var(--border);
}
.project-status-error { color: #a33; }
.project-tabs { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--border); }
.project-tab {
  border: none;
  background: transparent;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: var(--muted-foreground);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.project-tab.active { color: var(--purple-700); border-bottom-color: var(--purple-600); font-weight: 600; }
.project-view { display: none; }
.project-view.active { display: block; }
.preview-frame {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #fff;
}
.code-block {
  background: #1e1b26;
  color: #e6e1f0;
  padding: 1.25rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  font-size: 0.8rem;
  max-height: 70vh;
  overflow-y: auto;
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
