/* ═══════════════════════════════════════════════════════════════
   prompt-lab.css  –  redesigned layout: prompt-first + sidebar
   ═══════════════════════════════════════════════════════════════ */

/* ── Layout ─────────────────────────────────────────────────── */
body { background: #f0f4ff; }

.lab-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  max-width: 1180px;
  margin: 32px auto 60px;
  padding: 0 20px;
  align-items: start;
}

/* ── Left: Main ─────────────────────────────────────────────── */
.lab-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Heading */
.lab-heading { margin-bottom: 4px; }
.lab-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  background: linear-gradient(135deg,#7c3aed 0%,#2563eb 100%);
  color: white;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .5px;
  margin-bottom: 10px;
}
.lab-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  margin-bottom: 6px;
}
.lab-sub { color: #64748b; font-size: .9rem; }

/* ── Prompt Card ─────────────────────────────────────────────── */
.prompt-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  padding: 20px 22px 16px;
  box-shadow: 0 2px 12px rgba(37,99,235,.06);
  transition: border-color .2s, box-shadow .2s;
}
.prompt-card:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37,99,235,.09), 0 2px 12px rgba(37,99,235,.08);
}
.prompt-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.prompt-card-label {
  font-size: .8rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.token-badge {
  font-size: .75rem;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 99px;
  padding: 2px 10px;
}

.prompt-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: vertical;
  font-family: inherit;
  font-size: .95rem;
  line-height: 1.65;
  color: #0f172a;
  background: transparent;
  min-height: 130px;
}
.prompt-textarea::placeholder { color: #94a3b8; }
.prompt-textarea-neg { min-height: 60px; font-size: .875rem; }

/* ── Prompt Footer (pill + neg toggle) ──────────────────────── */
.prompt-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

/* ── AI Pill (combined platform + model selector) ─────────── */
.ai-pill-wrap { position: relative; }
.ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 8px;
  border: 1.5px solid #e2e8f0;
  border-radius: 99px;
  background: #f8fafc;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, background .15s, box-shadow .15s;
  white-space: nowrap;
  max-width: 340px;
}
.ai-pill:hover { border-color: #93c5fd; background: #eff6ff; }
.ai-pill.open  { border-color: #2563eb; background: #eff6ff;
                  box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.ai-pill-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  line-height: 1;
  display: flex; align-items: center;
}
.ai-pill-icon img { width: 1.1rem; height: 1.1rem; vertical-align: middle; }
.ai-pill-text  { display: flex; flex-direction: column; min-width: 0; }
.ai-pill-model {
  font-size: .82rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 220px;
}
.ai-pill-platform {
  font-size: .7rem;
  color: #94a3b8;
  line-height: 1.2;
  font-family: 'Fira Code', monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 220px;
}
.ai-pill-chevron {
  width: 14px; height: 14px; flex-shrink: 0; color: #94a3b8;
  transition: transform .18s;
}
.ai-pill.open .ai-pill-chevron { transform: rotate(180deg); }

/* Floating panel */
.ai-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 300px;
  max-width: 380px;
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(15,23,42,.15);
  z-index: 200;
  overflow: hidden;
  animation: panelPop .14s ease;
}
@keyframes panelPop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* Platform group header inside panel */
.ap-platform-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 6px;
  font-size: .72rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-top: 1px solid #f1f5f9;
}
.ap-platform-row:first-child { border-top: none; }
.ap-platform-icon { font-size: 1rem; }
.ap-platform-icon img { width: 1rem; height: 1rem; vertical-align: middle; }
/* Model option row inside panel */
.ap-model-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 20px;
  cursor: pointer;
  transition: background .1s;
  border-radius: 0;
}
.ap-model-row:hover    { background: #f0f7ff; }
.ap-model-row.selected { background: #eff6ff; }
.ap-radio {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #cbd5e1;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .12s;
}
.ap-model-row.selected .ap-radio { border-color: #2563eb; }
.ap-radio-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #2563eb; display: none;
}
.ap-model-row.selected .ap-radio-dot { display: block; }
.ap-model-info { flex: 1; min-width: 0; }
.ap-model-name {
  font-size: .84rem; font-weight: 600; color: #1e293b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ap-model-id {
  font-size: .7rem; font-family: 'Fira Code', monospace; color: #94a3b8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* No platform notice inside panel */
.ap-empty {
  padding: 20px 16px; text-align: center;
  font-size: .85rem; color: #94a3b8;
}

.neg-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  color: #94a3b8;
  padding: 5px 8px;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color .15s;
  white-space: nowrap;
  border-radius: 99px;
}
.neg-toggle-btn:hover { color: #2563eb; background: #eff6ff; }

/* ── Settings Card ───────────────────────────────────────────── */
.settings-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  padding: 18px 22px;
  box-shadow: 0 2px 12px rgba(37,99,235,.06);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.setting-label {
  font-size: .78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.pm-loading { padding: 16px; text-align: center; color: #94a3b8; font-size: .85rem; }

/* Ratio Chips */
.ratio-row { display: flex; gap: 6px; flex-wrap: wrap; }
.ratio-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 99px;
  background: #f8fafc;
  color: #64748b;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.ratio-chip:hover { border-color: #93c5fd; color: #2563eb; }
.ratio-chip.active { background: #2563eb; border-color: #2563eb; color: white; }

/* Ratio shape icons */
.rs { display: inline-block; border: 2px solid currentColor; border-radius: 2px; flex-shrink: 0; }
.rs-sq { width: 10px; height: 10px; }
.rs-wd { width: 14px; height: 9px; }
.rs-tl { width: 9px; height: 14px; }
.rs-ls { width: 13px; height: 10px; }

/* Quality Select */
.setting-select {
  padding: 8px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-family: inherit;
  font-size: .875rem;
  color: #0f172a;
  background: #f8fafc;
  cursor: pointer;
  outline: none;
  transition: border-color .2s;
}
.setting-select:focus { border-color: #2563eb; }


/* ── Generate Button ─────────────────────────────────────────── */
.btn-generate {
  width: 100%;
  padding: 16px 24px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 50%, #0ea5e9 100%);
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 20px rgba(37,99,235,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  letter-spacing: .2px;
}
.btn-generate:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(37,99,235,.45);
}
.btn-generate:active:not(:disabled) { transform: translateY(0); }
.btn-generate:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
}

/* Spinner inside button */
.gen-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.no-platform-notice {
  text-align: center;
  color: #f59e0b;
  font-size: .85rem;
  font-weight: 500;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 16px;
}

/* ── Result Area ─────────────────────────────────────────────── */
.result-area { display: flex; flex-direction: column; gap: 12px; }
.result-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #94a3b8;
  font-size: .8rem;
  font-weight: 600;
}
.result-divider::before,
.result-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.result-card {
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(37,99,235,.06);
}

/* Loading state */
.result-loading {
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #64748b;
  font-size: .875rem;
}
.result-loading .spinner {
  width: 32px; height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.result-loading .loading-platform {
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
}

/* Success result */
.result-success {}
.result-img-wrap {
  position: relative;
  cursor: zoom-in;
  background: #0f172a;
}
.result-img {
  display: block;
  width: 100%;
  max-height: 600px;
  object-fit: contain;
}
.result-footer {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid #f1f5f9;
}
.result-platform { display: flex; align-items: center; gap: 8px; }
.result-platform-icon { font-size: 1.3rem; }
.result-platform-name { font-weight: 700; font-size: .9rem; }
.result-meta-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.result-chip {
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: #f1f5f9;
  color: #64748b;
}
.result-chip-token { background: #eff6ff; color: #2563eb; }
.result-chip-cost  { background: #f0fdf4; color: #16a34a; }
.result-actions { display: flex; gap: 8px; }
.result-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  background: white;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: #334155;
  transition: all .15s;
}
.result-btn:hover { border-color: #2563eb; color: #2563eb; }

/* Error result */
.result-error {
  padding: 32px 24px;
  text-align: center;
}
.result-error-icon { font-size: 2rem; margin-bottom: 10px; }
.result-error-title { font-weight: 700; color: #e11d48; margin-bottom: 6px; }
.result-error-msg { font-size: .85rem; color: #64748b; }

/* ── RIGHT: Sidebar ──────────────────────────────────────────── */
.lab-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.lab-sidebar::-webkit-scrollbar { width: 4px; }
.lab-sidebar::-webkit-scrollbar-track { background: transparent; }
.lab-sidebar::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

/* Stats row */
.sidebar-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: .8rem;
}
.stat-chip-left { display: flex; align-items: center; gap: 8px; }
.stat-chip-icon { font-size: 1.1rem; }
.stat-chip-name { font-weight: 600; color: #334155; }
.stat-chip-right { text-align: right; }
.stat-chip-gens { font-weight: 800; font-size: .95rem; color: #2563eb; }
.stat-chip-cost { font-size: .72rem; color: #94a3b8; }

/* History section */
.sidebar-section {
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(37,99,235,.04);
}
.sidebar-section-header {
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
}
.sidebar-title { font-weight: 700; font-size: .9rem; }
.sidebar-filter {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: .75rem;
  font-family: inherit;
  color: #334155;
  background: #f8fafc;
  cursor: pointer;
  outline: none;
  max-width: 130px;
}

/* History item */
.history-item {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid #f8fafc;
  cursor: pointer;
  transition: background .12s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: #f8faff; }

.hi-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}
.hi-thumb-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.hi-body { flex: 1; min-width: 0; }
.hi-platform {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}
.hi-platform-icon { font-size: .9rem; }
.hi-platform-name {
  font-size: .72rem;
  font-weight: 700;
  color: #2563eb;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.hi-status-fail { color: #e11d48; }
.hi-prompt {
  font-size: .78rem;
  color: #334155;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 3px;
}
.hi-meta {
  font-size: .7rem;
  color: #94a3b8;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.hi-token { color: #2563eb; font-weight: 600; }

.sidebar-empty {
  padding: 28px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: .82rem;
}
.sidebar-loading { padding: 20px 16px; text-align: center; color: #94a3b8; font-size: .82rem; }

.sidebar-pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 10px 14px;
  border-top: 1px solid #f1f5f9;
}
.sp-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #64748b;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .12s;
}
.sp-btn:hover { border-color: #2563eb; color: #2563eb; }
.sp-btn.active { background: #2563eb; border-color: #2563eb; color: white; }
.sp-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Login Gate ──────────────────────────────────────────────── */
.login-gate {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.login-gate-box {
  text-align: center;
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  padding: 48px 40px;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(37,99,235,.08);
}
.login-gate-icon { font-size: 3rem; margin-bottom: 16px; }
.login-gate-box h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.login-gate-box p { color: #64748b; margin-bottom: 24px; }

/* ── Lightbox ────────────────────────────────────────────────── */
.modal-overlay[hidden] { display: none !important; }
.lightbox-inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lightbox-inner img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px; height: 32px;
  background: white;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.lightbox-meta {
  color: rgba(255,255,255,.8);
  font-size: .82rem;
  text-align: center;
}

/* nav-pill-ghost */
.nav-pill-ghost {
  background: transparent !important;
  color: #64748b !important;
  border: 1.5px solid #e2e8f0 !important;
  box-shadow: none !important;
}
.nav-pill-ghost:hover {
  background: white !important;
  color: #2563eb !important;
  border-color: #93c5fd !important;
  transform: none !important;
  box-shadow: none !important;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .lab-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .lab-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
}
@media (max-width: 600px) {
  .lab-layout { padding: 0 12px; margin-top: 20px; }
  .lab-title { font-size: 1.5rem; }
  .settings-card { flex-direction: column; }
  .ratio-row { flex-wrap: wrap; }
}
