/* ==========================================================================
   components.css — اجزای مشترک
   ========================================================================== */

/* ---------- کارت ---------- */
.card {
  background: var(--sadaf-card);
  border-radius: var(--r-card-lg);
  box-shadow: var(--shadow);
  padding: 14px 12px;
}

.card--plain { background: #fff; }
.card--tight { padding: 10px; }

/* ---------- سربرگ بخش ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 18px 2px 10px;
}

.section-header h2 { margin: 0; }

.section-header .section-more {
  font-size: 12px;
  font-weight: 700;
  color: var(--sadaf-gold);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.section-header .section-more i { font-style: normal; }

/* ---------- دکمه ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  text-align: center;
}

.btn--primary {
  background: var(--sadaf-gold);
  color: #fffdf8;
}

.btn--primary:hover { background: #a9762f; }

.btn--ghost {
  background: #fff;
  border-color: var(--sadaf-line);
  color: var(--sadaf-text);
}

.btn--ghost:hover { background: var(--bg); }

.btn--outline-gold {
  background: #fff;
  border-color: rgba(184, 137, 59, .45);
  color: var(--sadaf-gold);
}

.btn--block { width: 100%; }

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

/* ---------- چیپ ---------- */
.ads-chip-v2 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--sadaf-line);
  background: #fff;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--sadaf-text);
  transition: background var(--t-fast), border-color var(--t-fast);
}

.ads-chip-v2.primary {
  background: var(--sadaf-gold);
  border-color: var(--sadaf-gold);
  color: #fffdf8;
}

.ads-chip-v2.primary:hover { background: #a9762f; }

.ads-chipbar-v2 {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.ads-chipbar-v2.is-empty { display: none; }

/* چیپ فیلتر فعال با دکمه حذف */
.ads-chip-v2.is-active {
  background: #fdf6e8;
  border-color: rgba(184, 137, 59, .45);
  color: #6b5730;
  padding-inline-end: 6px;
}

.ads-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(184, 137, 59, .16);
  font-size: 14px;
  line-height: 1;
  color: #8a6224;
  flex: none;
}

.ads-chip-x:hover { background: rgba(184, 137, 59, .3); }

/* ---------- بج ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(31, 23, 17, .72);
  color: #fffdf8;
}

.badge svg { width: 14px; height: 14px; }

.badge--gold {
  background: var(--sadaf-gold-2);
  color: #5c4620;
}

.badge--soft {
  background: #f4ead7;
  color: #6b5730;
}

/* ---------- کارت فصل (پریمیتیو مشترک همه‌ی صفحات) ---------- */
.chapter {
  padding: 16px 14px;
  border-radius: var(--r-card-lg);
  background: var(--sadaf-card);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.chapter > h2 {
  font-size: 17px;
  margin-bottom: 9px;
}

.chapter > h3 {
  font-size: 14px;
  margin: 14px 0 7px;
}

.chapter p,
.chapter li {
  font-size: 13px;
  line-height: 2.1;
  color: var(--sadaf-muted);
}

.chapter p { margin-bottom: 10px; }
.chapter p:last-child { margin-bottom: 0; }

.chapter ul,
.chapter ol {
  padding-inline-start: 18px;
  margin-bottom: 10px;
}

.chapter li { margin-bottom: 5px; }

.chapter a {
  color: var(--sadaf-gold);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* دکمه‌های داخل فصل‌ها نباید رنگ و زیرخطِ لینک متنی را بگیرند */
.chapter .btn { text-decoration: none; }
.chapter .btn--primary { color: #fffdf8; }
.chapter .btn--ghost { color: var(--sadaf-text); }

.chapter table { width: 100%; }

/* ---------- فرم ---------- */
.field {
  display: block;
  margin-bottom: 12px;
}

.field > label,
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--sadaf-text);
  margin-bottom: 6px;
}

.input,
.select,
textarea.input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 13px;
  border: 1px solid var(--sadaf-line);
  background: #fff;
  font-size: 13.5px;
  color: var(--sadaf-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

textarea.input {
  min-height: 108px;
  padding: 10px 12px;
  line-height: 1.8;
  resize: vertical;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c7067' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 16px;
}

.input:focus,
.select:focus,
textarea.input:focus {
  outline: none;
  border-color: var(--sadaf-gold);
  box-shadow: 0 0 0 3px rgba(184, 137, 59, .14);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"] {
  border-color: #c0392b;
}

.field-error {
  display: none;
  margin-top: 5px;
  font-size: 11.5px;
  color: #c0392b;
}

.field.has-error .field-error { display: block; }

/* پیام خطای سرور در فرم‌های متصل به API */
.form-alert {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdecea;
  border: 1px solid #f5c6c0;
  color: #8e2b20;
  font-size: 12.5px;
  line-height: 1.8;
}

.form-alert:empty { display: none; }

.btn[disabled] { opacity: 0.65; cursor: progress; }

/* ورودی مبلغ با نمایش حروف */
.ads-money-input-wrap { position: relative; }

.ads-money-words {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--sadaf-gold);
  min-height: 16px;
}

/* ---------- نوار فیلتر آگهی ---------- */
.ads-filter-v2 { padding: 13px 11px 12px; }

.ads-filter-v2 h2 { margin-bottom: 9px; }

.ads-search-v2 {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 12px;
  border-radius: 13px;
  border: 1px solid var(--sadaf-line);
  background: #fff;
  transition: border-color var(--t-fast);
}

.ads-search-v2:focus-within {
  border-color: var(--sadaf-gold);
  box-shadow: 0 0 0 3px rgba(184, 137, 59, .14);
}

.ads-search-v2 svg {
  width: 18px;
  height: 18px;
  color: var(--sadaf-muted);
  flex: none;
}

.ads-search-v2 input {
  flex: 1;
  border: 0;
  outline: none;
  background: none;
  font-size: 13.5px;
  min-width: 0;
}

.ads-search-v2 input::placeholder { color: #a49b91; }

/* ---------- شیت جستجوی پیشرفته ---------- */
.ads-advanced-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  background: var(--ref-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
}

.ads-advanced-backdrop.is-open { opacity: 1; visibility: visible; }

.ads-advanced-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: var(--shell-max);
  max-height: 88vh;
  z-index: calc(var(--z-sheet) + 1);
  display: flex;
  flex-direction: column;
  background: var(--sadaf-card);
  border-radius: var(--r-hero) var(--r-hero) 0 0;
  box-shadow: 0 -14px 40px rgba(51, 35, 17, .18);
  transition: transform var(--t-base);
  overscroll-behavior: contain;
}

.ads-advanced-sheet.is-open { transform: translate(-50%, 0); }

.ads-advanced-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--sadaf-line);
  flex: none;
}

