/* GanjehKala Search Panel v6.0 - Clean Storefront UI */

:root {
    --gk-search-bg: #fff;
    --gk-search-surface: #f7f8fa;
    --gk-search-text: #1f2937;
    --gk-search-muted: #7b8492;
    --gk-search-border: rgba(15, 23, 42, .09);
    --gk-search-primary: var(--gk-header-primary, var(--gk-primary, #2563eb));
    --gk-search-danger: #dc2626;
    --gk-search-success: #16803d;
    --gk-search-radius: 14px;
    --gk-search-shadow: 0 14px 40px rgba(15, 23, 42, .11);
}

.gk-live-search-wrap,
.gk-search-wrapper {
    position: relative;
}

.gk-search-panel,
.gk-search-panel * {
    box-sizing: border-box;
}

.gk-search-panel {
    position: absolute;
    inset-block-start: calc(100% + 8px);
    inset-inline-start: 0;
    z-index: 10020;
    display: none;
    flex-direction: column;
    width: min(var(--gk-header-search-panel-w, 640px), calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: min(var(--gk-header-search-panel-max-h, 430px), 76vh);
    overflow: hidden;
    direction: rtl;
    text-align: right;
    color: var(--gk-header-dropdown-text, var(--gk-search-text));
    background: var(--gk-header-dropdown-bg, var(--gk-search-bg));
    border: 1px solid var(--gk-header-dropdown-border, var(--gk-search-border));
    border-radius: var(--gk-search-radius);
    box-shadow: var(--gk-search-shadow);
    transform-origin: top center;
}

.gk-search-panel.open {
    display: flex;
    animation: gkSearchPanelIn .14s ease-out both;
}

@keyframes gkSearchPanelIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.gk-search-panel svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

/* Header: one quiet line, no decorative gradients or icon pills. */
.gk-search-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--gk-search-border);
    background: #fff;
    flex-shrink: 0;
}

.gk-search-panel__head strong {
    display: block;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--gk-search-text);
    font-size: 13px;
    font-weight: 750;
    line-height: 1.6;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gk-search-panel__count,
.gk-search-panel__query {
    min-width: 0;
    overflow: hidden;
    color: var(--gk-search-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gk-search-panel__query {
    max-width: 56%;
    color: var(--gk-search-text);
}

.gk-search-debug-time {
    color: var(--gk-search-muted);
    font-size: 10px;
    font-weight: 500;
    direction: ltr;
}

.gk-search-panel__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 12px 8px;
    background: #fff;
}

.gk-search-panel__body::-webkit-scrollbar { width: 5px; }
.gk-search-panel__body::-webkit-scrollbar-track { background: transparent; }
.gk-search-panel__body::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, .28);
    border-radius: 99px;
}

.gk-search-section {
    margin: 0;
    padding: 8px 0 4px;
}

.gk-search-section + .gk-search-section,
.gk-search-suggestion-grid + .gk-search-text-results {
    border-top: 1px solid var(--gk-search-border);
}

.gk-search-section__title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 2px 4px 6px;
    color: var(--gk-search-muted);
}

.gk-search-section__title > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: #9aa3af;
    background: transparent;
    border-radius: 0;
}

.gk-search-section__title > span svg {
    width: 15px;
    height: 15px;
}

.gk-search-section__title strong {
    color: #667085;
    font-size: 11px;
    font-weight: 700;
}

.gk-search-product-list,
.gk-search-link-list,
.gk-search-chip-list {
    display: grid;
    gap: 0;
}

.gk-search-result {
    -webkit-tap-highlight-color: transparent;
}

/* Product results are rows, not nested cards. */
.gk-search-product-card {
    position: relative;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    min-height: 76px;
    padding: 9px 4px;
    color: var(--gk-search-text);
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: 8px;
    transition: background-color .12s ease;
}

.gk-search-product-card + .gk-search-product-card {
    border-top: 1px solid rgba(15, 23, 42, .065);
}

.gk-search-product-card:hover,
.gk-search-product-card:focus-visible,
.gk-search-product-card.is-active {
    outline: none;
    background: #f8fafc;
    transform: none;
    box-shadow: none;
}

.gk-search-product-card__image {
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    color: var(--gk-search-muted);
    background: #f5f6f8;
}

