/* GrantDraft — Professional nonprofit styling */
:root {
  --navy: #1a365d;
  --navy-light: #2a4a7f;
  --navy-dark: #0f2340;
  --gold: #d69e2e;
  --gold-light: #ecc94b;
  --gold-dark: #b7791f;
  --white: #ffffff;
  --gray-50: #f7fafc;
  --gray-100: #edf2f7;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e0;
  --gray-400: #a0aec0;
  --gray-500: #718096;
  --gray-600: #4a5568;
  --gray-700: #2d3748;
  --gray-800: #1a202c;
  --green: #38a169;
  --red: #e53e3e;
  --blue: #3182ce;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  background: var(--navy);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-logo span {
  color: var(--gold);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-nav button {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.header-nav button:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
}

.header-nav .btn-gold {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--navy);
  font-weight: 600;
}

.header-nav .btn-gold:hover {
  background: var(--gold-light);
}

.credits-badge {
  background: rgba(255,255,255,0.15);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.hero {
  text-align: center;
  padding: 48px 24px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: white;
  margin: -24px -24px 32px;
}

.hero h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.hero p {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.8);
  max-width: 600px;
  margin: 0 auto;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  border: 1px solid var(--gray-200);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
}

/* ── Form ─────────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
}

.form-group label .required {
  color: var(--red);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(26,54,93,0.1);
}

.form-group textarea { resize: vertical; min-height: 80px; }

/* ── Section Picker ───────────────────────────────────────────────────────── */
.section-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.section-option {
  padding: 14px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.section-option:hover {
  border-color: var(--navy-light);
  background: var(--gray-50);
}

.section-option.selected {
  border-color: var(--navy);
  background: rgba(26,54,93,0.05);
}

.section-option h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.section-option p {
  font-size: 0.72rem;
  color: var(--gray-500);
}

.section-option .price {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--gold-dark);
  margin-top: 6px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--navy);
  color: white;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-primary:disabled { background: var(--gray-400); cursor: not-allowed; }

.btn-gold {
  background: var(--gold);
  color: var(--navy);
}
.btn-gold:hover { background: var(--gold-light); }

.btn-outline {
  background: white;
  border: 2px solid var(--navy);
  color: var(--navy);
}
.btn-outline:hover { background: var(--gray-50); }

.btn-sm { padding: 8px 16px; font-size: 0.8rem; }

/* ── Output ───────────────────────────────────────────────────────────────── */
.output-panel {
  margin-top: 24px;
}

.output-content {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 24px;
  font-size: 0.95rem;
  line-height: 1.8;
  white-space: pre-wrap;
  min-height: 200px;
  max-height: 600px;
  overflow-y: auto;
}

.output-content h2 { font-size: 1.15rem; color: var(--navy); margin: 16px 0 8px; }
.output-content h3 { font-size: 1rem; color: var(--navy-light); margin: 12px 0 6px; }
.output-content strong { color: var(--gray-800); }

.output-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.word-count {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-left: auto;
}

/* ── Loading ──────────────────────────────────────────────────────────────── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.loading-overlay.active { display: flex; }

.loading-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ── Auth Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: white;
  padding: 32px;
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal h3 {
  font-size: 1.2rem;
  color: var(--navy);
  margin-bottom: 20px;
  text-align: center;
}

.modal .form-group { margin-bottom: 14px; }
.modal .btn { width: 100%; justify-content: center; }
.modal .toggle-link {
  text-align: center;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--blue);
  cursor: pointer;
}

/* ── Federal Template Banner ──────────────────────────────────────────────── */
.template-banner {
  background: linear-gradient(135deg, rgba(26,54,93,0.05), rgba(214,158,46,0.05));
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.template-banner .icon { font-size: 1.3rem; }
.template-banner .text { font-size: 0.85rem; color: var(--navy); font-weight: 500; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .section-picker { grid-template-columns: 1fr 1fr; }
  .hero h2 { font-size: 1.5rem; }
  .header { flex-direction: column; gap: 12px; }
  .header-nav { width: 100%; justify-content: center; }
}

/* ── Packages ─────────────────────────────────────────────────────────────── */
.packages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.package-card {
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.package-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.package-card.popular {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(214,158,46,0.03), rgba(214,158,46,0.08));
}

.package-card h4 { color: var(--navy); font-size: 0.95rem; margin-bottom: 8px; }
.package-card .price { font-size: 1.5rem; font-weight: 800; color: var(--gold-dark); }
.package-card .per { font-size: 0.75rem; color: var(--gray-500); }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: 10px;
  color: white;
  font-weight: 500;
  font-size: 0.9rem;
  z-index: 400;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.active { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
