/* =====================================================================
 * Formula Ads Pro — Quick Search (minimal, modern)
 * Tokens: primary #1AA29A, text #0f172a, muted #64748b, border #e2e8f0
 * ===================================================================== */

.fap-qs-wrap {
    display: block;
    direction: rtl;
    font-family: inherit;
    width: 100%;
}

/* ---------- Trigger: flat input with rotating placeholder ---------- */
.fap-qs-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 52px;
    padding: 0 20px;
    background: rgba(26, 162, 154, 0.06);
    color: #475569;
    cursor: pointer;
    border: 1px solid rgba(26, 162, 154, 0.18);
    border-radius: 12px;
    font-family: inherit;
    font-size: 14.5px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    box-sizing: border-box;
    text-align: right;
}

.fap-qs-trigger:hover {
    background: rgba(26, 162, 154, 0.10);
    border-color: rgba(26, 162, 154, 0.30);
}

.fap-qs-trigger:active {
    background: rgba(26, 162, 154, 0.13);
}

.fap-qs-trigger:focus-visible {
    outline: 2px solid #1AA29A;
    outline-offset: 2px;
}

.fap-qs-trigger__placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    text-align: right;
    color: #94a3b8;
    font-size: 14.5px;
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
    order: 1;
}

.fap-qs-trigger__rotating-text {
    color: #475569;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.fap-qs-trigger__caret {
    display: inline-block;
    width: 1.5px;
    height: 16px;
    background: #1AA29A;
    margin-right: 3px;
    vertical-align: middle;
    flex-shrink: 0;
    animation: fapqsBlink 0.9s steps(1) infinite;
}

.fap-qs-trigger__icon {
    flex-shrink: 0;
    color: #1AA29A;
    order: 2;
}

.fap-qs-trigger--button {
    width: auto;
    background: #f3f4f6;
    color: #0f172a;
    padding: 0 18px;
    height: 44px;
}

.fap-qs-trigger--icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
}

@keyframes fapqsBlink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fap-qs-trigger__caret {
        animation: none;
        opacity: 1;
    }
}

/* ---------- Modal ---------- */
.fap-qs-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483647; /* max safe int — beat any site header / sticky bar */
    display: none;
    direction: rtl;
    font-family: inherit;
}

.fap-qs-modal[aria-hidden="false"] {
    display: block;
}

.fap-qs-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.50);
    backdrop-filter: blur(8px) saturate(1.2);
    -webkit-backdrop-filter: blur(8px) saturate(1.2);
    animation: fapqsFadeIn 0.2s ease-out;
}

.fap-qs-modal__sheet {
    position: absolute;
    top: 10vh;
    left: 50%;
    transform: translateX(-50%);
    width: min(640px, calc(100% - 32px));
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 20px;
    box-shadow:
        0 40px 80px -20px rgba(15, 23, 42, 0.35),
        0 0 0 1px rgba(15, 23, 42, 0.04);
    overflow: hidden;
    animation: fapqsSlideDown 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Drag handle: hidden on desktop, visible on mobile */
.fap-qs-modal__handle {
    display: none;
}

/* Header */
.fap-qs-modal__header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #f1f5f9;
}

/* Input shell: a polished input-like card */
.fap-qs-modal__input-shell {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 52px;
    padding: 0 16px;
    background: #f8fafc;
    border: 1.5px solid transparent;
    border-radius: 14px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    min-width: 0;
}

.fap-qs-modal__input-shell:hover {
    background: #f1f5f9;
}

.fap-qs-modal__input-shell:focus-within {
    background: #ffffff;
    border-color: #1AA29A;
    box-shadow: 0 0 0 4px rgba(26, 162, 154, 0.12);
}

.fap-qs-modal__search-icon {
    color: #94a3b8;
    flex-shrink: 0;
    transition: color 0.18s ease;
}

.fap-qs-modal__input-shell:focus-within .fap-qs-modal__search-icon {
    color: #1AA29A;
}

.fap-qs-modal__input {
    flex: 1;
    width: 100%;
    height: 100%;
    padding: 0;
    font-size: 15.5px;
    border: none;
    background: transparent;
    color: #0f172a;
    outline: none;
    font-family: inherit;
    min-width: 0;
}

.fap-qs-modal__input::placeholder {
    color: #94a3b8;
}

.fap-qs-modal__clear {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.fap-qs-modal__clear:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.fap-qs-modal__close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: transparent;
    color: #94a3b8;
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.fap-qs-modal__close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Loading bar under header */
.fap-qs-loader {
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    overflow: hidden;
}

.fap-qs-loader[hidden] {
    display: none;
}

.fap-qs-loader::after {
    content: '';
    display: block;
    width: 35%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #1AA29A, transparent);
    animation: fapqsBarSlide 1s linear infinite;
}

@keyframes fapqsBarSlide {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(385%);
    }
}

/* Body */
.fap-qs-modal__body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 14px;
    background: #ffffff;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.fap-qs-modal__body::-webkit-scrollbar {
    width: 8px;
}

.fap-qs-modal__body::-webkit-scrollbar-track {
    background: transparent;
}

.fap-qs-modal__body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
    border: 2px solid #ffffff;
}

.fap-qs-modal__body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.fap-qs-hint {
    display: none;
}

/* Section title (e.g. "جستجوهای پرطرفدار") */
.fap-qs-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 22px 10px;
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.fap-qs-section-title svg {
    color: #1AA29A;
    flex-shrink: 0;
}

