/* =====================================================================
   AEHI · control-center-v8.css  (۲.۱۰.۵)
   استایل صفحهٔ بازطراحی‌شدهٔ «تنظیمات مالک» (v9) + انیمیشن‌ها
   این فایل بعد از bundle/v6/v7 بارگذاری می‌شود؛ پس قواعدش برنده‌اند.
   رنگ‌ها تماماً از متغیرها می‌آیند تا در هر دو حالت روشن و تیره درست باشند.
   ===================================================================== */

:root {
  --o9-bg: #f7f6f3;
  --o9-surface: #ffffff;
  --o9-surface-2: #f1efeb;
  --o9-text: #16181c;
  --o9-text-muted: #6a7078;
  --o9-border: #dcd8d2;
  --o9-border-soft: #e9e6e1;
  --o9-accent: #a33a1e;
  --o9-accent-soft: rgba(163, 58, 30, .12);
  --o9-ok: #2f7d4f;
  --o9-warn: #9a4d12;
  --o9-shadow: 0 1px 0 rgba(0, 0, 0, .03);
}

body.theme-dark,
html[data-theme="dark"] body,
[data-theme="dark"] {
  --o9-bg: #14161a;
  --o9-surface: #1b1e24;
  --o9-surface-2: #22262e;
  --o9-text: #eceef1;
  --o9-text-muted: #9aa2ac;
  --o9-border: #31363f;
  --o9-border-soft: #282d35;
  --o9-accent: #e08163;
  --o9-accent-soft: rgba(224, 129, 99, .16);
  --o9-ok: #63c08c;
  --o9-warn: #e0a45f;
  --o9-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}

/* ---------- پوستهٔ صفحه ---------- */

.o9-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--o9-text);
}

.o9-fade {
  animation: o9-fade-in .35s ease both;
}

@keyframes o9-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes o9-card-in {
  from { opacity: 0; transform: translateY(14px) scale(.995); }
  to { opacity: 1; transform: none; }
}

.o9-card,
.o9-metric,
.o9-kv-list > * {
  animation: o9-card-in .42s cubic-bezier(.2, .7, .25, 1) both;
  animation-delay: var(--o9-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  .o9-card, .o9-metric, .o9-kv-list > *, .o9-fade { animation: none !important; }
}

/* ---------- نوار وضعیت ---------- */

.o9-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0;
  background: var(--o9-surface);
  border: 1px solid var(--o9-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--o9-shadow);
}

.o9-status-item {
  padding: 14px 18px;
  border-inline-start: 1px solid var(--o9-border-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.o9-status-item:first-child { border-inline-start: 0; }

.o9-status-item span {
  font-size: 12px;
  color: var(--o9-text-muted);
  letter-spacing: .02em;
}

.o9-status-item b {
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.o9-status-actions {
  padding: 14px 18px;
  border-inline-start: 1px solid var(--o9-border-soft);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.o9-dirty-badge {
  font-size: 12.5px;
  color: var(--o9-text-muted);
  transition: color .2s ease;
}

.o9-dirty-badge.is-warn {
  color: var(--o9-warn);
  font-weight: 700;
  animation: o9-pulse 1.6s ease-in-out infinite;
}

@keyframes o9-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

/* ---------- نوار ابزار: تب‌ها + جست‌وجو ---------- */

.o9-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.o9-tabs {
  display: flex;
  gap: 4px;
  background: var(--o9-surface-2);
  border: 1px solid var(--o9-border);
  border-radius: 10px;
  padding: 4px;
  flex-wrap: wrap;
}

.o9-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--o9-text-muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 7px;
  cursor: pointer;
  position: relative;
  transition: background .22s ease, color .22s ease, transform .12s ease;
}

.o9-tab:hover { color: var(--o9-text); transform: translateY(-1px); }

.o9-tab.active {
  background: var(--o9-surface);
  color: var(--o9-text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .06), 0 0 0 1px var(--o9-border);
}

.o9-tab.active::after {
  content: "";
  position: absolute;
  inset-inline: 16px;
  bottom: -1px;
  height: 2px;
  background: var(--o9-accent);
  border-radius: 2px;
  animation: o9-underline .28s ease both;
}

@keyframes o9-underline {
  from { transform: scaleX(.3); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.o9-tab:focus-visible {
  outline: 2px solid var(--o9-accent);
  outline-offset: 2px;
}

.o9-search input {
  background: var(--o9-surface);
  border: 1px solid var(--o9-border);
  border-radius: 9px;
  color: var(--o9-text);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 14px;
  min-width: 240px;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.o9-search input:focus {
  outline: none;
  border-color: var(--o9-accent);
  box-shadow: 0 0 0 3px var(--o9-accent-soft);
}

/* ---------- کارت‌ها ---------- */

.o9-panel { display: flex; flex-direction: column; gap: 14px; }

.o9-card {
  background: var(--o9-surface);
  border: 1px solid var(--o9-border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .25s ease, box-shadow .25s ease;
}

.o9-card:hover { border-color: var(--o9-border); box-shadow: 0 6px 22px -18px rgba(0, 0, 0, .45); }

.o9-card.o9-card-dirty {
  border-color: var(--o9-warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--o9-warn) 14%, transparent);
}

.o9-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--o9-border-soft);
  background: linear-gradient(0deg, transparent, color-mix(in srgb, var(--o9-surface-2) 45%, transparent));
}

.o9-card-head h4 { margin: 0 0 4px; font-size: 15.5px; font-weight: 700; }
.o9-card-head p { margin: 0; font-size: 13px; color: var(--o9-text-muted); line-height: 1.7; }

.o9-card-tools { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.o9-dirty-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--o9-border);
  transition: background .2s ease, box-shadow .2s ease;
}

.o9-card-dirty .o9-dirty-dot {
  background: var(--o9-warn);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--o9-warn) 22%, transparent);
}

.o9-card-body { padding: 16px 18px; }

.o9-sub {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--o9-text-muted);
  letter-spacing: .02em;
}

