/* =========================================
   Universal Search Overlay
   ========================================= */

/* --- Overlay Base --- */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* --- Backdrop --- */
.search-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 20, 50, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* --- Content Panel --- */
.search-overlay__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 780px;
    margin-top: 8vh;
    padding: 0 24px 40px;
    transform: translateY(-30px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.35s ease;
}

.search-overlay.is-open .search-overlay__panel {
    transform: translateY(0);
    opacity: 1;
}

/* --- Close Button --- */
.search-overlay__close {
    position: absolute;
    top: 0;
    right: 24px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.search-overlay__close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: scale(1.08);
}

/* --- Input Area --- */
.search-overlay__input-wrap {
    margin-top: 60px;
}

.search-overlay__input-inner {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 0 20px;
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.search-overlay__input-inner:focus-within {
    border-color: rgba(0, 56, 118, 0.6);
    background: rgba(255, 255, 255, 0.10);
    box-shadow: 0 0 0 4px rgba(0, 56, 118, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.2);
}

.search-overlay__input-icon {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.3s ease;
}

.search-overlay__input-inner:focus-within .search-overlay__input-icon {
    color: rgba(255, 255, 255, 0.8);
}

.search-overlay__input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 400;
    color: #ffffff;
    padding: 18px 16px;
    caret-color: #FFDF00;
}

.search-overlay__input::placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-weight: 300;
}

/* Clear button */
.search-overlay__input-clear {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

.search-overlay__input-clear:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Hint text */
.search-overlay__hint {
    margin-top: 10px;
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
}

@media (max-width:1024px) {
    .search-overlay__hint {
        display: none !important;
    }
}

.search-overlay__hint kbd {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-family: 'Nunito Sans', 'Inter', monospace;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    color: rgba(255, 255, 255, 0.5);
}

/* --- Loading Spinner --- */
.search-overlay__loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 0;
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
}

.search-overlay__spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #FFDF00;
    border-radius: 50%;
    animation: search-spin 0.7s linear infinite;
}

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

/* --- Results Container --- */
.search-overlay__results {
    margin-top: 20px;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom scrollbar */
.search-overlay__results::-webkit-scrollbar {
    width: 5px;
}

.search-overlay__results::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}

.search-overlay__results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

.search-overlay__results::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Result Group --- */
.search-result-group {
    margin-bottom: 28px;
}

.search-result-group__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.search-result-group__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 20px;
    color: #fff;
}

/* Color-coded badges per post type */
.search-result-group__badge--page {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.search-result-group__badge--product {
    background: linear-gradient(135deg, #003876, #1A4C9E);
}

.search-result-group__badge--disease {
    background: linear-gradient(135deg, #e53e3e, #c53030);
}

.search-result-group__badge--blog {
    background: linear-gradient(135deg, #38a169, #276749);
}

.search-result-group__badge--mom {
    background: linear-gradient(135deg, #d69e2e, #b7791f);
}

.search-result-group__count {
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
}

/* --- Individual Result Card --- */
.search-result-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.04);
    text-decoration: none;
    color: #fff;
    transition: background 0.25s ease,
        border-color 0.25s ease,
        transform 0.2s ease,
        box-shadow 0.25s ease;
    margin-bottom: 6px;
}

.search-result-card:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.search-result-card:active {
    transform: translateX(2px) scale(0.99);
}

/* Thumbnail */
.search-result-card__thumb {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-result-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Placeholder icon when no thumbnail */
.search-result-card__thumb-placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* Text content */
.search-result-card__content {
    flex: 1;
    min-width: 0;
}

.search-result-card__title {
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-card__excerpt {
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Arrow indicator */
.search-result-card__arrow {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.15);
    transition: color 0.2s ease, transform 0.2s ease;
}

.search-result-card:hover .search-result-card__arrow {
    color: rgba(255, 255, 255, 0.5);
    transform: translateX(3px);
}

/* --- Empty State --- */
.search-overlay__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0;
    text-align: center;
}

.search-overlay__empty-title {
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

.search-overlay__empty-subtitle {
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.3);
    margin: 0;
}

/* --- Prompt State --- */
.search-overlay__prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 48px 0;
    text-align: center;
}

.search-overlay__prompt p {
    font-family: 'Nunito Sans', 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.3);
    margin: 0;
}

/* --- Highlight matched text --- */
.search-highlight {
    background: rgba(255, 223, 0, 0.25);
    color: #FFDF00;
    border-radius: 2px;
    padding: 0 2px;
}

/* =========================================
   Responsive — Tablet
   ========================================= */
@media (max-width: 1024px) {
    .search-overlay__panel {
        max-width: 640px;
        margin-top: 6vh;
    }

    .search-overlay__input {
        font-size: 18px;
        padding: 16px 14px;
    }
}

/* =========================================
   Responsive — Mobile
   ========================================= */
@media (max-width: 640px) {
    .search-overlay__panel {
        max-width: 100%;
        margin-top: 0;
        padding: 0 16px 24px;
    }

    .search-overlay__close {
        top: 16px;
        right: 16px;
    }

    .search-overlay__input-wrap {
        margin-top: 72px;
    }

    .search-overlay__input-inner {
        border-radius: 12px;
        padding: 0 14px;
    }

    .search-overlay__input {
        font-size: 16px;
        padding: 14px 10px;
    }

    .search-overlay__results {
        max-height: 60vh;
    }

    .search-result-card {
        padding: 12px;
        gap: 12px;
    }

    .search-result-card__thumb {
        width: 44px;
        height: 44px;
    }

    .search-result-card__title {
        font-size: 14px;
    }

    .search-result-card__excerpt {
        font-size: 12px;
        -webkit-line-clamp: 1;
    }
}

/* =========================================
   Body overflow lock when search is open
   ========================================= */
body.search-overlay-open {
    overflow: hidden;
}