/* پوسته پنل ادمین دستیار استوری: فونت Vazirmatn و اجزای اختصاصی.
   رنگ‌های برند به‌صورت متغیر از /admin/brand-theme.css (برگرفته از brand.yaml) می‌آیند. */

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Variable.woff2") format("woff2-variations"),
       url("fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-sans: "Vazirmatn", ui-sans-serif, system-ui, sans-serif;
  --brand-accent: #DFA329;
  --brand-bg: #41648C;
}

html, body, input, select, textarea, button {
  font-family: var(--font-sans) !important;
  font-feature-settings: "ss01";
}

/* اعداد و کد چپ‌به‌راست بمانند */
.sa-json, code, pre { direction: ltr; text-align: left; }

/* ---------------------------------------------------------------- تصویر کوچک */
.sa-thumb {
  aspect-ratio: 9 / 16;
  width: auto;
  border-radius: 8px;
  object-fit: cover;
  display: inline-block;
  vertical-align: middle;
  box-shadow: 0 1px 2px rgb(0 0 0 / .15);
  background: var(--brand-bg);
}
.sa-thumb--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, rgb(127 127 127 / .08) 0 6px, rgb(127 127 127 / .16) 6px 12px);
  color: rgb(127 127 127 / .9);
  box-shadow: inset 0 0 0 1px rgb(127 127 127 / .25);
}
.sa-thumb--empty .material-symbols-outlined { font-size: 20px; }
.sa-preview { max-height: 520px; border-radius: 14px; box-shadow: 0 4px 18px rgb(0 0 0 / .18); }
.sa-strip { display: flex; gap: 4px; flex-wrap: nowrap; }
.sa-ref { display: inline-flex; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- برچسب‌ها */
.sa-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  background: rgb(127 127 127 / .12);
  color: inherit;
}
.sa-badge--role { background: color-mix(in srgb, var(--brand-bg) 14%, transparent); color: var(--brand-bg); }
.dark .sa-badge--role { color: color-mix(in srgb, var(--brand-bg) 40%, white); }
.sa-badge--proposed { background: rgb(59 130 246 / .14); color: rgb(29 78 216); }
.sa-badge--approved { background: rgb(34 197 94 / .15); color: rgb(21 128 61); }
.sa-badge--rejected { background: rgb(239 68 68 / .14); color: rgb(185 28 28); }
.sa-badge--awaiting_photo { background: rgb(249 115 22 / .15); color: rgb(194 65 12); }
.sa-badge--review { background: var(--brand-accent-100, #F9EBC6); color: var(--brand-accent-900, #57400D); }
.dark .sa-badge--proposed { color: rgb(147 197 253); }
.dark .sa-badge--approved { color: rgb(134 239 172); }
.dark .sa-badge--rejected { color: rgb(252 165 165); }
.dark .sa-badge--awaiting_photo { color: rgb(253 186 116); }
.dark .sa-badge--review { background: color-mix(in srgb, var(--brand-accent) 22%, transparent); color: var(--brand-accent); }

.sa-num {
  display: inline-block;
  min-width: 2.4em;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--brand-bg);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  text-align: center;
}
.sa-muted { opacity: .65; font-size: 12.5px; }
.sa-text { max-width: 34rem; line-height: 1.9; white-space: normal; }

/* ---------------------------------------------------------------- مراحل خط تولید */
.sa-steps { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.sa-step {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid rgb(127 127 127 / .25);
  opacity: .55;
}
.sa-step--done { opacity: 1; border-color: transparent; background: color-mix(in srgb, var(--brand-bg) 14%, transparent); color: var(--brand-bg); }
.sa-step--done::before { content: "✓"; }
.dark .sa-step--done { color: color-mix(in srgb, var(--brand-bg) 40%, white); }
.sa-step--current { opacity: 1; border-color: transparent; background: var(--brand-accent); color: #2b1d00; }
.sa-step--wait { opacity: 1; border-style: dashed; border-color: var(--brand-accent); color: var(--brand-accent-700, #A6791A); }

/* ---------------------------------------------------------------- نقشه و JSON */
.sa-plan { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.sa-plan li { line-height: 1.9; }
.sa-json { margin: 0; padding: 10px 12px; border-radius: 8px; background: rgb(127 127 127 / .08); font-size: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; }

/* ---------------------------------------------------------------- داشبورد */
.sa-dash { display: grid; gap: 24px; }
.sa-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .sa-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .sa-kpis { gap: 10px; } .sa-kpi { padding: 14px; } .sa-kpi__value { font-size: 28px; } }
@media (max-width: 340px) { .sa-kpis { grid-template-columns: 1fr; } }
.sa-kpi {
  display: block;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px solid rgb(127 127 127 / .2);
  background: var(--color-white, #fff);
  text-decoration: none !important;
  color: inherit !important;
  transition: box-shadow .15s, transform .15s;
}
.dark .sa-kpi { background: rgb(255 255 255 / .03); }
.sa-kpi:hover { box-shadow: 0 6px 20px rgb(0 0 0 / .08); transform: translateY(-1px); }
.sa-kpi__value { font-size: 34px; font-weight: 800; line-height: 1.2; color: var(--brand-bg); }
.dark .sa-kpi__value { color: color-mix(in srgb, var(--brand-bg) 35%, white); }
.sa-kpi__label { font-weight: 700; margin-top: 2px; }
.sa-kpi__hint { font-size: 12px; opacity: .6; margin-top: 2px; }
.sa-kpi--accent { background: var(--brand-bg); border-color: var(--brand-bg); color: #fff !important; }
.sa-kpi--accent .sa-kpi__value { color: var(--brand-accent); }
.dark .sa-kpi--accent { background: var(--brand-bg); }

.sa-panel { border-radius: 14px; border: 1px solid rgb(127 127 127 / .2); overflow: hidden; background: var(--color-white, #fff); }
.dark .sa-panel { background: rgb(255 255 255 / .03); }
.sa-panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid rgb(127 127 127 / .18);
}
.sa-panel__title { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.sa-panel__title .material-symbols-outlined { color: var(--brand-accent); }
.sa-panel__body { padding: 18px 20px; }
.sa-panel__link { font-size: 13px; font-weight: 600; color: var(--brand-bg) !important; }
.dark .sa-panel__link { color: var(--brand-accent) !important; }

.sa-chain { display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 210px)); gap: 14px; justify-content: start; }
@media (max-width: 1100px) { .sa-chain { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .sa-chain { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sa-chain__item { display: flex; flex-direction: column; gap: 6px; text-decoration: none !important; color: inherit !important; }
.sa-chain__item .sa-thumb { width: 100%; height: auto; }
.sa-chain__meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.sa-chain__text { font-size: 12.5px; line-height: 1.8; opacity: .8; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sa-empty { padding: 28px; text-align: center; opacity: .7; line-height: 2; }

.sa-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sa-table th { text-align: start; font-weight: 700; opacity: .65; padding: 8px 10px; border-bottom: 1px solid rgb(127 127 127 / .2); }
.sa-table td { padding: 8px 10px; border-bottom: 1px solid rgb(127 127 127 / .1); vertical-align: middle; }
.sa-table tr:last-child td { border-bottom: 0; }
.sa-table td.sa-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.sa-scroll { overflow-x: auto; }

/* ---------------------------------------------------------------- اصلاح راست‌به‌چپ
   چند کلاس فیزیکی در قالب‌های unfold (ml-auto، mr-3، text-left) در RTL برعکس نمی‌شوند. */
[dir="rtl"] .ml-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .mr-auto { margin-right: 0 !important; margin-left: auto !important; }
[dir="rtl"] .mr-3 { margin-right: 0 !important; margin-left: .75rem !important; }
[dir="rtl"] .ml-3 { margin-left: 0 !important; margin-right: .75rem !important; }
[dir="rtl"] .text-left { text-align: right !important; }
[dir="rtl"] .text-right { text-align: left !important; }
[dir="rtl"] .sa-json, [dir="rtl"] pre.sa-json { text-align: left !important; }

/* فیلدهای JSON (استیکر، دلیل‌های بازبینی) چپ‌به‌راست تا براکت‌ها به‌هم نریزند */
textarea[name="sticker"], textarea[name="review_notes"], textarea[name="plan_item"],
textarea[name="metrics"], textarea[name="raw"] {
  direction: ltr; text-align: left !important; font-family: ui-monospace, Menlo, Consolas, "Vazirmatn", monospace !important; font-size: 12.5px;
}

/* حالت تیره: سرمه‌ای برند روی زمینه تیره کم‌کنتراست است؛ برای متن و آیکون از درجه روشن‌تر همان رنگ */
html.dark .dark\:text-primary-500, html.dark .dark\:text-primary-400,
html.dark .text-primary-600, html.dark .text-primary-500 { color: var(--color-primary-300) !important; }
html.dark .dark\:group-hover\:text-primary-500:hover { color: var(--color-primary-200) !important; }

/* بخش‌های بسته‌شونده: فلش کوچک تا معلوم باشد با کلیک باز می‌شوند */
fieldset h2.cursor-pointer::after {
  content: "expand_more";
  font-family: "Material Symbols Outlined";
  font-size: 20px;
  margin-inline-start: auto;
  opacity: .55;
}

/* ---------------------------------------------------------------- تنظیمات محتوا */
.sa-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.sa-file {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 12px;
  border: 1px solid rgb(127 127 127 / .2); text-decoration: none !important; color: inherit !important;
  transition: border-color .15s, box-shadow .15s;
}
.sa-file:hover { border-color: var(--brand-bg); box-shadow: 0 4px 14px rgb(0 0 0 / .07); }
.sa-file__name { font-weight: 800; font-size: 15px; }
.sa-file__meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; opacity: .75; margin-top: 4px; align-items: center; }
.sa-file__meta code { direction: ltr; }

.sa-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .sa-editor-layout { grid-template-columns: 1fr; } }
.sa-editor-side { display: grid; gap: 20px; }
.sa-code {
  width: 100%; min-height: 420px; padding: 14px 16px; border-radius: 10px;
  border: 1px solid rgb(127 127 127 / .3); background: rgb(127 127 127 / .04);
  font-size: 14px; line-height: 1.9; resize: vertical; color: inherit;
}
.sa-code:focus { outline: 2px solid color-mix(in srgb, var(--brand-bg) 55%, transparent); outline-offset: 1px; }
.sa-code--ltr { direction: ltr; text-align: left; font-size: 13px; line-height: 1.7; }
.sa-editor__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.sa-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-weight: 700;
  font-size: 14px; border: 1px solid rgb(127 127 127 / .3); background: transparent; color: inherit !important;
  cursor: pointer; text-decoration: none !important;
}
.sa-btn .material-symbols-outlined { font-size: 18px; }
.sa-btn--primary { background: var(--brand-bg); border-color: var(--brand-bg); color: #fff !important; }
.sa-btn--primary:hover { filter: brightness(1.08); }
.sa-btn--ghost { border-color: transparent; opacity: .75; }
.sa-alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; line-height: 1.9; }
.sa-alert ul { margin: 6px 0 0; padding-inline-start: 20px; list-style: disc; }
.sa-alert--error { background: rgb(239 68 68 / .1); color: rgb(153 27 27); border: 1px solid rgb(239 68 68 / .3); }
.sa-alert--ok { background: rgb(34 197 94 / .1); color: rgb(21 101 52); border: 1px solid rgb(34 197 94 / .3); }
.dark .sa-alert--error { color: rgb(252 165 165); }
.dark .sa-alert--ok { color: rgb(134 239 172); }
.sa-previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sa-previews figure { margin: 0; text-align: center; }
.sa-previews .sa-thumb { width: 100%; height: auto; }
.sa-backups { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.sa-backups li { display: flex; justify-content: space-between; gap: 8px; }
.sa-backups a { font-weight: 600; direction: ltr; }

/* ارقام: در متن عادی پنل فارسی (ss01)، ولی در ورودی‌ها، کد و پیام‌های خطا همان چیزی که تایپ می‌شود */
input, textarea, select, code, pre, .sa-code, .sa-json, .sa-alert, .sa-file__meta code {
  font-feature-settings: normal !important;
}
/* حروف فارسی داخل ویرایشگر YAML با Vazirmatn (فونت‌های monospace فارسی ندارند) */
.sa-code--ltr, .sa-json, code {
  font-family: ui-monospace, Menlo, Consolas, "Vazirmatn", monospace !important;
}

/* ---------------------------------------------------------------- کتابخانه رسانه */
.sa-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.sa-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; font-weight: 700;
  font-size: 13px; border: 1px solid rgb(127 127 127 / .25); text-decoration: none !important; color: inherit !important;
}
.sa-chip.is-active { background: var(--brand-bg); border-color: var(--brand-bg); color: #fff !important; }
.sa-chip__n { font-size: 11px; opacity: .7; }
.sa-media-filters__row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.sa-grow { flex: 1; }
.sa-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; }
.sa-field span { opacity: .7; }
.sa-field--grow { flex: 1 1 260px; }
.sa-field input[type=text], .sa-field input[type=search], .sa-field input[type=date], .sa-field input[type=file] {
  padding: 8px 10px; border-radius: 8px; border: 1px solid rgb(127 127 127 / .3); background: transparent;
  color: inherit; font-size: 14px; min-height: 38px;
}
.sa-form { display: grid; gap: 14px; }
.sa-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.sa-h3 { font-weight: 800; font-size: 15px; margin-top: 10px; }
.sa-btn--sm { padding: 4px 10px; font-size: 12.5px; }
.sa-btn--danger { background: rgb(220 38 38); border-color: rgb(220 38 38); color: #fff !important; }
.sa-alert--warn { background: var(--brand-accent-50, #FDF6E6); color: var(--brand-accent-900, #57400D); border: 1px solid var(--brand-accent-100, #F9EBC6); }
.dark .sa-alert--warn { background: color-mix(in srgb, var(--brand-accent) 15%, transparent); color: var(--brand-accent); }

.sa-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.sa-media-card { border: 1px solid rgb(127 127 127 / .2); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; background: var(--color-white, #fff); }
.dark .sa-media-card { background: rgb(255 255 255 / .03); }
.sa-media-card__img {
  aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: rgb(127 127 127 / .08);
}
.sa-media-card__img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sa-media-card__img--story { aspect-ratio: 9 / 12; }
.sa-media-card__img--story img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.sa-media-card__img .material-symbols-outlined { font-size: 40px; opacity: .4; }
/* پس‌زمینه تصویرهای شفاف: شطرنجی، رنگ برند یا تیره */
[data-bg="checker"] .sa-media-card__img--transparent, .sa-media-card__img--transparent[data-bg="checker"] {
  background-color: #fff;
  background-image: linear-gradient(45deg, #d9d9d9 25%, transparent 25%), linear-gradient(-45deg, #d9d9d9 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #d9d9d9 75%), linear-gradient(-45deg, transparent 75%, #d9d9d9 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
[data-bg="brand"] .sa-media-card__img--transparent, .sa-media-card__img--transparent[data-bg="brand"] { background: var(--brand-bg); }
[data-bg="dark"] .sa-media-card__img--transparent, .sa-media-card__img--transparent[data-bg="dark"] { background: #111827; }
.sa-media-preview { aspect-ratio: 1; border-radius: 10px; }
.sa-media-card__body { padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.sa-media-card__top { display: flex; flex-wrap: wrap; gap: 5px; }
.sa-media-card__title { font-weight: 800; line-height: 1.7; }
.sa-media-card__sub { font-size: 12.5px; line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sa-media-card__meta { font-size: 12px; }
.sa-media-card__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; }
.sa-table--mini { font-size: 12.5px; margin: 4px 0; }
.sa-table--mini th, .sa-table--mini td { padding: 3px 6px; }
.sa-table--mini tr.is-diff td { color: var(--brand-accent-700, #A6791A); font-weight: 800; }
.sa-strip--wrap { flex-wrap: wrap; gap: 8px; }
.sa-confirm { display: grid; grid-template-columns: 160px 1fr; gap: 16px; align-items: start; }
.sa-confirm__img { aspect-ratio: 1; border-radius: 10px; }
@media (max-width: 560px) { .sa-confirm { grid-template-columns: 1fr; } }

/* مقایسه اسکرین‌شات اینسایت با عددها */
.sa-compare { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .sa-compare { grid-template-columns: 1fr; } }
.sa-compare__img img { width: 100%; border-radius: 10px; border: 1px solid rgb(127 127 127 / .2); }
.sa-compare .sa-table tr.is-diff td { color: var(--brand-accent-700, #A6791A); font-weight: 800; }
.sa-download { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 12.5px; }
.sa-download .material-symbols-outlined { font-size: 18px; }
/* اسم فایل و مسیر با همان ارقامی که روی دیسک است */
.sa-media-card__meta, .sa-confirm b { font-feature-settings: normal !important; overflow-wrap: anywhere; }
.sa-day--missing td, .sa-day--clamped td { color: var(--brand-accent-700, #A6791A); font-weight: 800; }
.sa-kpi--warn { border-color: var(--brand-accent); box-shadow: inset 0 0 0 2px var(--brand-accent); }
@media (min-width: 1101px) { .sa-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
