/* app.css — styles for /app/* pages (generate, gallery) */
/* Inherits design tokens from theme.css */

/* ── NAV ADDITIONS ─────────────────────────────────── */
.nav-logo {
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  font-size: 0.88rem;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  transition: color 0.2s ease, background 0.2s ease;
  font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
  color: var(--fg-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-cta {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bg-primary);
  background: var(--accent);
  text-decoration: none;
  padding: 8px 18px;
  border-radius: 8px;
  transition: opacity 0.2s ease, transform 0.15s ease;
  margin-left: 8px;
}

.nav-cta:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ── HERO CTA BUTTONS ─────────────────────────────── */
.hero-ctas {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 64px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bg-primary);
  background: var(--accent);
  text-decoration: none;
  padding: 14px 32px;
  border-radius: 10px;
  letter-spacing: -0.01em;
  transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 30px rgba(192, 132, 252, 0.3);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-2px);
  box-shadow: 0 4px 40px rgba(192, 132, 252, 0.45);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg-secondary);
  background: transparent;
  text-decoration: none;
  padding: 14px 28px;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--fg-primary);
  background: var(--accent-glow);
}

/* closing CTA */
.closing-ctas {
  margin-top: 48px;
}

/* ── GENERATE PAGE ─────────────────────────────────── */
.app-main {
  min-height: 100vh;
  padding-top: 80px;
  display: flex;
  align-items: stretch;
}

.app-container {
  display: grid;
  grid-template-columns: 440px 1fr;
  min-height: calc(100vh - 80px);
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* Left panel */
.generate-panel {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 48px 40px;
  overflow-y: auto;
}

.panel-header {
  margin-bottom: 40px;
}

.panel-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.panel-sub {
  font-size: 0.9rem;
  color: var(--fg-muted);
}

/* Form elements */
.generate-form {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.field-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.field-textarea {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  line-height: 1.65;
  padding: 14px 16px;
  resize: vertical;
  min-height: 130px;
  transition: border-color 0.2s ease;
  outline: none;
}

.field-textarea:focus {
  border-color: var(--accent);
}

.field-textarea::placeholder {
  color: var(--fg-muted);
  font-size: 0.88rem;
}

.field-count {
  align-self: flex-end;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* Style grid */
.style-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.style-option {
  cursor: pointer;
}

.style-option input {
  display: none;
}

.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  transition: border-color 0.2s ease, background 0.2s ease;
  cursor: pointer;
}

.style-card:hover {
  border-color: rgba(192, 132, 252, 0.4);
}

.style-card.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.style-icon {
  font-size: 1.3rem;
}

.style-name {
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-align: center;
  font-weight: 500;
}

/* Range slider */
.field-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.field-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(192, 132, 252, 0.4);
  transition: box-shadow 0.2s ease;
}

.field-range::-webkit-slider-thumb:hover {
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.6);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* Generate button */
.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bg-primary);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  padding: 16px 32px;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 30px rgba(192, 132, 252, 0.3);
  letter-spacing: -0.01em;
}

.btn-generate:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 40px rgba(192, 132, 252, 0.45);
}

.btn-generate:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.btn-generate:hover:not(:disabled) .btn-icon {
  transform: translateX(3px);
}

