/* ===================================================================
   Search results (search.php)
   =================================================================== */

.search-page {
    padding: 40px 0 80px;
}

/* ── Breadcrumb ─────────────────────────────────────────────────── */

.search-page__breadcrumb {
    margin-bottom: 24px;
    overflow-x: auto;
    scrollbar-width: none;
}

.search-page__breadcrumb::-webkit-scrollbar {
    display: none;
}

.search-page__breadcrumb .hl-bc-text {
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* Desktop: "Strona główna" text only, no home icon */
@media (min-width: 768px) {
    .search-page__breadcrumb .hl-bc-home-icon {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

/* Mobile: home icon only, no "Strona główna" text */
@media (max-width: 767px) {
    .search-page__breadcrumb .hl-bc-home-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

/* ── Head: title + search box ──────────────────────────────────── */

.search-page__head {
    position: sticky;
    top: var(--nav-height, 70px);
    z-index: 100;
    margin-bottom: 40px;
    padding-bottom: 20px;
    background: var(--wp--preset--color--white);
    border-bottom: 1px solid transparent;
    transition: top .35s ease, border-color .2s ease;
}

.search-page__head.is-stuck {
    border-bottom-color: #e4e4ea;
}

.search-page__title {
    font-size: 32px;
    font-weight: 400;
    color: var(--wp--preset--color--black);
    margin: 0 0 20px;
    line-height: 1.2;
}

.search-page__form {
    display: flex;
    max-width: 480px;
    border: 1px solid #e4e4ea;
    border-radius: 8px;
    overflow: hidden;
    background: var(--wp--preset--color--white);
    transition: border-color .15s, box-shadow .15s;
}

.search-page__form:focus-within {
    border-color: var(--wp--preset--color--purple-500);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .12);
}

.search-page__input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 300;
    color: var(--wp--preset--color--black);
    background: transparent;
}

.search-page__input:focus {
    outline: none;
}

.search-page__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    border: none;
    background: var(--wp--preset--color--yellow);
    color: var(--wp--preset--color--black);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
}

.search-page__submit:hover {
    background: #f0d800;
}

/* ── Topic chips ──────────────────────────────────────────────── */

.search-page__topics {
    margin-top: 20px;
}

.search-page__topics-label {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: var(--wp--preset--color--neutral-300);
    margin-bottom: 10px;
}

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

/* Same shape/sizing as the mega menu's .mega-chip (assets/css/style.css),
   colors adapted for a light page instead of the dark mega menu panel. */
.search-page__topic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    background-color: transparent;
    border: 1px solid var(--wp--preset--color--neutral-200, #c5c5cd);
    border-radius: 4px;
    color: var(--wp--preset--color--black);
    font-size: 12px;
    font-family: inherit;
    line-height: 1.6;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .15s, background-color .15s, color .15s;
}

.search-page__topic:hover {
    border-color: var(--wp--preset--color--purple-500);
    color: var(--wp--preset--color--purple-500);
}

.search-page__topic--active {
    background-color: var(--wp--preset--color--purple-500);
    border-color: var(--wp--preset--color--purple-500);
    color: var(--wp--preset--color--white);
    font-weight: 700;
}

.search-page__topic--active:hover {
    background-color: #350a72;
    border-color: #350a72;
    color: var(--wp--preset--color--white);
}

/* ── AJAX loading state ──────────────────────────────────────────── */

.search-page__results-wrap {
    position: relative;
}

.search-page.is-searching .js-search-results {
    opacity: .5;
    pointer-events: none;
    transition: opacity .15s ease;
}

.search-page__loader {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 5;
    align-items: flex-start;
    justify-content: center;
    padding-top: 96px;
}

.search-page.is-searching .search-page__loader {
    display: flex;
}

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

.search-page__spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--wp--preset--color--purple-100, #ebe8f4);
    border-top-color: var(--wp--preset--color--purple-500, #7c3aed);
    border-radius: 50%;
    animation: search-page-spin .75s linear infinite;
}

html[data-theme="dark"] .search-page__spinner {
    border-color: rgba(255, 255, 255, .15);
    border-top-color: var(--wp--preset--color--yellow, #FFE500);
}

/* ── Corrected-query / count strip ─────────────────────────────── */

.search-page__corrected {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin: 0 0 16px;
    padding: 12px 16px;
    background: #faf8ff;
    border: 1px solid var(--wp--preset--color--purple-100, #e0d7f6);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 300;
    color: var(--wp--preset--color--black);
    line-height: 1.5;
}

.search-page__corrected strong {
    font-weight: 700;
    color: var(--wp--preset--color--purple-500);
}

.search-page__corrected a {
    color: var(--wp--preset--color--purple-500);
    text-decoration: underline;
}

.search-page__count {
    font-size: 14px;
    font-weight: 300;
    color: var(--wp--preset--color--neutral-300);
    margin: 0 0 32px;
}

.search-page__empty {
    padding: 24px 0 40px;
    font-size: 16px;
    font-weight: 300;
    color: var(--wp--preset--color--dark);
    line-height: 1.6;
}

.search-page__empty a {
    color: var(--wp--preset--color--purple-500);
    text-decoration: underline;
}

/* ── Group section ──────────────────────────────────────────────── */

.search-group {
    margin-bottom: 48px;
    padding-bottom: 48px;
    border-bottom: 1px solid #e4e4ea;
    scroll-margin-top: calc(var(--nav-height, 70px) + 24px);
}

.search-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.search-group__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.search-group__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    background: rgba(139, 92, 246, .1);
    color: var(--wp--preset--color--purple-500);
}

.search-group__icon svg {
    width: 16px;
    height: auto;
}

.search-group__title {
    font-size: 20px;
    font-weight: 700;
    color: var(--wp--preset--color--black);
    margin: 0;
}

.search-group__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #f0f0f4;
    color: var(--wp--preset--color--neutral-300);
    font-size: 12px;
    font-weight: 700;
}

/* ── Result cards ───────────────────────────────────────────────── */

.search-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-item {
    position: relative;
    padding: 20px 24px;
    border: 1px solid #e4e4ea;
    border-radius: 12px;
    background: var(--wp--preset--color--white);
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.search-item:hover {
    border-color: var(--wp--preset--color--purple-100, #e0d7f6);
    background: #faf8ff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .05);
}

.search-item--hidden {
    display: none;
}

.search-item__title {
    display: block;
    max-width: 800px;
    font-size: 18px;
    font-weight: 400;
    color: var(--wp--preset--color--black);
    text-decoration: none;
    margin-bottom: 6px;
    overflow-wrap: break-word;
    word-break: break-word;
}

a.search-item__title:hover {
    text-decoration: underline;
    color: var(--wp--preset--color--purple-500);
}

.search-item__title--plain {
    cursor: default;
}

.search-item .ac-badge--promo {
    position: absolute;
    top: 20px;
    right: 24px;
    margin-bottom: 0;
}

/* Keep long titles from running under the corner badge. */
.search-item:has(.ac-badge--promo) .search-item__title {
    padding-right: 100px;
}

.search-item__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.search-item__category {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(139, 92, 246, .08);
    color: var(--wp--preset--color--purple-500);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
}

.search-item__excerpt {
    max-width: 800px;
    font-size: 14px;
    font-weight: 300;
    color: var(--wp--preset--color--neutral-300);
    line-height: 1.6;
    margin: 0 0 8px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.search-item__meta {
    font-size: 12px;
    font-weight: 400;
    color: #a0a0ab;
}

.search-item strong {
    font-weight: 700;
    color: var(--wp--preset--color--purple-500);
    background: rgba(139, 92, 246, .08);
    border-radius: 2px;
}

/* ── Matched categories (e.g. Szkolenie matched by product_cat name) ── */

.search-group__terms {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e4e4ea;
}

.search-group__terms-label {
    font-size: 12px;
    font-weight: 400;
    color: var(--wp--preset--color--neutral-300);
}

.search-group__term {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(139, 92, 246, .08);
    color: var(--wp--preset--color--purple-500);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: background-color .15s, color .15s;
}

a.search-group__term:hover {
    background: var(--wp--preset--color--purple-500);
    color: var(--wp--preset--color--white);
}

.search-group__term--plain {
    cursor: default;
}

/* ── "See more" button ─────────────────────────────────────────── */

.search-group__more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.search-group__more {
    padding: 12px 32px;
}

@media (max-width: 640px) {
    .search-page__title {
        font-size: 24px;
    }

    .search-page__form {
        max-width: 100%;
    }

    .search-item {
        padding: 16px;
    }

    .search-item .ac-badge--promo {
        top: 16px;
        right: 16px;
    }

    .search-item:has(.ac-badge--promo) .search-item__title {
        padding-right: 84px;
    }
}

/* ── Dark mode ──────────────────────────────────────────────────────────── */

html[data-theme="dark"] .search-page {
    background-color: var(--wp--preset--color--black, #1A1A25);
}

html[data-theme="dark"] .search-page__breadcrumb .hl-bc-text,
html[data-theme="dark"] .search-page__breadcrumb .hl-bc-home {
    color: rgba(255, 255, 255, .65);
}

html[data-theme="dark"] .search-page__breadcrumb .hl-bc-item--page {
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .search-page__head {
    background: var(--wp--preset--color--black, #1A1A25);
}

html[data-theme="dark"] .search-page__head.is-stuck {
    border-bottom-color: rgba(255, 255, 255, .12);
}

html[data-theme="dark"] .search-page__title {
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .search-page__form {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(255, 255, 255, .2);
}

html[data-theme="dark"] .search-page__form:focus-within {
    border-color: var(--wp--preset--color--yellow, #FFE500);
    box-shadow: 0 0 0 3px rgba(255, 229, 0, .12);
}

html[data-theme="dark"] .search-page__input {
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .search-page__input::placeholder {
    color: rgba(255, 255, 255, .5);
}

html[data-theme="dark"] .search-page__corrected {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(255, 255, 255, .15);
    color: rgba(255, 255, 255, .8);
}

html[data-theme="dark"] .search-page__corrected strong {
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .search-page__corrected a {
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .search-page__count,
html[data-theme="dark"] .search-page__empty {
    color: rgba(255, 255, 255, .65);
}

html[data-theme="dark"] .search-page__topics-label {
    color: rgba(255, 255, 255, .5);
}

html[data-theme="dark"] .search-page__topic {
    background-color: rgba(255, 255, 255, .1);
    border-color: var(--wp--preset--color--neutral-300, #747481);
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .search-page__topic:hover {
    border-color: var(--wp--preset--color--yellow, #FFE500);
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .search-page__topic--active {
    background-color: var(--wp--preset--color--yellow, #FFE500);
    border-color: var(--wp--preset--color--yellow, #FFE500);
    color: var(--wp--preset--color--black, #1A1A25);
}

html[data-theme="dark"] .search-page__topic--active:hover {
    background-color: #e6ce00;
    border-color: #e6ce00;
    color: var(--wp--preset--color--black, #1A1A25);
}

html[data-theme="dark"] .search-page__empty a {
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .search-group {
    border-bottom-color: rgba(255, 255, 255, .12);
}

html[data-theme="dark"] .search-group__icon {
    background: rgba(255, 255, 255, .08);
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .search-group__title {
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .search-group__count {
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .65);
}

html[data-theme="dark"] .search-item {
    background: rgba(255, 255, 255, .03);
    border-color: rgba(255, 255, 255, .12);
}

html[data-theme="dark"] .search-item:hover {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .25);
    box-shadow: none;
}

html[data-theme="dark"] .search-item__title {
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] a.search-item__title:hover {
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .search-item__category {
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .8);
}

html[data-theme="dark"] .search-item__excerpt {
    color: rgba(255, 255, 255, .65);
}

html[data-theme="dark"] .search-item__meta {
    color: rgba(255, 255, 255, .5);
}

html[data-theme="dark"] .search-item strong {
    color: var(--wp--preset--color--yellow, #FFE500);
    background: rgba(255, 229, 0, .12);
}

html[data-theme="dark"] .search-group__terms {
    border-top-color: rgba(255, 255, 255, .12);
}

html[data-theme="dark"] .search-group__terms-label {
    color: rgba(255, 255, 255, .5);
}

html[data-theme="dark"] .search-group__term {
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .8);
}

html[data-theme="dark"] a.search-group__term:hover {
    background: var(--wp--preset--color--yellow, #FFE500);
    color: var(--wp--preset--color--black, #1A1A25);
}

html[data-theme="dark"] .search-group__more.btn-primary {
    border-color: var(--wp--preset--color--white);
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .search-group__more.btn-primary:hover,
html[data-theme="dark"] .search-group__more.btn-primary:active {
    background: var(--wp--preset--color--white);
    color: var(--wp--preset--color--black, #1A1A25);
}