.ads-advanced-head strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--sadaf-text);
}

.ads-advanced-head button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--sadaf-line);
  background: #fff;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.ads-advanced-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 12px 10px;
  overscroll-behavior: contain;
}

/* ردیف فیلتر */
.ads-filter-row { border-bottom: 1px solid var(--sadaf-line); }

.ads-filter-row:last-child { border-bottom: 0; }

.ads-filter-row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 0 2px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--sadaf-text);
  text-align: start;
}

.ads-filter-row-title i {
  font-style: normal;
  color: var(--sadaf-muted);
  font-size: 15px;
  transition: transform var(--t-base);
  flex: none;
}

.ads-filter-row-title[aria-expanded="true"] i { transform: rotate(-90deg); }

.ads-filter-row-value {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--sadaf-gold);
}

.ads-filter-box {
  display: none;
  padding: 2px 2px 14px;
}

.ads-filter-box.is-open { display: block; }

/* گزینه‌ها */
.ads-option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ads-option-btn {
  padding: 8px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--sadaf-line);
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sadaf-text);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.ads-option-btn:hover { background: var(--bg); }

.ads-option-btn.is-selected {
  background: var(--sadaf-gold);
  border-color: var(--sadaf-gold);
  color: #fffdf8;
  font-weight: 700;
}

/* محدوده */
.ads-range-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 8px;
}

.ads-range-pair > .ads-range-eq {
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--sadaf-muted);
  padding-top: 0;
}

.ads-range-pair .field { margin-bottom: 0; }

.ads-simple-select,
.ads-simple-input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 13px;
  border: 1px solid var(--sadaf-line);
  background: #fff;
  font-size: 13px;
  color: var(--sadaf-text);
}

.ads-simple-select {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 32px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c7067' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 11px center;
  background-size: 15px;
}

.ads-simple-select:focus,
.ads-simple-input:focus {
  outline: none;
  border-color: var(--sadaf-gold);
  box-shadow: 0 0 0 3px rgba(184, 137, 59, .14);
}

.ads-simple-input { text-align: center; }

/* اکشن‌های شیت */
.ads-advanced-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--sadaf-line);
  flex: none;
}

.ads-advanced-actions button {
  min-height: 46px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--sadaf-line);
  background: #fff;
  color: var(--sadaf-text);
  transition: background var(--t-fast);
}

.ads-advanced-actions button:hover { background: var(--bg); }

.ads-advanced-actions button.apply {
  background: var(--sadaf-gold);
  border-color: var(--sadaf-gold);
  color: #fffdf8;
}

