/* GanjehKala Search Panel v5.0 - Storefront UI */

:root {
    --gk-search-bg: #ffffff;
    --gk-search-surface: #f8fafc;
    --gk-search-surface-2: #f1f5f9;
    --gk-search-text: #111827;
    --gk-search-muted: #6b7280;
    --gk-search-border: rgba(15, 23, 42, .10);
    --gk-search-primary: var(--gk-header-primary, var(--gk-primary, #2563eb));
    --gk-search-danger: #ef4056;
    --gk-search-success: #16a34a;
    --gk-search-warning: #f59e0b;
    --gk-search-radius: 18px;
    --gk-search-radius-lg: 24px;
    --gk-search-shadow: 0 24px 70px rgba(15, 23, 42, .16), 0 2px 10px rgba(15, 23, 42, .05);
}

.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% + 12px);
    inset-inline-start: 0;
    z-index: 10020;
    display: none;
    width: min(720px, 96vw);
    max-height: min(76vh, 680px);
    overflow: hidden;
    direction: rtl;
    text-align: right;
    color: var(--gk-search-text);
    background: var(--gk-search-bg);
    border: 1px solid var(--gk-search-border);
    border-radius: var(--gk-search-radius-lg);
    box-shadow: var(--gk-search-shadow);
    transform-origin: top center;
}

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

@keyframes gkSearchPanelIn {
    from { opacity: 0; transform: translateY(-8px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.gk-search-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--gk-search-border);
    background:
        radial-gradient(circle at 100% 0, color-mix(in srgb, var(--gk-search-primary) 11%, transparent), transparent 34%),
        linear-gradient(180deg, #fff, #fbfdff);
    flex-shrink: 0;
}

.gk-search-panel__head strong {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    font-weight: 800;
    color: var(--gk-search-text);
}

.gk-search-panel__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
    color: var(--gk-search-primary);
}

.gk-search-panel__eyebrow svg {
    width: 16px;
    height: 16px;
}

.gk-search-debug-time {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 11px;
    direction: ltr;
}

.gk-search-panel__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
    background: linear-gradient(180deg, #fff 0, #fff 64%, #fafafa 100%);
}

.gk-search-panel__body::-webkit-scrollbar {
    width: 6px;
}

.gk-search-panel__body::-webkit-scrollbar-track {
    background: transparent;
}

.gk-search-panel__body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .45);
    border-radius: 999px;
}

.gk-search-section {
    margin: 0 0 14px;
}

.gk-search-section:last-child {
    margin-bottom: 0;
}

.gk-search-section__title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 6px 9px;
    color: #475569;
}

.gk-search-section__title span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    color: var(--gk-search-primary);
    background: color-mix(in srgb, var(--gk-search-primary) 10%, transparent);
}

.gk-search-section__title strong {
    font-size: 13px;
    font-weight: 800;
}

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

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

.gk-search-product-card {
    position: relative;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto 24px;
    align-items: center;
    gap: 12px;
    padding: 10px;
    min-height: 86px;
    color: var(--gk-search-text);
    text-decoration: none;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 18px;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease, background .16s ease;
}

.gk-search-product-card:hover,
.gk-search-product-card:focus-visible,
.gk-search-product-card.is-active {
    outline: none;
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--gk-search-primary) 32%, rgba(15, 23, 42, .08));
    box-shadow: 0 12px 34px rgba(15, 23, 42, .09);
    background: linear-gradient(180deg, #fff, #fbfdff);
}

.gk-search-product-card__image {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    overflow: hidden;
    background: var(--gk-search-surface);
    border: 1px solid rgba(15, 23, 42, .08);
    color: var(--gk-search-muted);
}

.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: 7px;
}

.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: 14px;
    font-weight: 800;
    line-height: 1.7;
}

.gk-search-product-card__title mark,
.gk-search-link mark {
    padding: 0 3px;
    border-radius: 5px;
    color: var(--gk-search-primary);
    background: color-mix(in srgb, var(--gk-search-primary) 13%, transparent);
}

.gk-search-product-card__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 22px;
}

.gk-search-product-card__meta small,
.gk-search-rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, .06);
}

.gk-search-rating {
    color: #a16207;
    background: #fffbeb;
}

.gk-search-rating svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
    stroke: none;
}

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

.gk-search-product-card__price {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 4px 7px;
    color: var(--gk-search-text);
    font-size: 13px;
    font-weight: 900;
    line-height: 1.5;
    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: #9ca3af;
    font-size: 11px;
    font-weight: 600;
    text-decoration-thickness: 1px;
}

