/**
 * App-specific styles (generator + assets pages).
 * Landing page styles live in theme.css.
 * Uses CSS variables from theme.css design system.
 */

/* ===== App body ===== */
.app-body {
  min-height: 100vh;
  padding-top: 64px; /* navbar height */
}

/* ===== Navbar app links ===== */
.nav-links {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav-link {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.2s;
}

.nav-link:hover { color: var(--fg); }
.nav-link--active { color: var(--accent); }

/* ===== Generator Page ===== */
.generator-main {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  min-height: calc(100vh - 64px);
}

.prompt-panel {
  padding: 48px 40px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.panel-header { display: flex; flex-direction: column; gap: 8px; }
.panel-title {
  font-family: var(--font-head);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.03em;
}
.panel-subtitle { color: var(--fg-muted); font-size: 0.9rem; line-height: 1.5; }

.generate-form { display: flex; flex-direction: column; gap: 20px; }

.form-group { position: relative; }

.prompt-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 14px 16px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.6;
}
.prompt-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.prompt-input::placeholder { color: var(--fg-muted); }

.char-count {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.form-options { display: flex; flex-direction: column; gap: 10px; }
.option-label { font-size: 0.8rem; color: var(--fg-muted); letter-spacing: 0.06em; text-transform: uppercase; }

.option-chips { display: flex; gap: 8px; }
.chip {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: rgba(0,229,204,0.4); color: var(--fg); }
.chip--active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  color: #08080c;
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: -0.01em;
}
.generate-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.generate-btn:active { transform: translateY(0); }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-loading { display: inline-flex; align-items: center; gap: 8px; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(8,8,12,0.3);
  border-top-color: #08080c;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.quick-prompts { display: flex; flex-direction: column; gap: 12px; }
.quick-label { font-size: 0.75rem; color: var(--fg-muted); letter-spacing: 0.08em; text-transform: uppercase; }

.prompt-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.prompt-chip {
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}
.prompt-chip:hover { border-color: rgba(0,229,204,0.3); color: var(--fg); }

/* ===== Result Panel ===== */
.result-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
}

/* Idle state */
.result-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}
.idle-text { color: var(--fg-muted); font-size: 0.95rem; line-height: 1.6; }

/* Processing state */
.result-processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  max-width: 360px;
}
.processing-text { font-family: var(--font-head); font-size: 1.1rem; color: var(--fg); }
.processing-sub { font-size: 0.82rem; color: var(--fg-muted); }

.processing-spinner { position: relative; width: 80px; height: 80px; }
.orbit {
  width: 80px; height: 80px;
  border: 1.5px solid var(--accent-dim);
  border-radius: 50%;
  position: relative;
  animation: orbit-spin 2s linear infinite;
}
.orbit-dot {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-glow);
}
@keyframes orbit-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.progress-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 5%;
  background: linear-gradient(90deg, var(--accent), rgba(0,229,204,0.5));
  border-radius: 2px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Success state */
.result-success { display: flex; flex-direction: column; gap: 28px; width: 100%; max-width: 560px; }

.model-viewer-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.model-info {
  display: flex;
  gap: 24px;
  justify-content: center;
}
.model-stat { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.stat-label { font-size: 0.72rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-family: var(--font-head); font-size: 1.1rem; font-weight: 600; color: var(--accent); }

.download-section { display: flex; flex-direction: column; gap: 16px; }
.download-title { font-family: var(--font-head); font-size: 1rem; font-weight: 600; color: var(--fg); }
.download-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.download-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--fg-muted);
}
.download-btn--ready {
  border-color: rgba(0,229,204,0.3);
  color: var(--fg);
}
.download-btn--ready:hover { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-dim); }
.download-btn:not(.download-btn--ready) { opacity: 0.5; cursor: default; }
.dl-icon { font-size: 1.4rem; }
.dl-name { font-family: var(--font-head); font-weight: 700; font-size: 0.9rem; }
.dl-desc { font-size: 0.7rem; color: var(--fg-muted); }
.dl-note { font-size: 0.78rem; color: var(--fg-muted); text-align: center; }

