.ftkp-root,
.ftkp-root * {
    box-sizing: border-box;
}

.ftkp-root {
    --ftkp-border: #e5e7eb;
    --ftkp-muted: #6b7280;
    --ftkp-text: #111827;
    --ftkp-soft: #f8fafc;
    --ftkp-accent: #111827;
    position: relative;
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: 0;
    color: var(--ftkp-text);
    font: inherit;
    z-index: 99998;
}

.ftkp-form {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--ftkp-border);
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.ftkp-root.is-open .ftkp-form {
    border-color: #cbd5e1;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, .05);
}

.ftkp-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    margin: 0;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--ftkp-text);
    font: inherit;
    font-size: 14px;
    text-align: right;
    -webkit-appearance: none;
    appearance: none;
}

.ftkp-input::-webkit-search-cancel-button {
    display: none;
}

.ftkp-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.ftkp-submit,
.ftkp-close,
.ftkp-clear-recent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: #374151;
    cursor: pointer;
    box-shadow: none;
}

.ftkp-submit {
    order: -2;
    width: 44px;
    height: 44px;
    padding: 0 !important;
}

.ftkp-submit svg {
    display: block;
    width: 21px !important;
    height: 21px !important;
    min-width: 21px;
    min-height: 21px;
    fill: currentColor;
}

.ftkp-section-head svg {
    fill: currentColor;
}

.ftkp-input {
    order: 0;
}

.ftkp-close {
    order: 2;
    width: 42px;
    height: 44px;
    border-right: 1px solid #f1f5f9;
    font-size: 24px;
    line-height: 1;
    color: #94a3b8;
}

.ftkp-close[hidden],
.ftkp-panel[hidden],
.ftkp-live-view[hidden],
.ftkp-initial-view[hidden],
.ftkp-suggestions-wrap[hidden],
.ftkp-all-results[hidden] {
    display: none !important;
}

.ftkp-panel {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 8px);
    width: min(500px, calc(100vw - 24px));
    max-height: min(72vh, 680px);
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid #dbe1e8;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .16), 0 3px 10px rgba(15, 23, 42, .08);
    scrollbar-width: thin;
}

.ftkp-section {
    padding: 18px 20px;
}

.ftkp-section + .ftkp-section {
    border-top: 1px solid #eef2f6;
}

.ftkp-section-head,
.ftkp-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.ftkp-section-head h3,
.ftkp-result-head h4 {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 0;
    color: #1f2937;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.7;
}

.ftkp-section-head h3 svg {
    color: #64748b;
}

.ftkp-clear-recent {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    color: #94a3b8;
}

.ftkp-clear-recent:hover {
    background: #f8fafc;
    color: #475569;
}

.ftkp-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ftkp-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    max-width: 100%;
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569 !important;
    font-size: 13px;
    line-height: 1.5;
    text-decoration: none !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.ftkp-chip:hover,
.ftkp-chip:focus-visible {
    border-color: #cbd5e1;
    background: #fff;
    color: #111827 !important;
}

.ftkp-recent-list:empty::before {
    content: "هنوز جستجویی ندارید.";
    color: #9ca3af;
    font-size: 13px;
}

.ftkp-popular-list:empty::before {
    content: "هنوز داده کافی برای نمایش پرجستجوها وجود ندارد.";
    color: #9ca3af;
    font-size: 13px;
}

.ftkp-live-view {
    padding: 14px;
}

.ftkp-status {
    min-height: 0;
    padding: 0;
    color: var(--ftkp-muted);
    font-size: 13px;
    text-align: center;
}

.ftkp-status.is-loading,
.ftkp-status.is-empty {
    padding: 24px 12px;
}

.ftkp-status.is-loading::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-inline-end: 8px;
    vertical-align: -3px;
    border: 2px solid #dbe1e8;
    border-top-color: #64748b;
    border-radius: 50%;
    animation: ftkp-spin .7s linear infinite;
}

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

.ftkp-suggestions-wrap {
    padding: 4px 4px 14px;
    border-bottom: 1px solid #eef2f6;
    margin-bottom: 14px;
}

.ftkp-mini-title {
    margin-bottom: 8px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.ftkp-suggestions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    padding: 1px 1px 3px;
}

.ftkp-suggestions::-webkit-scrollbar {
    display: none;
}

.ftkp-suggestion-chip {
    flex: 0 0 auto;
    max-width: 240px;
    background: #fff;
    scroll-snap-align: start;
}

.ftkp-results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
}

.ftkp-result-section {
    min-width: 0;
    padding: 12px;
    border: 1px solid #edf0f3;
    border-radius: 10px;
    background: #fff;
}

.ftkp-result-head {
    justify-content: flex-start;
    margin-bottom: 8px;
}

