/* Header search + autocomplete */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.search-bar {
    position: relative;
}

.search-bar__form {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
}

.search-bar__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    display: flex;
}

.search-bar__form input[type="search"] {
    width: 100%;
    height: 44px;
    box-sizing: border-box;
    padding: 0 16px 0 42px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.2;
    color: #111827;
    background: #f9fafb;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.search-bar__form input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.search-bar__form input[type="search"]:focus {
    outline: none;
    border-color: #16a34a;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.search-bar--open .search-bar__form input[type="search"] {
    border-color: #16a34a;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.search-bar__submit {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: #16a34a;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-bar__submit:hover {
    background: #15803d;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 6000;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
    overflow: hidden;
}

.search-dropdown[hidden] {
    display: none !important;
}

.search-dropdown__inner {
    max-height: min(70vh, 420px);
    overflow-y: auto;
}

.search-dropdown__section {
    padding: 10px 0 6px;
    border-top: 1px solid #f3f4f6;
}

.search-dropdown__section:first-child {
    border-top: none;
}

.search-dropdown__heading {
    margin: 0;
    padding: 4px 14px 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #9ca3af;
}

.search-dropdown__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 14px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.search-dropdown__item:hover,
.search-dropdown__item.is-active {
    background: #f0fdf4;
}

.search-dropdown__thumb {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #16a34a;
}

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

.search-dropdown__body {
    flex: 1 1 auto;
    min-width: 0;
}

.search-dropdown__title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-dropdown__sub {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-dropdown__meta {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    color: #16a34a;
}

.search-dropdown__product {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 0;
}

.search-dropdown__product .search-dropdown__item {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 0 9px 14px;
}

.search-dropdown__bag-wrap {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-right: 10px;
    max-width: 118px;
}

.search-dropdown__attr {
    width: 100%;
    min-height: 28px;
    padding: 0 6px;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    background: #ffffff;
    font-size: 10px;
    color: #374151;
}

.search-dropdown__bag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    border: none;
    border-radius: 8px;
    background: #16a34a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.search-dropdown__bag:hover:not(:disabled) {
    background: #15803d;
}

.search-dropdown__bag:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.search-dropdown__bag.is-loading {
    opacity: 0.75;
}

.search-dropdown__bag.is-added {
    background: #14532d;
}

.search-dropdown__empty,
.search-dropdown__loading {
    padding: 18px 14px;
    font-size: 13px;
    color: #6b7280;
    text-align: center;
}

.search-dropdown__footer {
    padding: 10px 14px;
    border-top: 1px solid #f3f4f6;
    background: #fafafa;
}

.search-dropdown__view-all {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #111827;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.search-dropdown__view-all:hover {
    background: #1f2937;
    color: #ffffff;
}

/* Search results page */
.search-page {
    padding: 8px 0 40px;
}

.search-page__hero {
    margin-bottom: 22px;
    padding: 22px 20px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-left: 4px solid #16a34a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.search-page__title {
    margin: 0 0 6px;
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    font-weight: 700;
    color: #111827;
}

.search-page__summary {
    margin: 0 0 16px;
    font-size: 13px;
    color: #6b7280;
}

.search-page__form {
    position: relative;
    max-width: 640px;
}

.search-page__form .search-bar__form input[type="search"] {
    height: 46px;
    font-size: 15px;
}

.search-page__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0 18px;
}

.search-page__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.search-page__tab {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.search-page__tab:hover {
    border-color: #16a34a;
    color: #16a34a;
}

.search-page__tab.is-active {
    background: #16a34a;
    border-color: #16a34a;
    color: #ffffff;
}

.search-page__sort {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
}

.search-page__sort select {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    font-size: 12px;
    color: #111827;
    cursor: pointer;
}

.search-page__sort select:focus {
    outline: none;
    border-color: #16a34a;
}

.search-page__section {
    margin-top: 28px;
}

.search-page__section-title {
    margin: 0 0 6px;
    padding: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

.search-page__section-count {
    margin: 0 0 14px;
    font-size: 12px;
    color: #6b7280;
}

.search-page__empty {
    margin: 28px 0;
    padding: 28px 20px;
    border-radius: 14px;
    background: #f9fafb;
    border: 1px dashed #e5e7eb;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.search-page__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.search-page__chip {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.search-page__chip:hover {
    background: #dcfce7;
    color: #14532d;
}

/* Search result cards */
.search-grid {
    display: grid;
    gap: 16px;
    padding: 0;
}

.search-grid--products {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.search-grid--stores {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.search-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.search-card--product:hover {
    transform: translateY(-2px);
    border-color: #d1fae5;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.search-card--store {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 14px;
    text-decoration: none;
    color: inherit;
}

.search-card--store:hover {
    border-color: #16a34a;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.1);
}

.search-card__media {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    background: #f3f4f6;
    overflow: hidden;
    text-decoration: none;
}

.search-card__media--store {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    aspect-ratio: auto;
    border-radius: 12px;
}

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

.search-card__image--logo {
    object-fit: contain;
    background: #ffffff;
    padding: 8px;
}

.search-card__image--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    color: #9ca3af;
    font-size: 12px;
}

.search-card__price {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(17, 24, 39, 0.88);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
}

.search-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 4px;
    padding: 14px;
}

.search-card__body--store {
    padding: 0;
    min-width: 0;
}

.search-card__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: #111827;
    text-decoration: none;
}

.search-card__title:hover {
    color: #16a34a;
}

.search-card__store {
    font-size: 12px;
    color: #6b7280;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-card__store:hover {
    color: #16a34a;
}

.search-card__category {
    display: inline-block;
    align-self: flex-start;
    margin-top: 2px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f0fdf4;
    color: #166534;
    font-size: 10px;
    font-weight: 600;
}

.search-card__visit {
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #16a34a;
}

.search-card__cart-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 10px;
}

.search-card__select {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    font-size: 11px;
    color: #374151;
}

.search-card__select:focus {
    outline: none;
    border-color: #16a34a;
}

.search-card__bag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 38px;
    padding: 0 12px;
    border: none;
    border-radius: 10px;
    background: #16a34a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.search-card__bag-btn:hover:not(:disabled) {
    background: #15803d;
}

.search-card__bag-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.search-card__bag-btn.is-loading {
    opacity: 0.75;
}

.search-card__bag-btn.is-added {
    background: #14532d;
}

.search-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 7000;
    max-width: min(92vw, 420px);
    padding: 12px 16px;
    border-radius: 12px;
    background: #111827;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
}

.search-toast--error {
    background: #b91c1c;
}

@media (max-width: 768px) {
    .search-dropdown {
        position: fixed;
        top: 72px;
        left: 12px;
        right: 12px;
        width: auto;
    }

    .search-page__toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-page__sort {
        justify-content: space-between;
    }

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

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

    .search-card__body {
        padding: 10px;
    }

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

    .search-card__bag-btn {
        min-height: 36px;
        font-size: 11px;
    }

    .search-page__hero {
        padding: 18px 14px;
    }

    .search-dropdown__product {
        flex-wrap: wrap;
        padding-right: 0;
    }

    .search-dropdown__bag-wrap {
        width: calc(100% - 14px);
        max-width: none;
        margin: 0 0 8px 14px;
        flex-direction: row;
        align-items: center;
    }

    .search-dropdown__attr {
        flex: 1 1 auto;
        min-width: 0;
    }

    .search-dropdown__bag {
        flex: 0 0 auto;
    }
}

@media (max-width: 400px) {
    .search-grid--products {
        grid-template-columns: 1fr;
    }
}
