/*
 * Main stylesheet — AI App Rescue
 */

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

:root {
  --black:   #0d0d0d;
  --white:   #ffffff;
  --gray-1:  #f5f5f4;
  --gray-2:  #e8e6e3;
  --gray-3:  #b0ada9;
  --gray-4:  #6b6966;
  --gray-5:  #3d3b39;
  --accent:  #c8410b;
  --accent-h:#a33509;
  --green:   #1a6b3c;
  --yellow:  #8a6200;
  --red:     #b81c1c;
  --font:    "system-ui", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:    ui-monospace, "SFMono-Regular", Menlo, monospace;
  --max:     72rem;
  --r:       0.375rem;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  color: var(--black);
  background: var(--white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

img, svg { display: block; max-width: 100%; }

/* ─── Layout ────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: 2.5rem;
}

/* ─── Nav ───────────────────────────────────────────────────────── */
.site-nav {
  border-bottom: 1px solid var(--gray-2);
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
  gap: 2rem;
}

.nav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--black);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.nav-logo:hover { text-decoration: none; color: var(--accent); }

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
}

.nav-links a {
  color: var(--gray-5);
  font-size: 0.9rem;
}
.nav-links a:hover { color: var(--black); text-decoration: none; }

.nav-cta {
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 0;
  padding: 0.5rem;
  cursor: pointer;
  width: 2.5rem;
  height: 2.5rem;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.nav-toggle-bar {
  display: block;
  width: 1.4rem;
  height: 2px;
  background: var(--black);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

@media (max-width: 768px) {
  .site-nav .container { gap: 0.5rem; }
  .nav-toggle { display: flex; }
  .nav-menu {
    display: none;
    position: absolute;
    top: 3.5rem;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--white);
    border-bottom: 1px solid var(--gray-2);
    padding: 1rem 1.5rem 1.5rem;
    gap: 1rem;
  }
  .site-nav.nav-open .nav-menu { display: flex; }
  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    width: 100%;
  }
  .nav-links a {
    display: block;
    padding: 0.625rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--gray-2);
  }
  .nav-cta { width: 100%; }
  .site-nav.nav-open .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .site-nav.nav-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
  .site-nav.nav-open .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  border-radius: var(--r);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); text-decoration: none; color: var(--white); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: var(--white); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--gray-5);
  border-color: var(--gray-3);
}
.btn-ghost:hover { background: var(--gray-1); text-decoration: none; }

.btn-sm { padding: 0.4rem 0.875rem; font-size: 0.8rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }

/* ─── Hero ──────────────────────────────────────────────────────── */
.hero {
  padding: 7rem 0 6rem;
  border-bottom: 1px solid var(--gray-2);
}

.hero-eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  max-width: 38rem;
  margin-bottom: 1.25rem;
}

.hero-sub {
  font-size: 1.125rem;
  color: var(--gray-4);
  max-width: 36rem;
  margin-bottom: 2rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

/* ─── Sections ──────────────────────────────────────────────────── */
section { padding: 5.5rem 0; }
section + section { border-top: 1px solid var(--gray-2); }

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-3);
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.section-body {
  font-size: 1rem;
  color: var(--gray-4);
  max-width: 40rem;
  line-height: 1.75;
}

/* ─── Grid ──────────────────────────────────────────────────────── */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
}

/* ─── Cards ─────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--gray-2);
  border-radius: calc(var(--r) * 2);
  padding: 1.75rem;
  background: var(--white);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.card-body {
  color: var(--gray-4);
  font-size: 0.9rem;
  line-height: 1.65;
}

/* ─── Pricing cards ─────────────────────────────────────────────── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
  align-items: start;
}

.pricing-card {
  border: 1px solid var(--gray-2);
  border-radius: calc(var(--r) * 2);
  padding: 2rem;
  background: var(--white);
}

.pricing-card.featured {
  border-color: var(--accent);
  border-width: 2px;
}

.pricing-tier {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-3);
  margin-bottom: 0.25rem;
}

.pricing-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.pricing-price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--black);
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.pricing-price span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-3);
}

.pricing-desc {
  color: var(--gray-4);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.pricing-list {
  list-style: none;
  margin-bottom: 1.75rem;
}

.pricing-list li {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.875rem;
  color: var(--gray-5);
  padding: 0.3rem 0;
}

.pricing-list li::before {
  content: "✓";
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.05em;
}

/* ─── Steps ─────────────────────────────────────────────────────── */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
  counter-reset: step;
}

.step {
  counter-increment: step;
}

.step-num {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--gray-1);
  border: 2px solid var(--gray-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--gray-5);
  margin-bottom: 0.75rem;
}

.step-num::before { content: counter(step); }

.step-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.step-body {
  font-size: 0.875rem;
  color: var(--gray-4);
  line-height: 1.6;
}

/* ─── Callout boxes ─────────────────────────────────────────────── */
.callout {
  border-radius: var(--r);
  padding: 1.25rem 1.5rem;
  font-size: 0.9rem;
  line-height: 1.65;
  margin: 1.5rem 0;
}

.callout-warn {
  background: #fff8e1;
  border-left: 4px solid #f59e0b;
  color: #713f00;
}

.callout-danger {
  background: #fff1f0;
  border-left: 4px solid var(--red);
  color: #7b1515;
}

.callout-info {
  background: #eef6ff;
  border-left: 4px solid #3b82f6;
  color: #1e3a5f;
}

.callout-success {
  background: #f0fdf4;
  border-left: 4px solid var(--green);
  color: #14532d;
}

