/* =====================================================================
   کنترل‌های اختصاصی فرم — ابر طراحان آتی
   (منوی کشویی، جست‌وجو، فایل، چک‌باکس، ورودی‌ها)
   ===================================================================== */
:root {
  --ui-ease: cubic-bezier(.22, 1, .36, 1);
  --ui-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ui-ring: 0 0 0 4px rgba(47, 92, 255, .14);
}

/* ---------- ورودی‌های متنی ---------- */
.input, .textarea, .ui-select-btn {
  transition: border-color .2s, box-shadow .25s var(--ui-ease), background-color .2s;
}
.input:hover, .textarea:hover, .ui-select-btn:hover { border-color: #c9d3ee; }
.input:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--ui-ring), 0 6px 18px rgba(0, 45, 176, .08); background: #fff; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); transition: opacity .2s, transform .25s var(--ui-ease); }
.input:focus::placeholder, .textarea:focus::placeholder { opacity: .45; transform: translateX(-6px); }
.textarea { overflow-y: auto; }
.input.invalid, .q.error .input, .q.error .textarea { border-color: var(--err); box-shadow: 0 0 0 4px rgba(217, 45, 32, .1); }
.field > span { transition: color .2s; }
.field:focus-within > span { color: var(--brand); }
.input[type="search"]::-webkit-search-cancel-button { display: none; }

/* ---------- منوی کشویی ---------- */
.ui-select { position: relative; }
.ui-native { position: absolute !important; inset: 0; opacity: 0 !important; pointer-events: none; }
.ui-select-btn {
  width: 100%; min-height: 48px; display: flex; align-items: center; gap: 10px; text-align: start; cursor: pointer;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; font-weight: 600; color: var(--ink);
}
.ui-select-val { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; }
.ui-select-btn.is-empty .ui-select-val { color: var(--ink-3); font-weight: 500; }
.ui-select-val.ui-swap { animation: ui-swap .3s var(--ui-ease); }
@keyframes ui-swap { from { opacity: 0; transform: translateY(6px); } }
.ui-select-chev {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-2);
  background: var(--bg); transition: transform .3s var(--ui-spring), background .2s, color .2s;
}
.ui-select-chev svg { width: 18px; height: 18px; }
.ui-select-btn:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--ui-ring); }
.ui-select.open .ui-select-btn { border-color: var(--brand); box-shadow: var(--ui-ring); }
.ui-select.open .ui-select-chev { transform: rotate(180deg); background: var(--brand); color: #fff; }
.ui-select-btn.ui-picked { animation: ui-picked .35s var(--ui-spring); }
@keyframes ui-picked { 40% { transform: scale(.98); } }

.ui-select-panel {
  position: fixed; z-index: 1000; overflow: auto; overscroll-behavior: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 6px;
  box-shadow: 0 18px 50px rgba(11, 26, 74, .18), 0 2px 6px rgba(11, 26, 74, .06);
  opacity: 0; transform: translateY(-6px) scale(.97); transform-origin: top center;
  transition: opacity .18s ease, transform .22s var(--ui-ease);
}
.ui-select-panel.up { transform-origin: bottom center; transform: translateY(6px) scale(.97); }
.ui-select-panel.open { opacity: 1; transform: none; }
.ui-sheet-grip, .ui-sheet-title { display: none; }
.ui-select-list { list-style: none; margin: 0; padding: 0; outline: none; }
.ui-opt {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 10px; cursor: pointer;
  font-size: 15px; font-weight: 600; color: var(--ink); position: relative;
  transition: background .15s, color .15s;
}
.ui-select-panel.open .ui-opt { animation: ui-opt-in .28s var(--ui-ease) both; animation-delay: calc(var(--i) * 22ms); }
@keyframes ui-opt-in { from { opacity: 0; transform: translateY(-4px); } }
.ui-opt-txt { flex: 1; }
.ui-opt.active { background: var(--brand-50); color: var(--brand-700); }
.ui-opt[aria-selected="true"] { color: var(--brand); }
.ui-opt[aria-selected="true"]::before { content: ""; position: absolute; right: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--brand); }
.ui-opt.disabled { opacity: .45; cursor: not-allowed; }
.ui-opt-check { width: 20px; height: 20px; color: var(--brand); opacity: 0; transform: scale(.4); transition: opacity .2s, transform .3s var(--ui-spring); }
.ui-opt-check svg { width: 100%; height: 100%; }
.ui-opt[aria-selected="true"] .ui-opt-check { opacity: 1; transform: none; }