.ads-advanced-actions button.apply:hover { background: #a9762f; }

.ads-advanced-actions button.apply:disabled {
  opacity: .7;
  cursor: progress;
}

/* ---------- کارت آگهی (نمای ردیفی) ---------- */
.sadaf-ads-list-v2 {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.sadaf-ads-row-wrap-v2 { display: block; position: relative; }

.sadaf-ads-row-v2 {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 11px;
  align-items: center;
  padding: 9px;
  border-radius: var(--r-card-lg);
  background: var(--sadaf-card);
  box-shadow: var(--shadow);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.sadaf-ads-row-v2:hover {
  transform: translateY(-1px);
  box-shadow: var(--sadaf-shadow);
}

.sadaf-ads-photo-v2 {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: #efe6d6;
}

.sadaf-ads-photo-v2 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sadaf-ads-photo-badge-v2,
.sadaf-ads-video-badge-v2 {
  position: absolute;
  bottom: 5px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: rgba(31, 23, 17, .74);
  color: #fffdf8;
  font-size: 10px;
  font-weight: 700;
}

.sadaf-ads-photo-badge-v2 { right: 5px; }
.sadaf-ads-video-badge-v2 { left: 5px; }

.sadaf-ads-photo-badge-v2 svg,
.sadaf-ads-video-badge-v2 svg { width: 12px; height: 12px; stroke-width: 1.9; }

.sadaf-ads-row-v2 strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--sadaf-text);
  line-height: 1.5;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sadaf-ads-row-v2 .row-price {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--sadaf-gold);
  margin-bottom: 3px;
}

.sadaf-ads-row-v2 .row-meta {
  display: block;
  font-size: 11px;
  color: var(--sadaf-muted);
}

/* ---------- بارگذاری بیشتر و پیشرفت ---------- */
.ads-list-progress-v2 {
  height: 4px;
  border-radius: 4px;
  background: #ece3d5;
  overflow: hidden;
  margin: 16px 2px 10px;
}

.ads-list-progress-v2 > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--sadaf-gold);
  transition: width var(--t-base);
}

.ads-load-more-v2 {
  display: block;
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(184, 137, 59, .45);
  background: #fff;
  color: var(--sadaf-gold);
  font-size: 13.5px;
  font-weight: 700;
  transition: background var(--t-fast);
}

.ads-load-more-v2:hover { background: #fdf6e8; }
.ads-load-more-v2[hidden] { display: none; }

/* ---------- تب ---------- */
.tabs,
.fav-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: #f2ebe0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar,
.fav-tabs::-webkit-scrollbar { display: none; }

.tabs button,
.fav-tabs button {
  flex: 1 0 auto;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--sadaf-muted);
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}

.tabs button[aria-selected="true"],
.fav-tabs button[aria-selected="true"] {
  background: #fff;
  color: var(--sadaf-text);
  box-shadow: 0 2px 8px rgba(55, 36, 16, .07);
}

[role="tabpanel"][hidden] { display: none; }

/* ---------- حالت‌ها ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 14px;
  background: #fdf6e8;
  border: 1px solid rgba(184, 137, 59, .3);
  font-size: 12px;
  line-height: 1.8;
  color: #6b5730;
}

.alert svg { width: 17px; height: 17px; color: var(--sadaf-gold); margin-top: 2px; }

.sadaf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 46px 18px;
}

.sadaf-empty svg {
  width: 52px;
  height: 52px;
  stroke-width: 1.3;
  color: #cbb99b;
}

.sadaf-empty strong {
  font-size: 14px;
  color: var(--sadaf-text);
}

.sadaf-empty p {
  font-size: 12px;
  line-height: 1.9;
  max-width: 30ch;
}

.success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 40px 18px;
}

.success.is-visible { display: flex; }

.success svg {
  width: 56px;
  height: 56px;
  color: var(--sadaf-gold);
  stroke-width: 1.5;
}

.success strong { font-size: 15px; color: var(--sadaf-text); }

/* ---------- استپر ---------- */
.step-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 12px;
  border-radius: var(--r-card-lg);
  background: var(--sadaf-card);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.step-card .step {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--sadaf-muted);
}

.step-card .step b {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: 0 auto 5px;
  border-radius: 50%;
  background: #f2ebe0;
  color: var(--sadaf-muted);
  font-size: 12px;
}

.step-card .step.is-active { color: var(--sadaf-text); }
.step-card .step.is-active b { background: var(--sadaf-gold); color: #fffdf8; }
.step-card .step.is-done b { background: #e6d6b4; color: #6b5730; }

/* ---------- کارت فرم ---------- */
.form-card {
  padding: 14px 12px;
  border-radius: var(--r-card-lg);
  background: var(--sadaf-card);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.form-card > h2 { margin-bottom: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-grid .field--full { grid-column: 1 / -1; }

@media (max-width: 380px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* آپلود تصویر */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.upload-grid label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1.5px dashed rgba(184, 137, 59, .5);
  background: #fdfaf4;
  font-size: 11px;
  font-weight: 700;
  color: var(--sadaf-gold);
  cursor: pointer;
  text-align: center;
}

.upload-grid label svg { width: 22px; height: 22px; }

/* ---------- واکنش‌گرایی ---------- */
@media (max-width: 360px) {
  .sadaf-ads-row-v2 { grid-template-columns: 92px 1fr; gap: 9px; }
  .ads-range-pair { grid-template-columns: 1fr auto 1fr; gap: 6px; }
  .ads-simple-select,
  .ads-simple-input { font-size: 12.5px; padding-inline: 9px; }
}