/* ─── Risk zone badges ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-green  { background: #dcfce7; color: var(--green); }
.badge-yellow { background: #fef9c3; color: var(--yellow); }
.badge-red    { background: #fee2e2; color: var(--red); }
.badge-gray   { background: var(--gray-1); color: var(--gray-4); }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }

/* ─── Forms ─────────────────────────────────────────────────────── */
.form-wrap {
  max-width: 42rem;
  margin: 0 auto;
}

.form-section {
  margin-bottom: 2rem;
}

.form-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-2);
  color: var(--gray-5);
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-5);
  margin-bottom: 0.35rem;
}

.field label .required {
  color: var(--accent);
  margin-left: 0.15em;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="url"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-2);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--black);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 65, 11, 0.12);
}

.field textarea { resize: vertical; min-height: 6rem; }

.field .hint {
  font-size: 0.8rem;
  color: var(--gray-3);
  margin-top: 0.25rem;
}

.field.error input,
.field.error select,
.field.error textarea {
  border-color: var(--red);
}

.field .error-msg {
  font-size: 0.8rem;
  color: var(--red);
  margin-top: 0.25rem;
}

/* Checkbox / radio groups */
.check-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  line-height: 1.5;
}

.check-label input[type="checkbox"],
.check-label input[type="radio"] {
  margin-top: 0.15em;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Tier selector */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.tier-option input { display: none; }

.tier-option label {
  display: block;
  border: 2px solid var(--gray-2);
  border-radius: var(--r);
  padding: 0.875rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s;
  font-weight: 600;
  font-size: 0.875rem;
}

.tier-option input:checked + label {
  border-color: var(--accent);
  background: #fff5f2;
  color: var(--accent);
}

/* File upload */
.file-drop {
  border: 2px dashed var(--gray-2);
  border-radius: var(--r);
  padding: 2rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--gray-4);
  cursor: pointer;
  transition: border-color 0.15s;
}

.file-drop:hover { border-color: var(--accent); }

/* ─── Flash messages ────────────────────────────────────────────── */
.flash {
  padding: 0.875rem 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: var(--r);
  font-size: 0.9rem;
}

.flash-notice { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.flash-alert  { background: #fff1f0; border: 1px solid #fecaca; color: #991b1b; }

/* ─── Table ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gray-3);
  border-bottom: 2px solid var(--gray-2);
  padding: 0.6rem 0.75rem;
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--gray-1);
  color: var(--gray-5);
  vertical-align: top;
}

tr:hover td { background: var(--gray-1); }

/* ─── Footer ────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--gray-2);
  padding: 2.5rem 0;
  font-size: 0.8rem;
  color: var(--gray-3);
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  flex-wrap: wrap;
}

.footer-links a { color: var(--gray-3); font-size: 0.8rem; }
.footer-links a:hover { color: var(--black); text-decoration: none; }

/* ─── Page header ───────────────────────────────────────────────── */
.page-header {
  padding: 4rem 0 2.5rem;
  border-bottom: 1px solid var(--gray-2);
  margin-bottom: 3.5rem;
}

.page-header h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--gray-4);
  font-size: 1rem;
  max-width: 38rem;
}

/* ─── Prose ─────────────────────────────────────────────────────── */
.prose h2 { font-size: 1.25rem; font-weight: 700; margin: 2rem 0 0.5rem; }
.prose h3 { font-size: 1rem; font-weight: 700; margin: 1.5rem 0 0.4rem; }
.prose p  { color: var(--gray-5); line-height: 1.75; margin-bottom: 1rem; }
.prose ul, .prose ol { color: var(--gray-5); padding-left: 1.5rem; margin-bottom: 1rem; }
.prose li { line-height: 1.7; margin-bottom: 0.25rem; }
.prose a  { color: var(--accent); }

/* ─── Admin layout ──────────────────────────────────────────────── */
.admin-wrap {
  display: flex;
  min-height: calc(100vh - 3.5rem);
}

.admin-sidebar {
  width: 14rem;
  flex-shrink: 0;
  border-right: 1px solid var(--gray-2);
  padding: 1.5rem 1rem;
  background: var(--gray-1);
}

.admin-sidebar nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r);
  font-size: 0.875rem;
  color: var(--gray-5);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
  background: var(--gray-2);
  color: var(--black);
  text-decoration: none;
}

.admin-sidebar .sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-3);
  padding: 0 0.75rem;
  margin: 1rem 0 0.4rem;
}

.admin-main {
  flex: 1;
  padding: 2rem;
  overflow-x: auto;
  max-width: calc(var(--max) - 14rem);
}

.admin-main h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.admin-main h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ─── Detail rows ───────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.detail-section {
  border: 1px solid var(--gray-2);
  border-radius: calc(var(--r) * 2);
  padding: 1.5rem;
}

.detail-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-3);
  margin-bottom: 1rem;
}

.detail-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.4rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--gray-1);
}

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

.detail-label {
  color: var(--gray-3);
  min-width: 9rem;
  flex-shrink: 0;
}

.detail-value {
  color: var(--gray-5);
  word-break: break-word;
}

/* ─── Stat cards ────────────────────────────────────────────────── */
.stat-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  border: 1px solid var(--gray-2);
  border-radius: var(--r);
  padding: 1rem 1.5rem;
  min-width: 9rem;
}

.stat-num {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.15rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--gray-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ─── Utilities ─────────────────────────────────────────────────── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--gray-3); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.block { display: block; }
.flex { display: flex; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

@media (max-width: 640px) {
  .tier-grid { grid-template-columns: 1fr; }
  .admin-wrap { flex-direction: column; }
  .admin-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--gray-2); }
  .hero { padding: 3rem 0 2.5rem; }
}