/* Right preview panel */
.preview-panel {
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.hidden {
  display: none !important;
}

/* Idle state */
.preview-idle {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-idle-inner {
  text-align: center;
  position: relative;
}

.idle-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(192, 132, 252, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.idle-icon {
  font-size: 3rem;
  color: var(--fg-muted);
  margin-bottom: 20px;
  opacity: 0.4;
}

.idle-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

.idle-hint {
  font-size: 0.82rem;
  color: var(--fg-muted);
  opacity: 0.6;
}

/* Generating state */
.preview-generating {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gen-progress {
  text-align: center;
  width: 320px;
}

.gen-orbs {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.orb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  animation: orbPulse 1.4s ease-in-out infinite;
}

.orb-1 { animation-delay: 0s; }
.orb-2 { animation-delay: 0.2s; }
.orb-3 { animation-delay: 0.4s; }

@keyframes orbPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.gen-status {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  color: var(--fg-secondary);
  margin-bottom: 20px;
  min-height: 1.4em;
}

.gen-bar {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.gen-bar-fill {
  height: 100%;
  background: var(--gradient-purple);
  border-radius: 2px;
  width: 0%;
  transition: width 0.8s ease;
}

/* Result state */
.preview-result {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 40px;
}

.filmstrip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.frame {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: frameIn 0.5s ease both;
}

@keyframes frameIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.frame img {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.frame-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.5);
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.result-meta {
  margin-bottom: 24px;
}

.meta-prompt {
  font-size: 0.9rem;
  color: var(--fg-secondary);
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 12px;
}

.meta-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-tag {
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(192, 132, 252, 0.2);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-action {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.btn-download {
  color: var(--bg-primary);
  background: var(--accent);
}

.btn-download:hover {
  opacity: 0.88;
}

.btn-ghost {
  color: var(--fg-secondary);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.08);
  color: var(--fg-primary);
}

/* Error state */
.preview-error {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-content {
  text-align: center;
}

.error-icon {
  font-size: 2rem;
  color: #f87171;
  margin-bottom: 16px;
}

.error-msg {
  font-size: 0.95rem;
  color: var(--fg-secondary);
  margin-bottom: 24px;
  max-width: 320px;
}

/* ── GALLERY PAGE ──────────────────────────────────── */
.gallery-main {
  min-height: 100vh;
  padding-top: 80px;
}

.gallery-main .container {
  padding-top: 60px;
  padding-bottom: 80px;
}

.gallery-header {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 48px;
  flex-wrap: wrap;
}

.gallery-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  flex: 1;
  min-width: 200px;
}

.gallery-sub {
  font-size: 0.92rem;
  color: var(--fg-muted);
  margin-top: 4px;
}

.btn-generate-sm {
  display: inline-flex;
  align-items: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--bg-primary);
  background: var(--accent);
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 8px;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.btn-generate-sm:hover {
  opacity: 0.88;
}

/* Loading */
.gallery-loading {
  text-align: center;
  padding: 80px 0;
  color: var(--fg-muted);
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: orbPulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Empty */
.gallery-empty {
  text-align: center;
  padding: 80px 0;
  color: var(--fg-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 20px;
  opacity: 0.4;
}

.gallery-empty h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--fg-secondary);
}

.gallery-empty p {
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.gallery-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.gallery-card:hover {
  border-color: rgba(192, 132, 252, 0.35);
  transform: translateY(-2px);
}

.card-thumb {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--bg-secondary);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-card:hover .card-thumb img {
  transform: scale(1.03);
}

.card-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gallery-card:hover .card-overlay {
  opacity: 1;
}

.card-play {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: rgba(192, 132, 252, 0.85);
  padding: 8px 16px;
  border-radius: 6px;
}

.card-body {
  padding: 16px;
}

.card-prompt {
  font-size: 0.88rem;
  color: var(--fg-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-tag {
  font-size: 0.72rem;
  color: var(--fg-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
}

/* Load more */
.gallery-more {
  text-align: center;
  padding: 40px 0 0;
}

.btn-ghost-outline {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-secondary);
  background: transparent;
  border: 1px solid var(--border);
  padding: 12px 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.btn-ghost-outline:hover {
  border-color: var(--accent);
  color: var(--fg-primary);
  background: var(--accent-glow);
}

/* ── LIGHTBOX ──────────────────────────────────────── */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  backdrop-filter: blur(8px);
}

.lightbox {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(90vw, 900px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 40px;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-muted);
  font-size: 1rem;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}

.lightbox-close:hover {
  color: var(--fg-primary);
  background: rgba(255,255,255,0.12);
}

.lightbox-filmstrip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.lb-frame {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.lb-frame img {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.lb-frame-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.5);
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.lightbox-meta {
  margin-bottom: 24px;
}

.lb-prompt {
  font-size: 0.9rem;
  color: var(--fg-secondary);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 12px;
}

.lb-tags {
  display: flex;
  gap: 8px;
}

.lightbox-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── RESPONSIVE ────────────────────────────────────── */
@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  .generate-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .preview-panel {
    min-height: 500px;
  }

  .style-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .preview-result {
    padding: 24px;
  }
}

@media (max-width: 600px) {
  .nav-links .nav-link {
    display: none;
  }

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

  .lightbox {
    padding: 24px;
    width: 95vw;
  }

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

  .hero-ctas {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}