.ftkp-result-head h4 {
    font-size: 13px;
}

.ftkp-result-icon {
    color: #64748b;
    font-size: 14px;
}

.ftkp-product-list,
.ftkp-post-list,
.ftkp-category-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ftkp-product-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 8px;
    border-radius: 8px;
    color: #1f2937 !important;
    text-decoration: none !important;
}

.ftkp-product-item:hover,
.ftkp-post-item:hover,
.ftkp-category-item:hover {
    background: #f8fafc;
}

.ftkp-product-media {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    overflow: hidden;
    border: 1px solid #edf0f3;
    border-radius: 8px;
    background: #f8fafc;
}

.ftkp-product-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ftkp-product-placeholder {
    color: #cbd5e1;
    font-size: 24px;
}

.ftkp-product-info {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}

.ftkp-product-title {
    overflow: hidden;
    color: #1f2937;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ftkp-product-price {
    color: #374151;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
}

.ftkp-post-item,
.ftkp-category-item {
    display: block;
    padding: 8px;
    border-radius: 7px;
    color: #374151 !important;
    font-size: 13px;
    line-height: 1.7;
    text-decoration: none !important;
}

.ftkp-category-item {
    border-bottom: 1px dashed #eef2f6;
}

.ftkp-category-item:last-child {
    border-bottom: 0;
}

.ftkp-all-results {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 9px;
    background: #f8fafc;
    color: #1f2937 !important;
    font-size: 13px;
    text-decoration: none !important;
}

.ftkp-all-results:hover {
    background: #f1f5f9;
}

.ftkp-all-results strong {
    font-weight: 800;
}

.ftkp-root a:focus-visible,
.ftkp-root button:focus-visible,
.ftkp-root input:focus-visible {
    outline: 2px solid #94a3b8 !important;
    outline-offset: 2px;
}

@media (max-width: 800px) and (min-width: 641px) {
    .ftkp-panel {
        width: min(500px, calc(100vw - 24px));
    }
}

@media (max-width: 640px) {
    .ftkp-root:not(.is-open) {
        width: 36px;
        max-width: 36px;
        transform: translateY(9px);
    }

    .ftkp-root:not(.is-open) .ftkp-form {
        width: 36px;
        min-height: 36px;
        border: 0;
        border-radius: 7px;
        background: transparent;
        overflow: visible;
        box-shadow: none;
    }

    .ftkp-root:not(.is-open) .ftkp-input {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        min-width: 0 !important;
        padding: 0 !important;
        opacity: 0;
        pointer-events: none;
    }

    .ftkp-root:not(.is-open) .ftkp-submit {
        width: 36px;
        height: 36px;
        padding: 0 !important;
        border: 1px solid #d1d5db !important;
        border-radius: 7px !important;
        background: #fff !important;
        color: #334155;
        box-shadow: none !important;
    }

    .ftkp-root:not(.is-open) .ftkp-submit:hover,
    .ftkp-root:not(.is-open) .ftkp-submit:focus-visible {
        border-color: #cbd5e1 !important;
        background: #f8fafc !important;
    }

    .ftkp-root:not(.is-open) .ftkp-submit svg {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px;
        min-height: 18px;
    }

    body.ftkp-mobile-open {
        overflow: hidden;
    }

    .ftkp-root.is-open {
        position: fixed;
        inset: 0;
        z-index: 2147483000;
        max-width: none;
        margin: 0;
        padding: 10px;
        background: #fff;
    }

    .ftkp-root.is-open .ftkp-form {
        position: relative;
        z-index: 2;
        border-radius: 9px;
        box-shadow: none;
    }

    .ftkp-root.is-open .ftkp-panel {
        position: absolute;
        inset: 64px 10px 10px;
        width: auto;
        max-height: none;
        border: 0;
        border-top: 1px solid #eef2f6;
        border-radius: 0;
        box-shadow: none;
    }

    .ftkp-panel {
        width: calc(100vw - 20px);
    }

    .ftkp-section {
        padding: 16px 8px;
    }

    .ftkp-live-view {
        padding: 12px 2px 20px;
    }

    .ftkp-results-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ftkp-products {
        order: 1;
    }

    .ftkp-categories {
        order: 2;
    }

    .ftkp-posts {
        order: 3;
    }

    .ftkp-result-section {
        padding: 10px;
    }

    .ftkp-chip-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .ftkp-chip-row::-webkit-scrollbar {
        display: none;
    }

    .ftkp-chip {
        flex: 0 0 auto;
    }

    .ftkp-product-media {
        flex-basis: 48px;
        width: 48px;
        height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ftkp-chip,
    .ftkp-status.is-loading::before {
        transition: none;
        animation-duration: .001ms;
        animation-iteration-count: 1;
    }
}
