/* =====================================================================================
 * صفحه‌ی «ساخت عکس با هوش مصنوعی» (/ai-image) — روی تم سایبرپانک مشترک prompts.css
 * (توکن‌های --cy-*، .pz-panel، .pz-corners، .btn، .category-pill، .pz-orbit). همیشه بعد از
 * prompts.css لود می‌شود.
 * ===================================================================================== */

/* لینک فعال منو روی همین صفحه */
@media (min-width: 861px) {
  body:has(.pz-studio) .nav-links a[href="/ai-image"] {
    color: #22e3f5; border: 1px solid rgba(34, 227, 245, .45); border-radius: 999px; padding: 5px 12px;
    box-shadow: 0 0 14px rgba(34, 227, 245, .18);
  }
}
@media (max-width: 860px) { body:has(.pz-studio) .nav-links a[href="/ai-image"] { color: #22e3f5; } }

.pz-studio [hidden] { display: none !important; }
.pz-cyber .st-hero { padding-bottom: 6px; }
.st-main { max-width: 1080px; }
.st-top-alert { margin: 16px 0 0; }

/* ============================== ساخت عکس ============================== */
.st-composer {
  margin: 18px 0 0; padding: clamp(14px, 2.4vw, 22px);
  display: flex; flex-direction: column; gap: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.st-composer.drag-over { border-color: var(--cy-magenta); box-shadow: 0 0 34px rgba(255, 59, 212, .28), inset 0 0 40px rgba(255, 59, 212, .06); }

/* عکس‌ها */
.st-uploads { display: flex; gap: 10px; align-items: stretch; overflow-x: auto; scrollbar-width: thin; padding: 2px 2px 4px; }
.st-upload-tile {
  position: relative; flex: 0 0 168px; min-height: 112px; padding: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  border-radius: 14px; border: 1.5px dashed rgba(34, 227, 245, .45); background: rgba(34, 227, 245, .05);
  color: var(--cy-text); transition: border-color .2s, background .2s, box-shadow .2s;
}
.st-upload-tile:hover { border-color: var(--cy-cyan); background: rgba(34, 227, 245, .1); box-shadow: 0 0 18px rgba(34, 227, 245, .2); }
.st-upload-tile.full { opacity: .45; pointer-events: none; }
.st-upload-tile b { font-size: 13.5px; }
.st-upload-tile small { font-size: 11px; color: var(--cy-muted); }
.st-upload-ico {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; font-weight: 900;
  color: #021118; background: linear-gradient(135deg, var(--cy-cyan), var(--cy-magenta)); box-shadow: 0 0 14px rgba(34, 227, 245, .45);
}
.st-upload-req { position: absolute; top: 7px; right: 9px; font-size: 10.5px; font-weight: 800; color: var(--cy-muted); }
.st-upload-req.need { color: var(--cy-magenta); }
.st-upload-tile.shake { animation: st-shake .5s; border-color: var(--cy-magenta); }
@keyframes st-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.st-thumbs { display: flex; gap: 10px; }
.st-thumb { position: relative; flex: 0 0 112px; height: 112px; border-radius: 14px; overflow: hidden; border: 1px solid var(--cy-cyan-line); }
.st-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.st-x {
  position: absolute; top: 6px; left: 6px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(3, 6, 11, .75); color: #fff; font-size: 12px; cursor: pointer; display: grid; place-items: center; z-index: 2;
}
.st-x:hover { background: #ff3b6b; border-color: #ff3b6b; }

/* استایل انتخاب‌شده */
.st-selected {
  position: relative; display: flex; gap: 14px; align-items: center; padding: 12px; padding-inline-end: 44px;
  border-radius: 14px; border: 1px solid rgba(255, 59, 212, .45); background: linear-gradient(90deg, rgba(255, 59, 212, .08), rgba(34, 227, 245, .05));
}
.st-selected img { flex: 0 0 74px; width: 74px; height: 92px; object-fit: cover; border-radius: 10px; border: 1px solid var(--cy-cyan-line); background: rgba(34, 227, 245, .06); }
.st-selected-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.st-selected-body .pz-label { color: var(--cy-magenta); font-size: 10px; text-align: right; }
.st-selected-body strong { color: #fff; font-size: 16px; line-height: 1.7; }
.st-selected-sub { color: var(--cy-text-2); font-size: 12.5px; }
.st-selected-hint { color: var(--cy-muted); font-size: 12px; line-height: 1.8; }
.st-selected .st-x { top: 10px; left: 10px; }

/* نوشتن پرامپت */
.st-write textarea {
  width: 100%; min-height: 118px; resize: vertical; font: inherit; font-size: 15px; line-height: 2;
  color: var(--cy-text); background: rgba(3, 10, 17, .6); border: 1px solid rgba(34, 227, 245, .22); border-radius: 14px; padding: 12px 14px;
  transition: border-color .2s, box-shadow .2s;
}
.st-write textarea::placeholder { color: var(--cy-muted); }
.st-write textarea:focus { outline: none; border-color: var(--cy-cyan); box-shadow: 0 0 22px rgba(34, 227, 245, .18); }
.st-write textarea:disabled { opacity: .5; }
.st-write-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
.st-hint { color: var(--cy-muted); font-size: 12.5px; line-height: 1.9; margin: 0; }
.st-counter { color: var(--cy-muted); font-family: var(--cy-mono); font-size: 11px; white-space: nowrap; }

/* نوار پایین */
.st-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px dashed rgba(34, 227, 245, .18); padding-top: 14px; }
.st-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.st-chip {
  display: flex; flex-direction: column; gap: 1px; padding: 6px 12px; border-radius: 12px; min-width: 92px;
  border: 1px solid rgba(34, 227, 245, .2); background: rgba(34, 227, 245, .04);
}
.st-chip-k { font-size: 10.5px; color: var(--cy-muted); font-weight: 700; }
.st-chip b { font-size: 13px; color: #fff; }
.st-chip select { font: inherit; font-size: 13px; font-weight: 700; color: #fff; background: transparent; border: 0; padding: 0; cursor: pointer; }
.st-chip select option { background: #06101a; }
.pz-cyber .st-go { min-width: 220px; padding: 13px 26px; font-size: 15.5px; }
.st-go-price { font-size: 13px; opacity: .85; font-weight: 700; }
.st-go-price:not(:empty)::before { content: '·'; margin-inline-end: 8px; }
.st-alert .alert { margin: 0; }
.st-demo { margin: 0; font-size: 12px; color: var(--cy-amber); }

/* ============================== کارهای در جریان ============================== */
.st-jobs { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.st-jobs:empty { display: none; }
.st-job { display: flex; gap: 16px; padding: 14px; align-items: flex-start; animation: st-in .35s var(--pz-ease); }
@keyframes st-in { from { opacity: 0; transform: translateY(8px); } }
.st-job.is-done { border-color: rgba(61, 245, 160, .5); box-shadow: 0 0 26px rgba(61, 245, 160, .12); }
.st-job.is-failed { border-color: rgba(255, 84, 112, .45); }
.st-job-media { position: relative; flex: 0 0 150px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; place-items: center; min-height: 120px; border-radius: 12px; overflow: hidden; background: rgba(34, 227, 245, .05); }
.st-job-media img { width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; opacity: .5; filter: saturate(.6); }
.st-job-media img:only-of-type { grid-column: 1 / -1; aspect-ratio: 3 / 4; }
.st-job-media.failed img { opacity: .7; filter: grayscale(.5); }
.st-job-media .pz-orbit { position: absolute; top: 50%; left: 50%; margin: -27px 0 0 -27px; }
.st-job-noin { grid-column: 1 / -1; color: var(--cy-muted); font-size: 12px; }
.st-job-result { flex: 0 0 min(320px, 45%); }
.st-job-result img { width: 100%; border-radius: 12px; display: block; cursor: zoom-in; border: 1px solid rgba(61, 245, 160, .4); }
.st-job-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.st-job-head { display: flex; flex-direction: column; gap: 2px; }
.st-job-head b { color: #fff; font-size: 15px; }
.st-job-text { color: var(--cy-text-2); font-size: 12.5px; line-height: 1.9; white-space: pre-wrap; }
.st-job-msg { margin: 0; color: #ffb3c0; font-size: 13px; line-height: 1.9; }
.st-job-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.st-job-actions label.btn { cursor: pointer; }
.st-elapsed { font-family: var(--cy-mono); font-size: 13px; color: var(--cy-cyan); }
.st-debug { font-size: 11px; color: #ff8da0; overflow-wrap: anywhere; }

/* ============================== تب‌ها ============================== */
.st-tabs { display: flex; margin: 30px 0 0; border-bottom: 1px solid rgba(34, 227, 245, .2); }
.st-tab {
  flex: 1; padding: 13px 10px; font: inherit; font-size: 14.5px; font-weight: 800; cursor: pointer;
  color: var(--cy-muted); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .2s, border-color .2s, background .2s;
}
.st-tab:hover { color: #fff; }
.st-tab.active { color: var(--cy-cyan); border-bottom-color: var(--cy-cyan); background: linear-gradient(0deg, rgba(34, 227, 245, .08), transparent); text-shadow: 0 0 12px rgba(34, 227, 245, .45); }
.pz-cyber .st-filter { margin-top: 16px; }

/* ============================== استایل‌های آماده ============================== */
.st-styles, .st-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.st-style {
  position: relative; aspect-ratio: 3 / 4; border-radius: 16px; overflow: hidden; cursor: pointer;
  border: 1px solid rgba(34, 227, 245, .18); background: rgba(34, 227, 245, .05);
  transition: border-color .2s, box-shadow .2s, transform .2s var(--pz-ease);
}
.st-style img, .st-style-noimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--pz-ease), filter .3s; }
.st-style-noimg { background: linear-gradient(135deg, rgba(34, 227, 245, .25), rgba(255, 59, 212, .25)); }
.st-style::after { content: ''; position: absolute; inset: 45% 0 0; background: linear-gradient(180deg, transparent, rgba(3, 6, 11, .92)); pointer-events: none; }
.st-style:hover { border-color: var(--cy-cyan); box-shadow: 0 0 24px rgba(34, 227, 245, .25); transform: translateY(-3px); }
.st-style:hover img { transform: scale(1.05); filter: saturate(1.15); }
.st-style.selected { border-color: var(--cy-magenta); box-shadow: 0 0 0 2px var(--cy-magenta), 0 0 30px rgba(255, 59, 212, .4); }
.st-style.selected::before {
  content: '✓ انتخاب شد'; position: absolute; top: 10px; right: 10px; z-index: 2; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; color: #021118; background: var(--cy-magenta);
}
.st-style-body { position: absolute; inset: auto 0 0; z-index: 1; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.st-style-body h3 { margin: 0; font-size: 14px; font-weight: 800; color: #fff; line-height: 1.7; text-shadow: 0 1px 6px rgba(0, 0, 0, .8); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-style-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.st-try {
  font: inherit; font-size: 12.5px; font-weight: 800; cursor: pointer; padding: 6px 14px; border-radius: 999px;
  color: #fff; background: rgba(3, 6, 11, .55); border: 1px solid rgba(255, 255, 255, .35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background .2s, border-color .2s, color .2s;
}
.st-style:hover .st-try, .st-style.selected .st-try { color: #021118; background: var(--cy-cyan); border-color: var(--cy-cyan); }
.st-more { font-size: 11.5px; color: var(--cy-text-2); text-decoration: none; opacity: .8; }
.st-more:hover { color: var(--cy-cyan); opacity: 1; }
.st-more-wrap { display: flex; justify-content: center; margin-top: 18px; }

/* ============================== گالری ============================== */
.st-gal { border-radius: 16px; overflow: hidden; border: 1px solid rgba(34, 227, 245, .18); background: rgba(5, 15, 24, .7); display: flex; flex-direction: column; }
.st-gal-media { position: relative; aspect-ratio: 3 / 4; background: rgba(34, 227, 245, .05); }
.st-gal-media img, .st-gal-media .st-style-noimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.st-gal.is-done .st-gal-media img { cursor: zoom-in; }
.st-gal:not(.is-done) .st-gal-media img { opacity: .45; filter: grayscale(.4); }
.st-gal-badge { position: absolute; top: 8px; right: 8px; z-index: 1; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; background: rgba(3, 6, 11, .75); border: 1px solid; }
.st-gal-badge.new { color: var(--cy-green); border-color: rgba(61, 245, 160, .6); }
.st-gal-badge.busy { color: var(--cy-amber); border-color: rgba(255, 194, 75, .6); }
.st-gal-badge.failed { color: #ff8da0; border-color: rgba(255, 84, 112, .6); }
.st-gal-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.st-gal-body b { color: #fff; font-size: 13.5px; line-height: 1.7; }
.st-gal-text { color: var(--cy-text-2); font-size: 12px; line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-gal-date { color: var(--cy-muted); font-size: 11.5px; }
.st-gal-actions { margin-top: auto; padding-top: 6px; display: flex; gap: 6px; }

/* ============================== ریسپانسیو ============================== */
@media (max-width: 900px) {
  .st-styles, .st-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .st-styles, .st-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .st-upload-tile { flex-basis: 140px; min-height: 100px; }
  .st-thumb { flex-basis: 100px; height: 100px; }
  .st-bar { flex-direction: column; align-items: stretch; }
  .st-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .st-chip { min-width: 0; }
  .pz-cyber .st-go { width: 100%; min-width: 0; }
  .st-job { flex-direction: column; }
  .st-job-media, .st-job-result { flex-basis: auto; width: 100%; }
  .st-job-media { min-height: 0; }
  .st-tab { font-size: 13.5px; }
  .st-style-body { padding: 10px; }
  .st-style-body h3 { font-size: 13px; }
  .st-try { padding: 5px 11px; font-size: 12px; }
  .st-write-foot { flex-direction: column; gap: 2px; }
}