.gk-search-product-card__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gk-search-product-card__main {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.gk-search-product-card__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    color: var(--gk-search-text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.75;
}

.gk-search-product-card__title mark,
.gk-search-link mark {
    padding: 0;
    border-radius: 0;
    color: var(--gk-search-primary);
    background: transparent;
    font-weight: inherit;
}

.gk-search-product-card__meta {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    overflow: hidden;
    color: var(--gk-search-muted);
    white-space: nowrap;
}

.gk-search-product-card__meta small,
.gk-search-rating {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 120px;
    padding: 0;
    overflow: hidden;
    color: var(--gk-search-muted);
    background: transparent;
    border: 0;
    border-radius: 0;
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.6;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gk-search-product-card__meta small + small::before {
    content: "·";
    margin: 0 6px;
    color: #c0c5cc;
}

.gk-search-rating { color: #8a6d1f; }
.gk-search-rating svg {
    width: 11px;
    height: 11px;
    fill: currentColor;
    stroke: none;
}

.gk-search-product-card__side {
    display: grid;
    justify-items: end;
    gap: 3px;
    min-width: 96px;
}

.gk-search-product-card__price {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 3px 6px;
    color: var(--gk-search-text);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.55;
    text-align: left;
    direction: rtl;
}

.gk-search-product-card__price ins {
    color: var(--gk-search-danger);
    text-decoration: none;
}

.gk-search-product-card__price del {
    color: #a0a7b2;
    font-size: 10px;
    font-weight: 500;
    text-decoration-thickness: 1px;
}

.gk-search-stock {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    padding: 0;
    border-radius: 0;
    background: transparent !important;
    font-size: 10px;
    font-weight: 600;
}

.gk-search-stock.is-in { color: var(--gk-search-success); }
.gk-search-stock.is-out { color: #b42318; }

.gk-search-suggestion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 20px;
    border-top: 1px solid var(--gk-search-border);
}

.gk-search-section--compact {
    padding: 8px 0 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.gk-search-chip,
.gk-search-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 36px;
    padding: 7px 4px;
    color: var(--gk-search-text);
    text-decoration: none;
    border: 0;
    border-radius: 6px;
    background: transparent;
    transition: background-color .12s ease, color .12s ease;
}

.gk-search-chip + .gk-search-chip,
.gk-search-link + .gk-search-link {
    border-top: 1px solid rgba(15, 23, 42, .055);
}

.gk-search-chip:hover,
.gk-search-chip:focus-visible,
.gk-search-chip.is-active,
.gk-search-link:hover,
.gk-search-link:focus-visible,
.gk-search-link.is-active {
    outline: none;
    color: var(--gk-search-primary);
    background: #f8fafc;
}

.gk-search-chip span,
.gk-search-link span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
}

.gk-search-chip small {
    min-width: 0;
    padding: 0;
    color: #9aa3af;
    background: transparent;
    border-radius: 0;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
}

.gk-search-text-results {
    display: grid;
    gap: 0;
}

.gk-search-link svg {
    width: 14px;
    height: 14px;
    color: #b0b7c1;
}

/* Footer is a simple navigation row instead of a large CTA card. */
.gk-search-panel__foot {
    padding: 0;
    border-top: 1px solid var(--gk-search-border);
    background: #fff;
    flex-shrink: 0;
}

.gk-search-all {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    color: var(--gk-search-primary);
    background: #fff;
    border: 0;
    border-radius: 0;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    box-shadow: none;
    transition: background-color .12s ease;
}

.gk-search-all:hover,
.gk-search-all:focus-visible {
    outline: none;
    filter: none;
    transform: none;
    box-shadow: none;
    background: #f8fafc;
}

.gk-search-all strong {
    min-width: 0;
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gk-search-all svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

/* Loading rows follow the same visual rhythm as actual results. */
.gk-search-loading {
    padding: 4px 12px 8px;
}

.gk-search-skeleton {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    min-height: 76px;
    padding: 9px 4px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
}

.gk-search-skeleton + .gk-search-skeleton {
    border-top: 1px solid rgba(15, 23, 42, .055);
}

.gk-search-skeleton__thumb,
.gk-search-skeleton__body i {
    display: block;
    position: relative;
    overflow: hidden;
    background: #eef0f3;
}

.gk-search-skeleton__thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
}

.gk-search-skeleton__body {
    display: grid;
    gap: 8px;
}

.gk-search-skeleton__body i {
    height: 8px;
    border-radius: 3px;
}

.gk-search-skeleton__body i:nth-child(1) { width: 72%; }
.gk-search-skeleton__body i:nth-child(2) { width: 46%; }
.gk-search-skeleton__body i:nth-child(3) { width: 28%; }

.gk-search-skeleton__thumb::after,
.gk-search-skeleton__body i::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.72), transparent);
    animation: gkSearchShimmer 1.35s infinite;
}

