/* =========================================================
   PromptForge — style.css
   Design tokens, base reset, navbar, layout, footer
   ========================================================= */

/* ---------- Design Tokens ---------- */
:root {
  /* Surfaces */
  --bg:            #0B0B0B;
  --surface:       #121212;
  --surface-2:     #171717;
  --surface-3:     #1D1D1D;

  --border:        #2A2A2A;
  --border-soft:   #1F1F1F;

  /* Text */
  --text:          #F8FAFC;
  --text-muted:    #94A3B8;
  --text-faint:    #64748B;

  /* Accent */
  --accent:        #3B82F6;
  --accent-hover:  #2563EB;
  --accent-soft:   rgba(59, 130, 246, 0.14);
  --accent-line:   rgba(59, 130, 246, 0.35);

  /* Status */
  --danger:        #EF4444;
  --warning:       #F59E0B;
  --success:       #10B981;

  /* Typography */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px var(--accent-line), 0 8px 30px rgba(59, 130, 246, 0.18);

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Layout */
  --navbar-h: 60px;
  --maxw: 1680px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 180ms;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(59, 130, 246, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(59, 130, 246, 0.06), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); color: var(--text); }

/* Scrollbars (subtle, dark) */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--surface-3); background-clip: padding-box; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--navbar-h);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.navbar__inner {
  height: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}
.brand { display: inline-flex; align-items: center; gap: var(--sp-3); }
/* Issue #3: logo is visually balanced with the PromptForge wordmark.
   The image is rendered at its natural aspect ratio (no stretch). */
.brand__mark {
  display: inline-flex;
  height: 40px;
  width: auto;
  object-fit: contain;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.brand__name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand__accent { color: var(--accent); }
.brand__mark--sm .brand__name { font-size: 14px; }

/* Desktop nav: inline links, pushed to the right of the navbar. */
.nav { display: flex; gap: var(--sp-1); margin-left: auto; }
.nav--desktop { display: flex; gap: var(--sp-1); margin-left: auto; }
.nav--mobile {
  /* Mobile drawer — completely removed from layout when closed (display:none)
     so it cannot extend the document's scrollable width. When .is-open is
     added, it becomes display:flex and plays a slide-in keyframe animation. */
  display: none;
  position: fixed;
  top: var(--navbar-h);
  right: 0;
  width: min(280px, 80vw);
  height: calc(100vh - var(--navbar-h));
  flex-direction: column;
  gap: 4px;
  padding: var(--sp-4);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  overflow-y: auto;
}
.nav--mobile.is-open {
  display: flex;
  animation: nav-drawer-slide-in 280ms var(--ease);
}
@keyframes nav-drawer-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.nav__link {
  position: relative;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav__link:hover { color: var(--text); background: var(--surface-2); }
.nav__link.is-active { color: var(--text); background: var(--surface-3); }

/* Mobile drawer link variant — larger tap target, full-width, with icon support */
.nav__link--mobile {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  border-radius: var(--r-md);
  width: 100%;
  text-align: left;
}
.nav__link--mobile:hover { background: var(--surface-2); color: var(--text); }
.nav__link--mobile.is-active { background: var(--accent-soft); color: var(--accent); }
.nav__link--github { border-top: 1px solid var(--border-soft); margin-top: var(--sp-2); padding-top: var(--sp-3); }

/* Hamburger toggle button — hidden on desktop, shown on mobile */
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.nav-toggle:hover { background: var(--surface-3); border-color: var(--accent-line); }
.nav-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 220ms var(--ease), opacity 180ms var(--ease);
}
/* Hamburger → X animation when menu is open */
.nav-toggle.is-open .nav-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open .nav-toggle__bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.is-open .nav-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Click-outside backdrop (mobile only) */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: var(--navbar-h) 0 0 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 55;
  opacity: 0;
  transition: opacity 280ms var(--ease);
}
.nav-backdrop.is-open {
  display: block;
  opacity: 1;
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  /* Issue #1: when desktop nav is hidden on mobile, push the actions
     (hamburger) to the far right of the navbar. */
  margin-left: auto;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--sm { padding: 7px 12px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn--xs { padding: 5px 9px; font-size: 11.5px; border-radius: var(--r-sm); }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.28);
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--surface-3); border-color: var(--border); }
.btn--danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
}
.btn--danger:hover { background: rgba(239, 68, 68, 0.18); }

/* ---------- App layout ---------- */
/* Issue #2: no fixed min-height — panels size to content, with independent
   scroll on the left panel. The grid's align-items:stretch keeps both
   columns equal height naturally. */
.app {
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 0;
  max-width: var(--maxw);
  margin: 0 auto;
  border-left: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
}

/* ---------- Panels ---------- */
.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.panel--left {
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.4), rgba(15, 23, 42, 0.4));
  /* Issue #2: left panel scrolls independently — height = viewport minus navbar.
     No min-height, no fixed max-height. Sticky header stays at top. */
  height: calc(100vh - var(--navbar-h));
  position: sticky;
  top: var(--navbar-h);
  overflow: hidden;
}
.panel--right {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  /* Issue #2: right panel grows to content; no fixed height. */
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-soft);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* Issue #2: not sticky here — the parent .panel--left is sticky. */
  flex-shrink: 0;
}
.panel__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.panel__title--sm { font-size: 14px; }
.panel__subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.panel__body {
  /* Issue #2: panel__body inherits its height from .panel--left (which is
     height: calc(100vh - navbar)). flex:1 + min-height:0 lets it shrink and
     scroll independently. No max-height needed. */
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  flex: 1;
  min-height: 0;
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border-soft);
  background: rgba(15, 23, 42, 0.7);
  margin-top: 0;
}
.footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-6);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--sp-6);
}
.footer__brand { display: flex; align-items: center; gap: var(--sp-3); }
.footer__title { font-weight: 700; font-size: 14px; }
.footer__sub { font-size: 12px; color: var(--text-muted); }
.footer__links {
  display: flex;
  gap: var(--sp-5);
  justify-content: center;
  flex-wrap: wrap;
}
.footer__links a {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 4px;
  transition: color var(--dur) var(--ease);
}
.footer__links a:hover { color: var(--accent); }
.footer__copy {
  font-size: 12px;
  color: var(--text-faint);
  text-align: right;
}

/* ---------- Field ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }
.field__label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ---------- Inputs ---------- */
.input, .textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
  outline: none;
}
.textarea { resize: vertical; min-height: 60px; line-height: 1.5; font-family: var(--font-sans); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-3);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 100;
  max-width: 90vw;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast--success { border-color: rgba(16, 185, 129, 0.4); }
.toast--error   { border-color: rgba(239, 68, 68, 0.4); }

/* ---------- Utility ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
