/* ─── BookMint Design System ─────────────────────────── */
:root {
  --bg-deep: #0a0a0f;
  --bg-card: #12121a;
  --bg-elevated: #1a1a26;
  --mint: #3dffa2;
  --mint-dim: #2bcc80;
  --mint-glow: rgba(61, 255, 162, 0.15);
  --gold: #ffd666;
  --gold-dim: #c9a84c;
  --text-primary: #f0f0f5;
  --text-secondary: #8a8a9a;
  --text-muted: #5a5a6a;
  --border: #222233;
  --danger: #ff4d6a;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

h1, h2, h3, h4, h5 { font-family: 'Space Grotesk', sans-serif; }

a { color: var(--mint); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.8; }

/* ─── Nav ──────────────────────────────────────────── */
.app-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 10, 15, 0.88);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.nav-logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--mint), var(--mint-dim));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #0a0a0f;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: all 0.2s;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  opacity: 1;
}

.nav-link.active {
  color: var(--mint);
  background: rgba(61, 255, 162, 0.06);
}

.nav-cta {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #0a0a0f;
  background: linear-gradient(135deg, var(--mint), var(--mint-dim));
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s;
  margin-left: 0.5rem;
}

.nav-cta:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--mint-glow);
}

/* ─── Page Layout ──────────────────────────────────── */
.page {
  padding-top: 5rem;
  min-height: 100vh;
}

.page-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem 2rem;
}

.page-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--mint-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.page-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.page-desc {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 600px;
  line-height: 1.7;
}

.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
}

/* ─── Cards ────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  transition: all 0.25s;
}

.card:hover {
  border-color: rgba(61, 255, 162, 0.2);
  transform: translateY(-2px);
}

.card.selected {
  border-color: var(--mint);
  background: linear-gradient(135deg, rgba(61, 255, 162, 0.04), transparent);
  box-shadow: 0 0 30px rgba(61, 255, 162, 0.08);
}

/* ─── Buttons ──────────────────────────────────────── */
.btn {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.75rem 1.75rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--mint), var(--mint-dim));
  color: #0a0a0f;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--mint-glow);
  opacity: 1;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.btn-secondary:hover {
  border-color: var(--mint);
  color: var(--mint);
  opacity: 1;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #0a0a0f;
}

.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(255, 214, 102, 0.2);
  opacity: 1;
}

.btn-sm {
  padding: 0.5rem 1.25rem;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 1rem 2.5rem;
  font-size: 1rem;
}

/* ─── Form Inputs ──────────────────────────────────── */
.input-group {
  margin-bottom: 1.5rem;
}

.input-label {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}

.input {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  padding: 0.85rem 1.15rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
}

.input:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(61, 255, 162, 0.1);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a8a9a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ─── Template Grid ────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.template-card {
  cursor: pointer;
  position: relative;
}

.template-emoji {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.template-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.template-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.template-pages {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-family: 'Space Grotesk', sans-serif;
}

.template-check {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--mint);
  color: #0a0a0f;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.template-card.selected .template-check {
  display: flex;
}

/* ─── Generator Panel ──────────────────────────────── */
.generator-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
  align-items: start;
}

.gen-sidebar {
  position: sticky;
  top: 6rem;
}

.gen-config {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
}

.gen-config h3 {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Journal Preview ──────────────────────────────── */
.preview-area {
  min-height: 400px;
}

.preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  text-align: center;
  color: var(--text-muted);
}

.preview-empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.preview-empty h3 {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.preview-empty p {
  font-size: 0.9rem;
  max-width: 320px;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  text-align: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--mint);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  color: var(--text-secondary);
}

.loading-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Journal Page Renders */
.journal-pages {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.journal-page {
  background: #faf9f6;
  border-radius: 12px;
  padding: 2.5rem;
  color: #1a1a1a;
  position: relative;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  min-height: 450px;
  font-family: 'DM Sans', sans-serif;
}

.journal-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--mint), var(--gold));
  border-radius: 12px 12px 0 0;
}

.page-number {
  position: absolute;
  bottom: 1rem;
  right: 1.5rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  color: #aaa;
}

/* Cover Page */
.jp-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 500px;
  background: linear-gradient(170deg, #0a0a0f 0%, #12121a 50%, #1a1a26 100%);
  color: var(--text-primary);
}

.jp-cover .cover-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--mint), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.jp-cover .cover-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.jp-cover .cover-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 1rem;
}

.jp-cover .cover-brand {
  position: absolute;
  bottom: 1.5rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* Interior Pages */
.jp-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #e8e6e0;
}

.jp-quote {
  font-style: italic;
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  padding-left: 1rem;
  border-left: 3px solid #3dffa2;
}

.jp-prompt {
  color: #555;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  font-style: italic;
}