.gk-search-stock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.gk-search-stock.is-in {
    color: #15803d;
    background: #ecfdf5;
}

.gk-search-stock.is-out {
    color: #b91c1c;
    background: #fef2f2;
}

.gk-search-product-card__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: #94a3b8;
    background: #f8fafc;
    transition: transform .16s ease, color .16s ease, background .16s ease;
}

.gk-search-product-card:hover .gk-search-product-card__arrow,
.gk-search-product-card.is-active .gk-search-product-card__arrow {
    color: #fff;
    background: var(--gk-search-primary);
    transform: translateX(-2px);
}

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

.gk-search-section--compact {
    padding: 10px;
    border: 1px solid rgba(15, 23, 42, .07);
    border-radius: 18px;
    background: #fff;
}

.gk-search-chip-list {
    gap: 7px;
}

.gk-search-chip,
.gk-search-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 11px;
    color: var(--gk-search-text);
    text-decoration: none;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, .05);
    transition: background .16s ease, border-color .16s ease, color .16s ease;
}

.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: color-mix(in srgb, var(--gk-search-primary) 8%, #fff);
    border-color: color-mix(in srgb, var(--gk-search-primary) 24%, transparent);
}

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

.gk-search-chip small {
    min-width: 28px;
    text-align: center;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    background: #fff;
    border-radius: 999px;
    padding: 2px 7px;
}

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

.gk-search-link svg {
    width: 16px;
    height: 16px;
    color: #94a3b8;
}

.gk-search-panel__foot {
    padding: 12px;
    border-top: 1px solid var(--gk-search-border);
    background: #fff;
    flex-shrink: 0;
}

.gk-search-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    color: #fff;
    background: var(--gk-search-primary);
    border-radius: 16px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--gk-search-primary) 25%, transparent);
    transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}

.gk-search-all:hover,
.gk-search-all:focus-visible {
    outline: none;
    filter: brightness(1.04);
    transform: translateY(-1px);
    box-shadow: 0 14px 30px color-mix(in srgb, var(--gk-search-primary) 32%, transparent);
}

.gk-search-all strong {
    font-weight: 900;
}

.gk-search-all svg {
    width: 17px;
    height: 17px;
    stroke-width: 2.4;
}

.gk-search-loading {
    padding: 12px;
}

.gk-search-skeleton {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid rgba(15, 23, 42, .06);
    border-radius: 18px;
    background: #fff;
}

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

.gk-search-skeleton__thumb {
    width: 64px;
    height: 64px;
    border-radius: 16px;
}

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

.gk-search-skeleton__body i {
    height: 10px;
    border-radius: 999px;
}

.gk-search-skeleton__body i:nth-child(1) { width: 76%; }
.gk-search-skeleton__body i:nth-child(2) { width: 52%; }
.gk-search-skeleton__body i:nth-child(3) { width: 34%; }

.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,.75), transparent);
    animation: gkSearchShimmer 1.35s infinite;
}

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

.gk-search-empty {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 38px 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: 76px;
    height: 76px;
    border-radius: 26px;
    color: var(--gk-search-primary);
    background: color-mix(in srgb, var(--gk-search-primary) 9%, transparent);
}

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

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

.gk-search-empty strong {
    font-size: 15px;
    font-weight: 900;
}

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

.gk-search-empty__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    margin-top: 4px;
    color: var(--gk-search-primary);
    background: color-mix(in srgb, var(--gk-search-primary) 9%, transparent);
    border-radius: 999px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
}

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

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

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

    .gk-search-panel__head {
        padding: 14px;
    }

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

    .gk-search-product-card {
        grid-template-columns: 58px minmax(0, 1fr) 22px;
        gap: 10px;
        min-height: 82px;
    }

    .gk-search-product-card__image {
        width: 58px;
        height: 58px;
        border-radius: 15px;
    }

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

    .gk-search-product-card__arrow {
        grid-column: 3 / 4;
        grid-row: 1 / span 2;
    }

    .gk-search-product-card__title {
        font-size: 13px;
    }

    .gk-search-product-card__meta small:nth-child(n+3) {
        display: none;
    }

    .gk-search-suggestion-grid {
        grid-template-columns: 1fr;
    }
}

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

    .gk-search-product-card__price {
        font-size: 12px;
    }

    .gk-search-stock {
        font-size: 10px;
        padding-inline: 8px;
    }
}

@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;
    transform: none;
    z-index: 1;
    border-radius: 20px;
}

.gk-mobile-search .gk-search-panel--mobile.open {
    display: flex;
    animation: gkSearchPanelIn .16s 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;
        transform: none;
        width: auto;
    }
}
