/* AssetForge — Dark Theme Stylesheet */
/* Color palette: dark backgrounds with indigo/violet accent */

:root {
  --bg-page:     #0f0f17;
  --bg-card:     #1a1a2e;
  --bg-input:    #12121f;
  --bg-hover:    #22223a;
  --border:      #2d2d4a;
  --border-light:#3d3d5a;
  --accent:      #6366f1;
  --accent-dark: #4f46e5;
  --accent-glow: rgba(99,102,241,0.2);
  --text:        #e2e8f0;
  --text-muted:  #8892a4;
  --text-dim:    #4a5568;
  --success:     #10b981;
  --warning:     #f59e0b;
  --error:       #ef4444;
  --log-info:    #93c5fd;
  --log-warn:    #fbbf24;
  --log-error:   #f87171;
  --log-success: #6ee7b7;
  --font-mono:   'Fira Code', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
  --radius:      8px;
  --radius-sm:   4px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}

.sidebar-brand .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand .brand-name { font-weight: 700; font-size: 1.1rem; }
.sidebar-brand .brand-sub  { font-size: 0.65rem; color: var(--text-muted); letter-spacing: 0.05em; text-transform: uppercase; }

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  border-radius: 0;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  font-size: 0.875rem;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); border-left: 3px solid var(--accent); padding-left: calc(1rem - 3px); }
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ── Main content ─────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  flex-shrink: 0;
}

.topbar-title { font-size: 1.1rem; font-weight: 600; }
.topbar-sub   { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ── Pages (visibility toggled by JS) ─────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Asset type selector ──────────────────────────────────────────────────── */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 0.5rem;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  font-size: 0.78rem;
  font-weight: 500;
  user-select: none;
}

.type-btn:hover { border-color: var(--border-light); color: var(--text); background: var(--bg-hover); }
.type-btn.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.type-btn .type-icon { font-size: 1.6rem; }

/* ── Form controls ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 0.85rem; }
.form-group label { display: block; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.3rem; font-weight: 500; }

select, input[type="text"], input[type="number"], textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
}

select:focus, input:focus, textarea:focus { border-color: var(--accent); }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M6 8L0 0h12z' fill='%238892a4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

textarea { resize: vertical; min-height: 100px; }

input[type="range"] {
  padding: 0; border: none; background: none;
  accent-color: var(--accent); cursor: pointer; vertical-align: middle;
}

.range-row { display: flex; align-items: center; gap: 0.75rem; }
.range-val { min-width: 40px; text-align: right; font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-mono); }

/* ── Grid layout for selectors ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }

.btn-danger { background: transparent; color: var(--error); border: 1px solid var(--error); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

.generate-btn {
  width: 100%;
  justify-content: center;
  font-size: 1rem;
  padding: 0.85rem;
  margin-top: 0.5rem;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 0 20px var(--accent-glow);
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px rgba(99,102,241,0.4);
}

/* ── Live log panel ───────────────────────────────────────────────────────── */
.log-panel {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  overflow: hidden;
  margin-top: 0.75rem;
  display: none;
}

.log-panel.visible { display: block; }

