/* ============================================
   SMART SEARCH BAR - CSS (Clean Spanning & Card Vibe)
   ============================================ */

.search-filter-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 1.5rem;
    margin-bottom: 3.5rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1.5rem;
    height: 60px;
    position: relative;
    /* transition: none; - Removed for instant snap */
}

.course-search-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    /* THE ONLY REAL WAY TO CENTER */
    background: linear-gradient(135deg, var(--primary-50) 0%, var(--white) 100%);
    border: 1px solid rgba(40, 150, 205, 0.1);
    border-radius: 50%;
    padding: 0;
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(40, 150, 205, 0.08);
    cursor: pointer;
    position: relative;
    z-index: 10;
}

.course-search-bar input {
    position: absolute;
    /* Take out of flex flow to not push icon */
    width: 0;
    opacity: 0;
    pointer-events: none;
    border: none;
    outline: none;
}

.search-filter-wrapper.is-expanded .course-search-bar {
    flex: 1;
    max-width: 800px;
    width: auto;
    padding: 0 1.5rem;
    justify-content: flex-start;
    cursor: text;
    background: var(--white);
    border-color: var(--primary-200);
    border-radius: 50px;
}

.search-filter-wrapper.is-expanded .course-search-bar input {
    position: relative;
    /* Put back in flex flow */
    width: 100%;
    opacity: 1;
    display: block;
    pointer-events: auto;
}

.course-search-bar:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(40, 150, 205, 0.12);
}

/* Spanning block merged above */

.search-filter-wrapper .course-filter-tabs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    opacity: 1;
    visibility: visible;
    margin-bottom: 0 !important;
}

.search-filter-wrapper.is-expanded .course-filter-tabs {
    width: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    margin: 0;
    gap: 0;
}

/* Desktop Visibility Logic */
.filter-tab-all {
    display: none !important;
}

.filter-clear {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: rgba(40, 150, 205, 0.05);
    color: var(--primary-600);
    border: 1px dashed rgba(40, 150, 205, 0.3);
    transition: all 0.3s ease;
    font-weight: 600;
    margin-left: 0.5rem;
    padding: 0.6rem 1.2rem;
    /* Added padding for better alignment */
}

.filter-clear:hover {
    background: #e0f2fe;
    color: #2896cd;
    border-color: #2896cd;
    transform: translateY(-2px);
}

.filter-clear i {
    font-size: 0.85rem;
}

@media (max-width: 1200px) {
    .search-filter-wrapper {
        gap: 1.5rem;
    }
}

@media (max-width: 992px) {
    .search-filter-wrapper {
        flex-wrap: nowrap;
        justify-content: center;
        gap: 0.75rem;
        /* Tighter gap for tablet to prevent overflow */
        padding: 0 1rem;
        height: auto;
        min-height: 60px;
    }

    .search-filter-wrapper .course-filter-tabs {
        flex-wrap: nowrap;
        /* Force one line */
        overflow-x: auto;
        /* Allow horizontal swipe if strictly needed */
        scrollbar-width: none;
        /* Hide scrollbar Firefox */
        -ms-overflow-style: none;
        /* Hide scrollbar IE/Edge */
        padding: 0.5rem 0;
    }

    .search-filter-wrapper .course-filter-tabs::-webkit-scrollbar {
        display: none;
        /* Hide scrollbar Chrome/Safari */
    }
}

@media (max-width: 576px) {

    /* MOBILE POLICY: NO SEARCH */
    .course-search-bar {
        display: none !important;
    }

    .search-filter-wrapper {
        flex-direction: column;
        /* Allow stack on mobile for tabs only */
        height: auto;
        gap: 1rem;
    }

    .search-filter-wrapper .course-filter-tabs {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        /* Let tabs wrap on mobile */
    }
}

.course-search-bar i.fa-search {
    color: var(--primary-500);
    font-size: 1.15rem;
    margin: 0 !important;
    /* Force center in circle */
}

.search-filter-wrapper.is-expanded .course-search-bar i.fa-search {
    margin: 0 1.25rem 0 0 !important;
    /* Restore right margin when pill */
}

.course-search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    background: transparent;
    color: var(--gray-900);
    font-weight: 500;
    width: 100%;
}

.course-search-bar input::placeholder {
    color: #94a3b8;
}

.search-clear {
    display: none;
    /* Hidden unless there is content or expanded */
    cursor: pointer;
    color: #94a3b8;
    padding: 0.5rem;
    transition: all 0.2s;
    font-size: 1.1rem;
    line-height: 1;
}

.search-filter-wrapper.is-expanded .search-clear {
    display: block !important;
    /* Force visible in expanded state */
}

.search-clear:hover {
    color: var(--primary-500);
    transform: scale(1.1);
}

.search-results-count {
    text-align: center;
    font-size: 0.95rem;
    color: var(--primary-500);
    margin-bottom: 2rem;
    font-weight: 700;
    margin-top: -1.5rem;
    /* Pull up closer to bars */
}

/* Hide cards that don't match */
.course-card-full.search-hidden {
    display: none !important;
}

/* Elastic search state: eliminates bottom gap */
.courses-page.search-active {
    padding-bottom: 0 !important;
}

.courses-page.search-active .course-category {
    margin-bottom: 0 !important;
}

.courses-page.search-active .courses-list {
    padding-bottom: 1rem !important;
}