.jp-section {
  margin-bottom: 1.5rem;
}

.jp-section-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}

/* Lined areas */
.jp-lines {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.jp-line {
  height: 2rem;
  border-bottom: 1px solid #ddd;
}

/* Checklists */
.jp-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.jp-check-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: #333;
}

.jp-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid #bbb;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Rating */
.jp-rating {
  display: flex;
  gap: 0.4rem;
}

.jp-star {
  width: 24px;
  height: 24px;
  border: 1.5px solid #ccc;
  border-radius: 50%;
}

/* Tables */
.jp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.jp-table th {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid #ddd;
  text-align: left;
}

.jp-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #eee;
  height: 2rem;
}

/* Numbered List */
.jp-numbered {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  counter-reset: item;
}

.jp-numbered-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #eee;
}

.jp-num {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  color: #999;
  width: 1.5rem;
  flex-shrink: 0;
}

/* Habit Grid */
.jp-habit-grid {
  display: grid;
  grid-template-columns: 1fr repeat(7, 28px);
  gap: 4px;
  align-items: center;
  font-size: 0.82rem;
}

.jp-habit-name {
  font-weight: 500;
  color: #333;
  padding-right: 0.5rem;
}

.jp-habit-cell {
  width: 28px;
  height: 28px;
  border: 1.5px solid #ddd;
  border-radius: 4px;
}

.jp-day-header {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  color: #999;
  text-align: center;
}

/* Meal Grid */
.jp-meal-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1px;
  background: #ddd;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}

.jp-meal-day {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  color: #444;
  background: #f0eeea;
  padding: 0.6rem 0.75rem;
  display: flex;
  align-items: center;
}

.jp-meal-slots {
  background: #faf9f6;
  padding: 0.4rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.jp-meal-slot {
  font-size: 0.8rem;
  color: #999;
  padding: 0.2rem 0;
  border-bottom: 1px dotted #ddd;
}

/* Fields */
.jp-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.jp-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.jp-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #777;
  font-family: 'Space Grotesk', sans-serif;
}

.jp-field-input {
  height: 1.75rem;
  border-bottom: 1px solid #ccc;
}

/* Paragraphs / Tips */
.jp-paragraph {
  font-size: 0.9rem;
  color: #444;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.jp-tips {
  margin-top: 1rem;
}

.jp-tip {
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.5rem;
}

.jp-tip::before {
  content: '✦';
  color: var(--mint);
  flex-shrink: 0;
}

/* Affirmations */
.jp-affirmations {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.jp-affirmation {
  font-size: 0.95rem;
  color: #333;
  padding: 0.75rem 1rem;
  background: #f3f1ec;
  border-radius: 8px;
  border-left: 3px solid var(--mint);
  font-style: italic;
}

/* Goals */
.jp-goals {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.jp-goal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid #eee;
}

.jp-goal-name {
  font-weight: 500;
  color: #333;
}

.jp-goal-target {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: #2bcc80;
}

/* Categories */
.jp-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.jp-category {
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
  background: #f0eeea;
  border-radius: 20px;
  color: #555;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
}

/* Grocery List */
.jp-grocery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.jp-grocery-cat {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 0.5rem;
}

/* ─── Shop ─────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.product-card {
  position: relative;
  overflow: hidden;
}

.product-emoji {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.product-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.product-niche {
  font-size: 0.8rem;
  color: var(--mint-dim);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.product-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.product-price {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.product-price .cents {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.bundle-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #0a0a0f;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Success Page ─────────────────────────────────── */
.success-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 2rem;
}

.success-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
}

.success-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.success-desc {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 450px;
  margin-bottom: 2rem;
  line-height: 1.7;
}

/* ─── Footer ───────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.app-footer a {
  color: var(--text-secondary);
}

/* ─── Utilities ────────────────────────────────────── */
.text-mint { color: var(--mint); }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }

/* ─── Preview toolbar ──────────────────────────────── */
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.preview-info {
  display: flex;
  flex-direction: column;
}

.preview-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1rem;
}

.preview-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Mobile ───────────────────────────────────────── */
@media (max-width: 900px) {
  .generator-layout {
    grid-template-columns: 1fr;
  }

  .gen-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .app-nav {
    padding: 0.85rem 1.25rem;
  }

  .nav-links {
    gap: 0;
  }

  .nav-link {
    padding: 0.4rem 0.6rem;
    font-size: 0.78rem;
  }

  .nav-cta {
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
  }

  .page-header {
    padding: 2rem 1.25rem 1.5rem;
  }

  .page-content {
    padding: 0 1.25rem 3rem;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .jp-fields {
    grid-template-columns: 1fr;
  }

  .jp-grocery-grid {
    grid-template-columns: 1fr;
  }
}