/* Popular chips section */
.fap-qs-popular {
    padding: 4px 18px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fap-qs-chip,
.fap-qs-chip:hover,
.fap-qs-chip:focus,
.fap-qs-chip:active,
.fap-qs-chip:visited {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 999px;
    color: #334155;
    font-size: 13px;
    text-decoration: none !important;
    box-shadow: none !important;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.fap-qs-chip > * {
    text-decoration: none !important;
}

.fap-qs-chip:hover {
    border-color: #1AA29A;
    color: #1AA29A;
    background: rgba(26, 162, 154, 0.04);
}

.fap-qs-chip__arrow {
    color: #cbd5e1;
    transition: color 0.15s ease, transform 0.15s ease;
}

.fap-qs-chip:hover .fap-qs-chip__arrow {
    color: #1AA29A;
    transform: translateX(-2px);
}

/* Popular skeleton chips */
.fap-qs-popular__skeleton {
    padding: 4px 18px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fap-qs-popular__skeleton-chip {
    height: 34px;
    width: 140px;
    border-radius: 999px;
    background: linear-gradient(90deg, #f1f5f9 0%, #f8fafc 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: fapqsShimmer 1.4s linear infinite;
}

.fap-qs-popular__skeleton-chip:nth-child(2) {
    width: 110px;
}

.fap-qs-popular__skeleton-chip:nth-child(3) {
    width: 160px;
}

.fap-qs-popular__skeleton-chip:nth-child(4) {
    width: 130px;
}

.fap-qs-popular__skeleton-chip:nth-child(5) {
    width: 150px;
}

.fap-qs-popular__skeleton-chip:nth-child(6) {
    width: 120px;
}

/* Result list */
.fap-qs-results {
    list-style: none;
    margin: 0;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.fap-qs-results[hidden] {
    display: none;
}

.fap-qs-item,
.fap-qs-item:hover,
.fap-qs-item:focus,
.fap-qs-item:active,
.fap-qs-item:visited {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none !important;
    box-shadow: none !important;
    color: inherit;
    transition: background 0.12s ease;
}
.fap-qs-item > *,
.fap-qs-item__main > *,
.fap-qs-item__label,
.fap-qs-item__label *,
.fap-qs-item__count {
    text-decoration: none !important;
}

.fap-qs-item:hover,
.fap-qs-item.is-active {
    background: #f8fafc;
}

.fap-qs-item__main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.fap-qs-item__label {
    font-size: 14.5px;
    font-weight: 500;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fap-qs-item__sub {
    display: none;
}

.fap-qs-item__type {
    display: none;
}

.fap-qs-item__count {
    flex-shrink: 0;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 400;
}

.fap-qs-item__arrow {
    flex-shrink: 0;
    color: #cbd5e1;
    opacity: 0;
    transform: translateX(4px);
    transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.fap-qs-item:hover .fap-qs-item__arrow,
.fap-qs-item.is-active .fap-qs-item__arrow {
    opacity: 1;
    transform: translateX(0);
    color: #1AA29A;
}

.fap-qs-item__label mark {
    background: transparent;
    color: #1AA29A;
    font-weight: 700;
    padding: 0;
}

/* ---------- Skeleton loader (search results) ---------- */
.fap-qs-skeleton {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.fap-qs-skeleton[hidden] {
    display: none;
}

.fap-qs-skeleton__row {
    padding: 11px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fap-qs-skeleton__bar {
    height: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f1f5f9 0%, #f8fafc 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: fapqsShimmer 1.4s linear infinite;
}

.fap-qs-skeleton__bar--wide {
    width: 70%;
}

.fap-qs-skeleton__bar--narrow {
    width: 45%;
}

@keyframes fapqsShimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

/* Empty initial / no results */
.fap-qs-empty {
    padding: 50px 20px 60px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.fap-qs-empty[hidden] {
    display: none;
}

.fap-qs-empty__icon {
    color: #e2e8f0;
}

.fap-qs-empty__title {
    color: #64748b;
    font-size: 15px;
    font-weight: 500;
}

.fap-qs-empty__sub {
    color: #94a3b8;
    font-size: 12.5px;
}

/* Body lock */
body.fap-qs-locked {
    overflow: hidden;
}

@keyframes fapqsFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fapqsSlideDown {
    from {
        transform: translate(-50%, -10px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* ---------- Mobile (bottom-sheet, app-like) ---------- */
@media (max-width: 600px) {
    .fap-qs-modal__backdrop {
        background: rgba(15, 23, 42, 0.55);
    }

    .fap-qs-modal__sheet {
        top: auto;
        bottom: 0;
        left: 0;
        transform: translateY(0);
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: 24px 24px 0 0;
        animation: fapqsSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .fap-qs-modal__handle {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 0 4px;
    }

    .fap-qs-modal__handle::before {
        content: '';
        width: 40px;
        height: 4px;
        background: #cbd5e1;
        border-radius: 4px;
    }

    .fap-qs-modal__header {
        padding: 6px 14px 10px;
        gap: 6px;
    }

    .fap-qs-modal__input-shell {
        height: 48px;
        padding: 0 14px;
    }

    .fap-qs-modal__input {
        font-size: 16px;
    }

    /* avoid iOS auto-zoom */
    .fap-qs-modal__close {
        width: 38px;
        height: 38px;
    }

    .fap-qs-popular {
        padding: 4px 14px 16px;
    }

    .fap-qs-section-title {
        padding: 14px 18px 10px;
    }
}

@keyframes fapqsSlideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {

    .fap-qs-modal__sheet,
    .fap-qs-modal__backdrop,
    .fap-qs-skeleton__bar,
    .fap-qs-popular__skeleton-chip,
    .fap-qs-loader::after {
        animation: none;
    }
}

input.fap-qs-modal__input {
    border: none !important;
    direction: rtl;
}