/* =========================================
   Search Popup
========================================= */

.search-popup {
    position: fixed;
    inset: 0;
    z-index: 9999999;

    display: flex;
    justify-content: center;
    align-items: flex-start;

    padding-top: 38px;

    background: rgba(15, 30, 40, 0.45);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

.searchToggle {
    cursor: pointer;
}
a.searchToggle i {
    font-family: 'FontAwesome';
}

/* Open state */

.search-popup.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}


/* Popup box */

.search-popup-box {
    width: min(575px, calc(100% - 30px));

    background: #fff;

    border-radius: 16px;

    overflow: hidden;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.18);

    transform: translateY(-15px) scale(0.98);

    transition: transform 0.25s ease;
}


.search-popup.active .search-popup-box {
    transform: translateY(0) scale(1);
}


/* =========================================
   Header
========================================= */

.search-popup-header {
    display: flex;
    align-items: center;

    min-height: 64px;

    padding: 8px 20px;

    border-bottom: 1px solid #e5e5e5;
}


/* Input wrapper */

.search-input-wrapper {
    flex: 1;

    display: flex;
    align-items: center;

    gap: 14px;
}


.search-input-wrapper > i {
    font-size: 17px;
    color: #63717a;
}


/* Search input */

.search-input-wrapper input {
    width: 100%;

    border: 0;
    outline: 0;

    background: transparent;

    font-size: 16px;
    color: #263238;

    padding: 10px 0;
}


.search-input-wrapper input::placeholder {
    color: #7d858a;
}


/* =========================================
   Close button
========================================= */

.search-close {
    width: 34px;
    height: 34px;

    flex: 0 0 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-left: 15px;

    border: 1px solid #dce2e5;
    border-radius: 8px;

    background: #fff;

    color: #65747c;

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}


.search-close:hover {
    background: #f2f5f6;
    color: #222;
    border-color: #cbd3d7;
}


/* =========================================
   Form / combobox wiring
   ========================================= */

/* The wrapper used to be the flex row directly; it is now the <form>. */
.search-form {
    flex: 1;
    min-width: 0;
    margin: 0;
}

/* Stop the page behind the modal from scrolling. */
body.kfl-search-open {
    overflow: hidden;
}


/* =========================================
   Loading spinner
   ========================================= */

.search-spinner {
    flex: 0 0 auto;

    display: none;

    width: 16px;
    height: 16px;

    border: 2px solid #d3dbdf;
    border-top-color: #63717a;

    border-radius: 50%;

    animation: kflSearchSpin 0.7s linear infinite;
}

.search-popup.is-loading .search-spinner {
    display: block;
}

@keyframes kflSearchSpin {
    to { transform: rotate(360deg); }
}


/* =========================================
   Results area
   ========================================= */

.search-popup-results {
    min-height: 75px;

    padding: 8px 0 0;

    max-height: min(60vh, 460px);
    overflow-y: auto;

    overscroll-behavior: contain;
}

.search-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 35px;

    color: #65747c;

    font-size: 14px;

    text-align: center;
}

/* Idle / empty / error message row. */
.search-msg {
    margin: 0;

    padding: 26px 20px;

    color: #65747c;

    font-size: 14px;

    text-align: center;
}

.search-msg.is-error {
    color: #b4402f;
}


/* =========================================
   Result groups
   ========================================= */

.search-group + .search-group {
    border-top: 1px solid #eef1f2;
}

.search-group-head {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 12px 20px 6px;
}

.search-group-icon {
    color: #8b979d;

    font-size: 11px;
}

.search-group-label {
    color: #3c4b53;

    font-size: 11px;
    font-weight: 700;

    letter-spacing: 0.08em;

    text-transform: uppercase;
}

.search-group-count {
    margin-left: auto;

    color: #9aa5aa;

    font-size: 11px;
}


/* =========================================
   Result rows
   ========================================= */

.search-row,
.search-seeall {
    display: flex;
    align-items: center;
    gap: 13px;

    padding: 10px 20px;

    color: inherit;

    text-decoration: none;
}

.search-row.is-active,
.search-seeall.is-active {
    background: #f1f6f4;
}

.search-row-thumb,
.search-row-badge {
    flex: 0 0 auto;

    width: 42px;
    height: 42px;

    border-radius: 9px;
}

.search-row-thumb {
    object-fit: cover;

    background: #eef1f2;
}

.search-row-badge {
    display: flex;
    align-items: center;
    justify-content: center;

    background: #eef2f3;

    color: #6b7a82;

    font-size: 15px;
}

.search-row-body {
    display: flex;
    flex-direction: column;
    gap: 2px;

    min-width: 0;
}

.search-row-title {
    color: #1d2a31;

    font-size: 15px;
    font-weight: 600;

    line-height: 1.3;

    /* Two-line clamp keeps a long listing name from blowing up the row. */
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-row-sum {
    color: #7b878d;

    font-size: 13px;
    line-height: 1.4;

    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Footer: jump to the full results page. */
.search-seeall {
    margin-top: 6px;

    border-top: 1px solid #eef1f2;

    color: #2f6df6;

    font-size: 14px;
    font-weight: 600;

    justify-content: center;
}


/* =========================================
   Mobile
   ========================================= */

@media (max-width: 576px) {

    .search-popup {
        padding-top: 20px;
    }

    .search-popup-box {
        width: calc(100% - 20px);
        border-radius: 14px;
    }

    .search-popup-header {
        padding: 8px 15px;
    }

    .search-input-wrapper {
        gap: 10px;
    }

    .search-input-wrapper input {
        font-size: 15px;
    }

    .search-popup-results {
        max-height: 66vh;
    }

    .search-row,
    .search-seeall {
        padding: 11px 15px;
    }

    .search-row-thumb,
    .search-row-badge {
        width: 38px;
        height: 38px;
    }

}
