/* Exaforce shared design tokens + base component styles */

/* Cross-document view transitions — native fade between pages (Chrome/Edge 126+) */
@view-transition { navigation: auto; }

@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* --- Design tokens (dark — default) --- */
/* Neutral scale: Tailwind zinc. Accent: Tailwind blue. */
:root {
  --bg: #09090b;        /* zinc-950 */
  --surface: #18181b;   /* zinc-900 */
  --surface-2: #27272a; /* zinc-800 */
  --border: #27272a;    /* zinc-800 */
  --text: #e4e4e7;      /* zinc-200 */
  --text-dim: #a1a1aa;  /* zinc-400 */
  --accent: #3b82f6;    /* blue-500 */
  --accent-hover: #60a5fa; /* blue-400 */
  --nav-width: 280px;
}

/* --- Light theme (system default) --- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fafafa;        /* zinc-50  */
    --surface: #ffffff;   /* white    */
    --surface-2: #f4f4f5; /* zinc-100 */
    --border: #e4e4e7;    /* zinc-200 */
    --text: #18181b;      /* zinc-900 */
    --text-dim: #71717a;  /* zinc-500 */
    --accent-hover: #2563eb; /* blue-600 */
  }
}

/* --- Light theme (forced) --- */
:root[data-theme="light"] {
  --bg: #fafafa;        /* zinc-50  */
  --surface: #ffffff;   /* white    */
  --surface-2: #f4f4f5; /* zinc-100 */
  --border: #e4e4e7;    /* zinc-200 */
  --text: #18181b;      /* zinc-900 */
  --text-dim: #71717a;  /* zinc-500 */
  --accent-hover: #2563eb; /* blue-600 */
}

/* --- Base --- */
body {
  font-family: 'Inter Tight', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 999;
}

/* --- Section label --- */
.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--text-dim);
  margin-top: 8px;
  padding-bottom: 6px;
}

/* Section labels inside tool pages keep the divider line; nav labels do not */
.page-content .section-label {
  border-bottom: 1px solid var(--border);
}

/* --- Beta badge --- */
.badge-beta {
  display: inline-flex;
  align-items: center;
  font-family: 'Inter Tight', Arial, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  top: -1px;
  margin-left: 8px;
}

/* --- Form fields --- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-dim); }
.field-optional-badge { font-size: 10px; font-weight: 400; opacity: 0.6; }

.field input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: 'Inter Tight', Arial, sans-serif;
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.field input::placeholder { color: #71717a; /* zinc-500 — dark mode */ }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .field input::placeholder { color: #b4b4bb; /* lighter on white */ }
}
:root[data-theme="light"] .field input::placeholder { color: #b4b4bb; }

/* --- Toggle switch --- */
.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-switch.on { background: var(--accent); border-color: var(--accent); }

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.toggle-switch.on::after { transform: translateX(16px); }

/* --- Buttons --- */
.actions { display: flex; gap: 8px; margin-top: 8px; }

.btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  font-family: 'Inter Tight', Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,0.3); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-dim); }

/* --- Toast notification --- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(70px);
  background: var(--accent);
  color: #fff;
  padding: 10px 22px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Typography scale --- */
/* Apply to any element: <h1 class="text-xl">, <p class="text-sm">, etc. */
.text-2xl { font-size: 28px; font-weight: 600; letter-spacing: -0.5px; line-height: 1.2; }
.text-xl  { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; line-height: 1.2; }
.text-lg  { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.3; }
.text-md  { font-size: 15px; font-weight: 500; letter-spacing: -0.1px; line-height: 1.4; }
.text-sm  { font-size: 13px; font-weight: 400; line-height: 1.5; }
.text-xs  { font-size: 11px; font-weight: 400; line-height: 1.6; }

/* --- Page layout --- */
.page {
  max-width: 1100px;
  padding: 48px 48px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.page-title {
  color: var(--text);
}

.page-caption {
  margin-top: 6px;
  max-width: 560px;
  color: var(--text-dim);
}

@media (max-width: 768px) {
  .page { padding: 24px 18px; }
}

/* --- Navigation --- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--nav-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 16px;
  z-index: 100;
  overflow-y: auto;
}

.page-content {
  margin-left: var(--nav-width);
  min-height: 100vh;
}

.nav-top {
  display: flex;
  flex-direction: column;
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.nav-logo:hover { opacity: 0.8; }

.nav-logo-tag {
  font-family: 'Inter Tight', Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  padding: 5px 7px;
  border-radius: 6px;
  line-height: 1;
}

.nav-logo-img {
  height: 22px;
  width: auto;
  display: block;
  /* Dark mode default: invert black SVG to white */
  filter: brightness(0) invert(1);
  transition: filter 0.2s;
}

/* Light mode (system) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .nav-logo-img {
    filter: none;
  }
}

/* Light mode (forced) */
:root[data-theme="light"] .nav-logo-img {
  filter: none;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
}

.nav-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-request-btn {
  text-align: center;
  text-decoration: none;
  display: block;
  flex: unset;
}

.nav-copyright {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.6;
  text-align: center;
}

/* --- Theme selector --- */
.theme-selector {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.theme-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 0;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-btn:hover { color: var(--text); }

.theme-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.nav-close { display: none; }

.nav-hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.nav-hamburger:hover { background: var(--surface-2); }

/* Mobile bar inside the overlay nav */
.nav-mobile-bar { display: none; }

/* Mobile header bar (outside nav) */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 98;
}

/* Mobile footer bar */
.mobile-footer {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  z-index: 98;
}

/* --- Tool factory layout --- */
/* Controls stacked above preview, full page width (minus sidebar). */

.tool-layout {
  display: flex;
  flex-direction: column;
}

.tool-controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 40px;
}

.tool-preview {
  border-top: 1px solid var(--border);
  padding-top: 40px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Fields container — outer vertical rhythm */
.tool-fields {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Section: h3 heading + optional note + optional inner fields */
.tool-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Inner fields within a section (keeps section gap separate from field gap) */
.tool-section-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Multi-column field row — 2 equal columns by default */
.tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Actions bar */
.tool-actions {
  display: flex;
  gap: 8px;
  max-width: 360px;
}

@media (max-width: 768px) {
  .tool-row { grid-template-columns: 1fr; }
}

/* --- Navigation (mobile) --- */
@media (max-width: 768px) {
  /* Full-width overlay nav */
  .site-nav {
    width: 100%;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001;
  }
  .site-nav.open { transform: translateX(0); }

  /* Show mobile UI */
  .mobile-header { display: flex; }
  .mobile-footer { display: flex; }

  /* Mobile bar at top of overlay — must match .mobile-header exactly */
  .nav-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    margin: -24px -16px 16px; /* escape .site-nav padding to reach edges */
    padding: 0 20px;           /* match .mobile-header padding */
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  /* Hide desktop logo in sidebar on mobile — logo is in .nav-mobile-bar */
  .nav-top > .nav-logo { display: none; }

  /* Close button inside overlay */
  .nav-close {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
  }
  .nav-close:hover { color: var(--text); background: var(--surface-2); }

  /* Hide copyright from nav on mobile — it lives in .mobile-footer */
  .site-nav .nav-copyright { display: none; }

  /* Content spacing for fixed header + footer */
  .page-content { margin-left: 0; padding-top: 56px; padding-bottom: 44px; }
}