/* ===== PBR Material Channels ===== */
.pbr-section { display: flex; flex-direction: column; gap: 14px; }
.pbr-title { font-family: var(--font-head); font-size: 1rem; font-weight: 600; color: var(--fg); }
.pbr-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pbr-channel { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pbr-channel-preview {
  width: 100%; aspect-ratio: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
}
.pbr-channel-preview:hover { border-color: rgba(0,229,204,0.4); }
.pbr-channel-preview img { width: 100%; height: 100%; object-fit: cover; }
.pbr-channel-icon { font-size: 1.1rem; }
.pbr-channel-label { font-family: var(--font-head); font-size: 0.72rem; font-weight: 700; color: var(--accent); }
.pbr-channel-name { font-size: 0.68rem; color: var(--fg-muted); text-align: center; }

.try-again-btn {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  align-self: center;
}
.try-again-btn:hover { border-color: rgba(0,229,204,0.4); color: var(--fg); }

/* Error state */
.result-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.error-icon { font-size: 2.5rem; }
.error-text { color: var(--fg-muted); font-size: 0.9rem; }

/* ===== Assets Gallery ===== */
.gallery-main { max-width: 1200px; margin: 0 auto; padding: 48px 40px; }

.gallery-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}
.gallery-title {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.03em;
  flex: 1;
}
.gallery-sub { color: var(--fg-muted); font-size: 0.9rem; }

.cta-btn {
  padding: 10px 22px;
  background: var(--accent);
  color: #08080c;
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.2s;
}
.cta-btn:hover { opacity: 0.85; }

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

.gallery-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 40px;
  color: var(--fg-muted);
  text-align: center;
  grid-column: 1 / -1;
}

/* Asset Card */
.asset-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
}
.asset-card:hover { border-color: rgba(0,229,204,0.3); transform: translateY(-2px); }
.asset-card--ready { cursor: pointer; }

.card-preview { height: 180px; overflow: hidden; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; }
.card-thumb { width: 100%; height: 100%; object-fit: cover; }

.card-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--fg-muted);
  font-size: 0.82rem;
}
.card-spinner {
  width: 24px; height: 24px;
  border: 2px solid rgba(0,229,204,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.card-prompt {
  font-size: 0.85rem;
  color: var(--fg);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; align-items: center; gap: 10px; }
.card-status {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card-status.ready { background: rgba(0,229,204,0.15); color: var(--accent); }
.card-status.processing { background: rgba(245,158,11,0.15); color: var(--amber); }
.card-status.failed { background: rgba(239,68,68,0.15); color: #ef4444; }
.card-time { font-size: 0.72rem; color: var(--fg-muted); }
.card-poly { font-size: 0.75rem; color: var(--fg-muted); }

.card-view-btn {
  margin: 0 16px 16px;
  padding: 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(0,229,204,0.3);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.card-view-btn:hover { background: rgba(0,229,204,0.2); border-color: var(--accent); }

/* ===== Asset Modal ===== */
.asset-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8,8,12,0.85);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-elevated);
  border: none;
  color: var(--fg-muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
  z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--accent-dim); color: var(--accent); }

.modal-viewer { background: var(--bg-elevated); min-height: 300px; }
.modal-info { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.modal-prompt { font-family: var(--font-head); font-size: 1rem; font-weight: 600; color: var(--fg); line-height: 1.5; }
.modal-stats { display: flex; gap: 24px; }
.modal-stat { display: flex; flex-direction: column; gap: 4px; }
.modal-downloads { display: flex; gap: 12px; }
.modal-dl-btn {
  flex: 1;
  padding: 12px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #08080c;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.modal-dl-btn:hover:not(:disabled) { opacity: 0.85; }
.modal-dl-btn--disabled { background: var(--bg-elevated); color: var(--fg-muted); cursor: not-allowed; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .generator-main { grid-template-columns: 1fr; }
  .prompt-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .result-panel { min-height: 60vh; }
}

@media (max-width: 600px) {
  .gallery-main { padding: 24px 20px; }
  .gallery-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .download-grid { grid-template-columns: repeat(3, 1fr); }
}