/* ✨ AI Product Generator — additive admin panel overlay */

/* ── FAB ──────────────────────────────────────────────────────────────────── */
#aig-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 2147483640;
  display: none; align-items: center; gap: 8px;
  padding: 13px 22px;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  color: #fff; font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px; font-weight: 700; border: none; border-radius: 999px;
  cursor: pointer; white-space: nowrap; user-select: none;
  box-shadow: 0 8px 28px -6px rgba(109,40,217,.6), 0 0 0 1px rgba(255,255,255,.12) inset;
  /* No transform on hover — avoids stacking context shift on hit-testing */
  transition: box-shadow .18s, bottom .18s;
  pointer-events: auto;
}
#aig-fab.aig-visible { display: flex; }
#aig-fab:hover { bottom: 30px; box-shadow: 0 14px 36px -8px rgba(109,40,217,.7), 0 0 0 1px rgba(255,255,255,.15) inset; }

/* ── Backdrop ─────────────────────────────────────────────────────────────── */
#aig-backdrop {
  display: none; position: fixed; inset: 0;
  /* One below panel so it never intercepts panel clicks */
  z-index: 2147483643;
  background: rgba(15,15,30,.45); backdrop-filter: blur(4px);
  pointer-events: auto;
}
#aig-backdrop.aig-open { display: block; }