.o9-note { font-size: 12.8px; color: var(--o9-text-muted); line-height: 1.8; margin: 0; }

/* ---------- فرم ---------- */

.o9-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  align-items: start;
}

.o9-grid-2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.o9-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.o9-field > span { font-size: 12.8px; color: var(--o9-text-muted); }
.o9-field input,
.o9-field select,
.o9-field textarea {
  background: var(--o9-surface-2);
  border: 1px solid var(--o9-border);
  border-radius: 8px;
  color: var(--o9-text);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  width: 100%;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.o9-field input:focus,
.o9-field select:focus,
.o9-field textarea:focus {
  outline: none;
  border-color: var(--o9-accent);
  background: var(--o9-surface);
  box-shadow: 0 0 0 3px var(--o9-accent-soft);
}

.o9-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  padding: 9px 12px;
  border: 1px solid var(--o9-border-soft);
  border-radius: 8px;
  background: var(--o9-surface-2);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}

.o9-switch:hover { border-color: var(--o9-border); }

.o9-switch input {
  appearance: none;
  width: 38px; height: 21px;
  border-radius: 999px;
  background: var(--o9-border);
  position: relative;
  cursor: pointer;
  transition: background .24s ease;
  flex-shrink: 0;
  margin: 0;
}

.o9-switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--o9-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .24s cubic-bezier(.3, .8, .3, 1);
}

.o9-switch input:checked { background: var(--o9-ok); }
.o9-switch input:checked::after { transform: translateX(17px); }
html[dir="rtl"] .o9-switch input:checked::after { transform: translateX(-17px); }

.o9-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.o9-file-btn { cursor: pointer; display: inline-flex; align-items: center; }

/* ---------- فهرست کلید/مقدار ---------- */

.o9-kv-list { display: flex; flex-direction: column; gap: 6px; }

.o9-kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--o9-border-soft);
  border-radius: 8px;
  background: var(--o9-surface-2);
  font-size: 13.2px;
  min-width: 0;
}

.o9-kv > span { min-width: 0; overflow-wrap: anywhere; }
.o9-kv b { font-weight: 700; white-space: nowrap; }
.o9-kv small { color: var(--o9-text-muted); font-size: 12.2px; }

.o9-version-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.o9-version.o9-draft { opacity: .78; border-style: dashed; }

/* ---------- متریک‌ها ---------- */

.o9-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.o9-metric {
  background: var(--o9-surface-2);
  border: 1px solid var(--o9-border-soft);
  border-radius: 9px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.o9-metric span { font-size: 12px; color: var(--o9-text-muted); }
.o9-metric b { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.o9-metric-sm b { font-size: 15px; }

/* ---------- حالت بارگذاری ---------- */

.o9-load {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--o9-text-muted);
  font-size: 13.2px;
  padding: 10px 0;
}

.o9-spin {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid var(--o9-border);
  border-top-color: var(--o9-accent);
  animation: o9-spin .8s linear infinite;
  flex-shrink: 0;
}

@keyframes o9-spin { to { transform: rotate(360deg); } }

/* ---------- نوار پیشرفت آپلود ---------- */

.o9-progress { display: flex; align-items: center; gap: 10px; margin: 8px 0; }

.o9-progress-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--o9-surface-2);
  border: 1px solid var(--o9-border-soft);
  overflow: hidden;
}

.o9-progress-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--o9-accent), color-mix(in srgb, var(--o9-accent) 55%, var(--o9-ok)));
  transition: width .25s ease;
}

.o9-progress-text { font-size: 12.5px; color: var(--o9-text-muted); font-variant-numeric: tabular-nums; }

/* ---------- پیش‌نمایش زنده ---------- */

.o9-live {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}

.o9-live img {
  max-width: 100%;
  border-radius: 9px;
  border: 1px solid var(--o9-border);
  background: var(--o9-surface-2);
  min-height: 120px;
  animation: o9-fade-in .3s ease both;
}

/* ---------- دکمه‌های داخل این صفحه در هر دو تم ---------- */

.o9-shell .secondary-button,
.o9-shell .primary-button,
.o9-shell .danger-button {
  font-size: 13px;
  border-radius: 8px;
  transition: transform .12s ease, filter .2s ease, background .2s ease, color .2s ease;
}

.o9-shell .secondary-button:hover,
.o9-shell .primary-button:hover,
.o9-shell .danger-button:hover { transform: translateY(-1px); }

.o9-shell .secondary-button {
  background: var(--o9-surface-2);
  border: 1px solid var(--o9-border);
  color: var(--o9-text);
}

.o9-shell .secondary-button:hover { background: var(--o9-surface); }

.o9-shell .primary-button {
  background: var(--o9-accent);
  border: 1px solid var(--o9-accent);
  color: #fff;
}

.o9-shell .primary-button:hover { filter: brightness(1.08); }

.o9-shell .danger-button {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--o9-warn) 55%, transparent);
  color: var(--o9-warn);
}

.o9-shell .danger-button:hover { background: color-mix(in srgb, var(--o9-warn) 12%, transparent); }

/* ---------- ریسپانسیو ---------- */

@media (max-width: 720px) {
  .o9-status { grid-template-columns: 1fr 1fr; }
  .o9-status-item:nth-child(odd) { border-inline-start: 0; }
  .o9-toolbar { flex-direction: column; align-items: stretch; }
  .o9-search input { min-width: 0; width: 100%; }
  .o9-card-head { flex-direction: column; }
  .o9-kv { flex-direction: column; align-items: flex-start; }
}