/* برگه پایین صفحه در موبایل */
.ui-select-panel.as-sheet {
  left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 72vh;
  border-radius: 22px 22px 0 0; padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(100%); opacity: 1; transition: transform .32s var(--ui-ease);
}
.ui-select-panel.as-sheet.open { transform: none; }
.as-sheet .ui-sheet-grip { display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 10px; }
.as-sheet .ui-sheet-title { display: block; font-weight: 900; font-size: 16px; padding: 0 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.as-sheet .ui-sheet-title:empty { display: none; }
.as-sheet .ui-opt { min-height: 52px; font-size: 16px; }
.ui-backdrop {
  position: fixed; inset: 0; z-index: 999; background: rgba(11, 26, 74, .42); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .25s;
}
.ui-backdrop.show { opacity: 1; }
html.ui-lock, html.ui-lock body { overflow: hidden; }

/* ---------- چک‌باکس ---------- */
.check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin-top: 3px; flex: none; cursor: pointer;
  border: 2px solid var(--ink-3); border-radius: 7px; background: #fff; display: grid; place-items: center; position: relative;
  transition: background .2s, border-color .2s, transform .3s var(--ui-spring);
}
.check input[type="checkbox"]::after {
  content: ""; width: 14px; height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  clip-path: inset(0 100% 0 0); transition: clip-path .28s var(--ui-ease) .05s;
}
.check input[type="checkbox"]:checked { background: var(--brand); border-color: var(--brand); animation: ui-tick .35s var(--ui-spring); }
.check input[type="checkbox"]:checked::after { clip-path: inset(0 0 0 0); }
.check input[type="checkbox"]:hover { border-color: var(--brand); }
.check input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--ui-ring); }
@keyframes ui-tick { 40% { transform: scale(.85); } }