/* ── Panel ────────────────────────────────────────────────────────────────── */
#aig-panel {
  position: fixed; top: 0; bottom: 0;
  /* Slide via right offset — NO transform, so no stacking-context hit offset */
  right: -520px;
  width: 500px; max-width: 100vw;
  z-index: 2147483644;
  background: #fff; display: flex; flex-direction: column;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  box-shadow: -12px 0 48px -8px rgba(15,15,30,.22);
  transition: right .28s cubic-bezier(.22,1,.36,1);
  /* Guarantee this element owns its own stacking context cleanly */
  isolation: isolate;
  pointer-events: auto;
}
#aig-panel.aig-open { right: 0; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.aig-header {
  flex-shrink: 0; padding: 20px 24px 0;
  background: linear-gradient(135deg, #f5f3ff 0%, #eff6ff 100%);
  border-bottom: 1px solid #e5e7eb;
}
.aig-header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.aig-header-title { font-size: 17px; font-weight: 800; color: #1e1b4b; margin: 0; }
.aig-close-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid #e2e8f0;
  background: #fff; color: #64748b; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.aig-close-btn:hover { background: #fef2f2; border-color: #fecaca; color: #ef4444; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.aig-tabs { display: flex; gap: 4px; }
.aig-tab {
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: #64748b;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; border-radius: 6px 6px 0 0; transition: all .15s; font-family: inherit;
}
.aig-tab:hover { color: #7c3aed; }
.aig-tab.aig-tab-active { color: #7c3aed; border-bottom-color: #7c3aed; }

/* ── Body ─────────────────────────────────────────────────────────────────── */
.aig-body { flex: 1 1 auto; overflow-y: auto; padding: 24px; scrollbar-width: thin; scrollbar-color: #a78bfa #f1f5f9; }
.aig-body::-webkit-scrollbar { width: 8px; }
.aig-body::-webkit-scrollbar-track { background: #f1f5f9; }
.aig-body::-webkit-scrollbar-thumb { background: #a78bfa; border-radius: 8px; }
.aig-pane { display: none; }
.aig-pane.aig-pane-active { display: block; }

/* ── Form elements ────────────────────────────────────────────────────────── */
.aig-field { margin-bottom: 16px; }
.aig-label { display: block; font-size: 12px; font-weight: 700; color: #374151; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.aig-input, .aig-select, .aig-textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; font-family: inherit; color: #1e293b; background: #fff;
  box-sizing: border-box; outline: none; transition: border-color .15s, box-shadow .15s;
}
.aig-input:focus, .aig-select:focus, .aig-textarea:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.aig-textarea { resize: vertical; min-height: 72px; }
.aig-hint { margin-top: 5px; font-size: 11px; color: #94a3b8; line-height: 1.4; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.aig-generate-btn, .aig-btn-publish {
  width: 100%; padding: 13px; border: none; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  box-shadow: 0 6px 20px -6px rgba(109,40,217,.5);
  transition: opacity .15s, transform .15s; margin-top: 4px;
}
.aig-generate-btn:hover, .aig-btn-publish:hover { opacity: .92; transform: translateY(-1px); }
.aig-generate-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.aig-btn-secondary {
  flex: 1; padding: 11px; border: 1.5px solid #7c3aed; border-radius: 10px;
  background: #fff; color: #7c3aed; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.aig-btn-secondary:hover { background: #f5f3ff; }

.aig-btn-publish { flex: 1; width: auto; }

.aig-btn-ghost {
  width: 100%; padding: 8px; background: none; border: none; color: #64748b;
  font-size: 13px; cursor: pointer; font-family: inherit; text-align: left;
  transition: color .15s;
}
.aig-btn-ghost:hover { color: #7c3aed; }

.aig-save-btn {
  padding: 10px 20px; background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff; font-size: 13px; font-weight: 700; border: none; border-radius: 8px;
  cursor: pointer; font-family: inherit; transition: opacity .15s;
}
.aig-save-btn:hover { opacity: .88; }

/* ── Loading ──────────────────────────────────────────────────────────────── */
.aig-loading-box {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 24px; text-align: center;
}
.aig-loading-spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid #ede9fe; border-top-color: #7c3aed;
  animation: aig-spin .8s linear infinite; margin-bottom: 20px;
}
@keyframes aig-spin { to { transform: rotate(360deg); } }
.aig-loading-msg { font-size: 15px; font-weight: 600; color: #374151; }

/* ── Banners ──────────────────────────────────────────────────────────────── */
.aig-banner { padding: 12px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; margin-bottom: 16px; display: none; }
.aig-banner.aig-banner-error  { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.aig-banner.aig-banner-success{ background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.aig-banner.aig-visible { display: block; }

/* ── Thumbnail ────────────────────────────────────────────────────────────── */
.aig-thumb-wrap { position: relative; margin-bottom: 16px; }
.aig-thumb-img {
  width: 100%; height: 200px; object-fit: cover;
  border-radius: 12px; display: block;
  box-shadow: 0 4px 16px -4px rgba(15,15,30,.2);
}
.aig-thumb-placeholder {
  width: 100%; height: 200px; border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 60%, #0ea5e9 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; gap: 8px;
}
.aig-thumb-icon { font-size: 48px; }
.aig-thumb-placeholder span { font-size: 13px; font-weight: 700; opacity: .9; }
.aig-thumb-placeholder small { font-size: 11px; opacity: .7; text-align: center; padding: 0 16px; }

.aig-regen-img-btn {
  position: absolute; bottom: 10px; right: 10px;
  padding: 5px 12px; background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  color: #fff; font-size: 12px; font-weight: 600; border: none; border-radius: 8px;
  cursor: pointer; font-family: inherit; transition: background .15s;
}
.aig-regen-img-btn:hover { background: rgba(124,58,237,.8); }

/* ── Preview ──────────────────────────────────────────────────────────────── */
.aig-preview-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.aig-preview-title { font-size: 18px; font-weight: 800; color: #1e1b4b; margin: 0 0 10px; line-height: 1.3; }
.aig-preview-desc { font-size: 14px; color: #475569; line-height: 1.65; margin: 0 0 12px; }

.aig-chip {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe;
}
.aig-chip-cat { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.aig-chip-ver { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.aig-chip-dev { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.aig-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.aig-details {
  margin-bottom: 12px; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden;
}
.aig-details summary {
  padding: 10px 14px; font-size: 13px; font-weight: 700; color: #374151;
  cursor: pointer; list-style: none; background: #f8fafc;
  display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.aig-details summary::-webkit-details-marker { display: none; }
.aig-details summary::after { content: "›"; margin-left: auto; transition: transform .2s; }
.aig-details[open] summary::after { transform: rotate(90deg); }
.aig-details[open] { background: #fff; }

.aig-feature-list { margin: 0; padding: 10px 14px 10px 28px; font-size: 13px; color: #334155; line-height: 1.8; }

.aig-seo-row {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 14px;
  border-top: 1px solid #f1f5f9; font-size: 12px; color: #374151;
}
.aig-seo-row:first-child { border-top: none; }
.aig-seo-label { font-weight: 700; color: #7c3aed; white-space: nowrap; min-width: 80px; padding-top: 1px; }
.aig-seo-row span:nth-child(2) { flex: 1; word-break: break-word; }
.aig-copy-sm {
  padding: 2px 8px; background: #ede9fe; color: #6d28d9; font-size: 11px; font-weight: 700;
  border: 1px solid #ddd6fe; border-radius: 6px; cursor: pointer; font-family: inherit;
  transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.aig-copy-sm:hover { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.aig-copy-sm.aig-copied { background: #059669; color: #fff; border-color: #059669; }

.aig-divider { height: 1px; background: #e5e7eb; margin: 16px 0; }

/* ── Download link box ─────────────────────────────────────────────────────── */
.aig-dl-box {
  background: #fffbeb; border: 1.5px solid #fcd34d; border-radius: 10px;
  padding: 14px; margin-bottom: 16px;
}
.aig-dl-label { font-size: 13px; font-weight: 700; color: #92400e; margin-bottom: 8px; }

/* ── Preview actions ──────────────────────────────────────────────────────── */
.aig-preview-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ── Published ────────────────────────────────────────────────────────────── */
.aig-published-box { text-align: center; padding: 24px 16px 16px; }
.aig-published-icon { font-size: 48px; margin-bottom: 8px; }
.aig-published-title { font-size: 22px; font-weight: 800; color: #1e1b4b; margin: 0 0 4px; }
.aig-published-sub { font-size: 14px; color: #64748b; margin: 0 0 16px; }
.aig-published-name { font-size: 16px; font-weight: 700; color: #374151; margin-bottom: 16px; text-align: center; }

.aig-published-live {
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px;
  padding: 12px 16px; margin-bottom: 14px;
}
.aig-live-row { font-size: 13px; font-weight: 600; color: #15803d; padding: 3px 0; }
.aig-published-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ── Settings ─────────────────────────────────────────────────────────────── */
.aig-info-box { padding: 10px 14px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; font-size: 12px; color: #1d4ed8; line-height: 1.5; margin-bottom: 16px; }
.aig-settings-section { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.aig-settings-section-title { font-size: 13px; font-weight: 700; color: #374151; margin: 0 0 12px; }
.aig-provider-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 10px; }
.aig-provider-card {
  padding: 10px 8px; border: 2px solid #e2e8f0; border-radius: 8px;
  text-align: center; cursor: pointer; font-size: 12px; font-weight: 600;
  color: #64748b; background: #fff; transition: all .15s; user-select: none;
}
.aig-provider-card:hover { border-color: #a78bfa; color: #7c3aed; }
.aig-provider-card.aig-provider-active { border-color: #7c3aed; color: #7c3aed; background: #f5f3ff; }
.aig-provider-icon { font-size: 20px; display: block; margin-bottom: 4px; }

/* ── Vault badge ──────────────────────────────────────────────────────────── */
.aig-vault-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; margin-bottom: 14px;
  font-size: 12px; font-weight: 700; letter-spacing: .03em;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e; border: 1px solid #fcd34d;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  #aig-panel { width: 100vw; }
  #aig-fab { bottom: 16px; right: 16px; font-size: 13px; padding: 11px 16px; }
  .aig-body { padding: 16px; }
}