.log-header {
  padding: 0.5rem 0.85rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.log-body {
  max-height: 280px;
  overflow-y: auto;
  padding: 0.6rem 0.85rem;
  line-height: 1.7;
  word-break: break-all;
}

.log-line { display: flex; gap: 0.6rem; align-items: flex-start; }
.log-ts   { color: var(--text-dim); flex-shrink: 0; font-size: 0.7rem; padding-top: 0.1em; }
.log-msg  { flex: 1; }
.log-line.info    .log-msg { color: var(--log-info); }
.log-line.warn    .log-msg { color: var(--log-warn); }
.log-line.error   .log-msg { color: var(--log-error); }
.log-line.success .log-msg { color: var(--log-success); }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-bar-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin: 0.5rem 0;
  display: none;
}
.progress-bar-wrap.visible { display: block; }
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  border-radius: 99px;
  transition: width 0.4s ease;
  animation: pulse-bar 2s ease-in-out infinite;
}
@keyframes pulse-bar { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ── Result preview ───────────────────────────────────────────────────────── */
.result-panel {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 0.75rem;
  display: none;
}
.result-panel.visible { display: block; }
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.result-title  { font-weight: 600; color: var(--success); display: flex; align-items: center; gap: 0.5rem; }
.result-meta   { font-size: 0.75rem; color: var(--text-muted); }

.preview-image  { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); max-height: 400px; object-fit: contain; }
.preview-gif    { max-width: 300px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.preview-audio  { width: 100%; }
.preview-text   { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; max-height: 350px; overflow-y: auto; white-space: pre-wrap; font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.6; }
.preview-iframe { width: 100%; height: 400px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-pending   { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-running   { background: rgba(99,102,241,0.15); color: var(--accent); animation: pulse-badge 1.5s ease infinite; }
.badge-completed { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-failed    { background: rgba(239,68,68,0.15); color: var(--error); }
@keyframes pulse-badge { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ── Type color chips ──────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
}
.chip-text     { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.chip-image    { background: rgba(236,72,153,0.15); color: #f9a8d4; }
.chip-audio    { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.chip-threed   { background: rgba(245,158,11,0.15); color: #fcd34d; }
.chip-document { background: rgba(59,130,246,0.15); color: #93c5fd; }

/* ── History / Gallery ────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar select, .filter-bar input { width: auto; flex: 1; min-width: 120px; max-width: 200px; }
.filter-bar input.search { flex: 2; max-width: 300px; }

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

.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.job-card:hover { border-color: var(--border-light); background: var(--bg-hover); }
.job-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 0.5rem; gap: 0.5rem; }
.job-card-prompt { font-size: 0.82rem; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.job-card-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.job-card-preview { margin-top: 0.6rem; }
.job-card-preview img { max-width: 100%; max-height: 160px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.job-card-actions { display: flex; gap: 0.4rem; margin-top: 0.7rem; }

/* Gallery grid with larger previews */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.gallery-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.gallery-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.gallery-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-thumb img  { width: 100%; height: 100%; object-fit: contain; }
.gallery-thumb .no-preview { color: var(--text-dim); font-size: 2rem; flex-direction: column; gap: 0.3rem; display: flex; align-items: center; justify-content: center; height: 100%; }
.gallery-info { padding: 0.6rem 0.75rem; }
.gallery-info .gi-prompt { font-size: 0.75rem; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gallery-info .gi-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Docs page ────────────────────────────────────────────────────────────── */
.docs-content {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  line-height: 1.75;
}
.docs-content h1 { font-size: 1.75rem; color: var(--accent); margin-bottom: 0.5rem; }
.docs-content h2 { font-size: 1.2rem; color: var(--text); margin: 1.75rem 0 0.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.docs-content h3 { font-size: 1rem; color: var(--text-muted); margin: 1rem 0 0.25rem; }
.docs-content p  { color: var(--text-muted); margin-bottom: 0.75rem; }
.docs-content ul,
.docs-content ol { padding-left: 1.5rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.docs-content code { background: var(--bg-input); padding: 0.15em 0.4em; border-radius: 3px; font-family: var(--font-mono); font-size: 0.85em; color: #a5b4fc; }
.docs-content pre { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto; margin: 0.75rem 0; }
.docs-content pre code { background: none; padding: 0; color: var(--text); }
.docs-content table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; font-size: 0.82rem; }
.docs-content th,
.docs-content td { border: 1px solid var(--border); padding: 0.4rem 0.75rem; text-align: left; }
.docs-content th { background: var(--bg-input); color: var(--text-muted); font-weight: 600; }
.docs-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--text-muted); margin: 0.75rem 0; font-style: italic; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-dim);
  text-align: center;
  gap: 0.5rem;
}
.empty-state .empty-icon { font-size: 2.5rem; }
.empty-state .empty-title { font-size: 0.95rem; color: var(--text-muted); font-weight: 500; }
.empty-state .empty-sub   { font-size: 0.8rem; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.modal-body    { padding: 1.25rem; }
.modal-footer  { padding: 0.85rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; justify-content: flex-end; }
.modal-close   { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; padding: 0.2rem 0.4rem; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--bg-hover); }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.78rem; }
.mt-1 { margin-top: 0.4rem; }
.hidden { display: none !important; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