@keyframes gkSearchShimmer { to { transform: translateX(-100%); } }

.gk-search-empty {
    display: grid;
    justify-items: center;
    gap: 7px;
    padding: 28px 20px;
    text-align: center;
    color: var(--gk-search-text);
    background: #fff;
}

.gk-search-empty__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 3px;
    border-radius: 50%;
    color: #8c96a3;
    background: #f5f6f8;
}

.gk-search-empty--error .gk-search-empty__icon {
    color: var(--gk-search-danger);
    background: #fff5f5;
}

.gk-search-empty__icon svg {
    width: 26px;
    height: 26px;
    stroke-width: 1.6;
}

.gk-search-empty strong {
    font-size: 14px;
    font-weight: 750;
}

.gk-search-empty p {
    max-width: 360px;
    margin: 0;
    color: var(--gk-search-muted);
    font-size: 12px;
    line-height: 1.8;
}

.gk-search-empty__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 10px;
    margin-top: 4px;
    color: var(--gk-search-primary);
    background: transparent;
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
}

.gk-search-empty__action:hover,
.gk-search-empty__action:focus-visible {
    background: #f8fafc;
}

@media (max-width: 760px) {
    .gk-search-panel {
        width: calc(100vw - 24px);
        left: 50%;
        right: auto;
        max-height: min(78vh, 620px);
        border-radius: 14px;
        transform: translateX(-50%);
    }

    .gk-search-panel.open {
        animation: gkSearchPanelMobileIn .14s ease-out both;
    }

    @keyframes gkSearchPanelMobileIn {
        from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
        to { opacity: 1; transform: translateX(-50%) translateY(0); }
    }

    .gk-search-panel__head { padding-inline: 12px; }
    .gk-search-panel__body { padding-inline: 10px; }

    .gk-search-product-card {
        grid-template-columns: 52px minmax(0, 1fr);
        gap: 9px;
        min-height: 70px;
        padding: 8px 3px;
    }

    .gk-search-product-card__image {
        width: 52px;
        height: 52px;
        border-radius: 7px;
    }

    .gk-search-product-card__side {
        grid-column: 2 / 3;
        justify-items: start;
        min-width: 0;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px 8px;
    }

    .gk-search-product-card__title { font-size: 12.5px; }
    .gk-search-product-card__meta small:nth-child(n+3) { display: none; }
    .gk-search-suggestion-grid { grid-template-columns: 1fr; gap: 0; }
    .gk-search-section--compact + .gk-search-section--compact { border-top: 1px solid var(--gk-search-border); }
}

@media (max-width: 430px) {
    .gk-search-product-card__meta small:nth-child(n+2) { display: none; }
    .gk-search-product-card__price { font-size: 11.5px; }
    .gk-search-stock { font-size: 9.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .gk-search-panel,
    .gk-search-panel *,
    .gk-search-skeleton__thumb::after,
    .gk-search-skeleton__body i::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* Mobile header search ajax panel */
.gk-mobile-search.gk-live-search-wrap { position: fixed; }

.gk-mobile-search .gk-search-panel--mobile {
    position: static;
    inset: auto;
    width: auto;
    max-height: calc(100dvh - 96px);
    margin: 10px 12px 14px;
    z-index: 1;
    border-radius: 14px;
    transform: none;
}

.gk-mobile-search .gk-search-panel--mobile.open {
    display: flex;
    animation: gkSearchPanelIn .14s ease-out both;
}

.gk-mobile-search.gk-search-has-results .gk-mobile-search__empty { display: none !important; }
.gk-mobile-search .gk-search-panel--mobile .gk-search-panel__body { max-height: calc(100dvh - 190px); }

@media (max-width: 760px) {
    .gk-mobile-search .gk-search-panel--mobile,
    .gk-mobile-search .gk-search-panel--mobile.open {
        left: auto;
        right: auto;
        width: auto;
        transform: none;
    }
}

/* Single mobile results surface */
#gkMobileSearch .gk-mobile-search__content > .gk-search-panel--mobile {
    position: relative;
    inset: auto;
    z-index: 1;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    transform: none;
    transform-origin: center;
}

#gkMobileSearch .gk-mobile-search__content > .gk-search-panel--mobile.open {
    display: flex;
    min-height: 0;
    animation: gkSearchMobileFade .13s ease-out both;
}

@keyframes gkSearchMobileFade {
    from { opacity: 0; }
    to { opacity: 1; }
}