/* ---------- فایل ---------- */
.ui-drop { position: relative; }
.ui-drop-zone {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 14px; cursor: pointer;
  background: linear-gradient(180deg, #fff, var(--brand-50)); border: 2px dashed #c3d0f5;
  transition: border-color .2s, background .2s, transform .25s var(--ui-ease), box-shadow .25s;
}
.ui-drop-zone:hover { border-color: var(--brand-500); }
.ui-drop-zone:focus-within { border-color: var(--brand); box-shadow: var(--ui-ring); }
.ui-file-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ui-drop-ic { flex: none; width: 52px; height: 52px; border-radius: 16px; background: #fff; color: var(--brand); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0, 45, 176, .12); }
.ui-drop-ic svg { width: 32px; height: 32px; }
.ui-drop-ic .arrow { transition: transform .3s var(--ui-ease); }
.ui-drop-zone:hover .ui-drop-ic .arrow { transform: translateY(-3px); }
.ui-drop-txt { font-size: 14px; color: var(--ink-2); line-height: 1.7; }
.ui-drop-txt b { color: var(--ink); }
.ui-drop-txt u { color: var(--brand); text-decoration: none; font-weight: 800; border-bottom: 2px solid var(--brand-100); }
.ui-drop-txt small { display: block; font-size: 12px; color: var(--ink-3); }
.ui-drop.over .ui-drop-zone { border-color: var(--brand); background: var(--brand-50); transform: scale(1.015); animation: ui-ants .8s linear infinite; }
.ui-drop.over .ui-drop-ic { animation: ui-bounce .7s var(--ui-ease) infinite alternate; }
@keyframes ui-bounce { to { transform: translateY(-5px); } }
@keyframes ui-ants { 50% { border-color: var(--brand-500); } }
.ui-drop-file {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: #fff;
  border: 1.5px solid var(--brand-100); animation: ui-file-in .35s var(--ui-spring);
}
@keyframes ui-file-in { from { opacity: 0; transform: scale(.96); } }
.ui-file-ic { flex: none; width: 46px; height: 46px; border-radius: 12px; overflow: hidden; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; }
.ui-file-ic svg { width: 24px; height: 24px; }
.ui-file-ic img { width: 100%; height: 100%; object-fit: cover; }
.ui-file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ui-file-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; text-align: right; }
.ui-file-size { font-size: 12px; color: var(--ink-2); }
.ui-file-x { flex: none; width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--bg); color: var(--ink-2); cursor: pointer; display: grid; place-items: center; transition: background .2s, color .2s, transform .2s; }
.ui-file-x:hover { background: #fde8e7; color: var(--err); transform: rotate(90deg); }
.ui-file-x svg { width: 18px; height: 18px; }
.ui-drop-err { color: var(--err); font-size: 13px; font-weight: 600; min-height: 0; }
.ui-drop-err:not(:empty) { margin-top: 6px; }
.ui-drop.bad .ui-drop-zone { border-color: var(--err); animation: shake .3s; }
[hidden] { display: none !important; }

/* ---------- نوار جست‌وجو ---------- */
.ui-search {
  position: relative; display: flex; align-items: center; height: 48px; width: 100%; max-width: 420px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 0 6px 0 6px;
  transition: border-color .2s, box-shadow .3s var(--ui-ease), max-width .35s var(--ui-ease);
}
.ui-search:hover { border-color: #c9d3ee; }
.ui-search:focus-within { border-color: var(--brand); box-shadow: var(--ui-ring), 0 8px 24px rgba(0, 45, 176, .1); }
.ui-search-ic { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-3); transition: color .2s, background .2s, transform .35s var(--ui-spring); }
.ui-search-ic svg { width: 20px; height: 20px; }
.ui-search:focus-within .ui-search-ic { color: #fff; background: var(--brand); transform: rotate(-12deg) scale(1.04); }
.ui-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; padding: 0 10px; font-weight: 600; }
.ui-search input::placeholder { color: var(--ink-3); font-weight: 500; }
.ui-search-x {
  flex: none; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--bg); color: var(--ink-2); cursor: pointer;
  display: grid; place-items: center; opacity: 0; transform: scale(.5); pointer-events: none;
  transition: opacity .2s, transform .3s var(--ui-spring), background .2s;
}
.ui-search-x svg { width: 16px; height: 16px; }
.ui-search.has-val .ui-search-x { opacity: 1; transform: none; pointer-events: auto; }
.ui-search-x:hover { background: var(--brand-50); color: var(--brand); }

/* جست‌وجوی محصولات و سؤالات */
.search-row { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 24px; }
.search-row .filters { margin-bottom: 0; }
@media (min-width: 900px) { .search-row { flex-direction: row-reverse; justify-content: space-between; } .search-row .ui-search { max-width: 320px; } .search-row .ui-search:focus-within { max-width: 380px; } }
.faq-search { display: flex; justify-content: center; margin: -8px auto 22px; max-width: 820px; }
.faq-search .ui-search { max-width: 100%; }
.ui-hit { background: #fff1c7; color: inherit; border-radius: 4px; padding: 0 2px; box-shadow: 0 0 0 1px #ffe08a; }
.ui-filtered-out { display: none !important; }
.ui-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-2); padding: 28px 12px; animation: ui-file-in .3s var(--ui-ease); }
.ui-empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.ui-count { font-size: 13px; color: var(--ink-2); text-align: center; margin: -10px 0 16px; min-height: 1em; }
