/* ==========================================================================
   MNI Smart Search - Styles
   ========================================================================== */

.mni-search-wrapper {
    max-width: 700px;
    margin: 2rem auto;
    position: relative;
}

.mni-search-form {
    position: relative;
}

.mni-search-input-wrapper {
    display: flex;
    gap: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    transition: border-color 0.2s ease;
}

.mni-search-input-wrapper:focus-within {
    border-color: #2c6fbb;
}

.mni-search-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 16px;
    border: none;
    outline: none;
    background: #fff;
    font-family: inherit;
}

.mni-search-input::placeholder {
    color: #999;
}

.mni-search-submit {
    padding: 14px 24px;
    background: #2c6fbb;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease;
}

.mni-search-submit:hover {
    background: #1e5aa0;
}

.mni-search-icon {
    font-size: 18px;
}

.mni-search-text {
    display: none;
}

/* Live search results dropdown */
.mni-search-live-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
}

.mni-search-result-item {
    padding: 14px 18px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s ease;
}

.mni-search-result-item:last-child {
    border-bottom: none;
}

.mni-search-result-item:hover {
    background: #f7f9fc;
}

.mni-search-result-title {
    font-weight: 600;
    color: #2c6fbb;
    margin-bottom: 4px;
    font-size: 15px;
}

.mni-search-result-section {
    font-size: 12px;
    color: #f19301;
    font-weight: 600;
    margin-bottom: 6px;
}

.mni-search-result-excerpt {
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.mni-search-result-excerpt mark {
    background: #fff59d;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
}

.mni-search-no-results {
    padding: 24px 18px;
    text-align: center;
    color: #666;
}

.mni-search-loading {
    padding: 24px 18px;
    text-align: center;
    color: #999;
}

.mni-search-synonyms {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f0f6ff;
    border-radius: 6px;
    border-left: 3px solid #2c6fbb;
}

.mni-search-synonyms small {
    color: #555;
}

.mni-synonym-list {
    font-weight: 600;
    color: #2c6fbb;
}

/* Responsive */
@media (min-width: 600px) {
    .mni-search-text {
        display: inline;
    }
    
    .mni-search-icon {
        display: none;
    }
}

@media (max-width: 599px) {
    .mni-search-wrapper {
        margin: 1rem;
    }
    
    .mni-search-input {
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .mni-search-submit {
        padding: 14px 18px;
    }
}

/* Search results page styling */
.search-results .mni-search-wrapper {
    margin-bottom: 3rem;
}

.search-no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.search-no-results h2 {
    color: #2c6fbb;
    margin-bottom: 1rem;
}

/* Search result entries on results page */
.search-results article {
    padding: 1.5rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.search-results article:last-of-type {
    border-bottom: none;
}

.search-results .entry-title a {
    color: #2c6fbb;
    text-decoration: none;
    font-size: 1.3rem;
}

.search-results .entry-title a:hover {
    text-decoration: underline;
}

.search-results .entry-summary {
    color: #555;
    line-height: 1.6;
    margin-top: 0.5rem;
}

/* Highlight search terms in results */
.search-results mark {
    background: #fff59d;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
}

/* Highlights placed by scroll-to feature */
mark.mni-highlight {
    background: #fff59d;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
}

/* Make result items proper clickable links */
a.mni-search-result-item {
    display: block;
    text-decoration: none !important;
    color: inherit;
}

a.mni-search-result-item:hover .mni-search-result-title {
    text-decoration: underline;
}


/* ==========================================================================
   Global sticky search bar (under the site header)
   ========================================================================== */

/*
 * The bar sits immediately below the site header and sticks there as you
 * scroll. It uses a subtle background so it doesn't compete with content.
 *
 * z-index: 999 keeps it above content but below WP admin bar (z-index 99999).
 */
#mni-search-bar {
    position: sticky;
    top: 0;
    z-index: 999;
    background: #00629B;          /* MNI blue */
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    /* Shift down when WP admin bar is visible */
}

.admin-bar #mni-search-bar {
    top: 32px;                    /* WP admin bar is 32px on desktop */
}

@media screen and (max-width: 782px) {
    .admin-bar #mni-search-bar {
        top: 46px;                /* WP admin bar is 46px on mobile */
    }
}

/* Inner container: constrain width + center */
.mni-gsb-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 24px;
    /*
     * Reserve space on the right for the fixed #mni-user-menu button.
     * On desktop the button is ~120px wide (avatar + name + caret + gap).
     * On tablet (name hidden) it's ~50px. On mobile ~44px.
     * We add this via padding-right so the search input never slides under the button.
     */
    padding-right: 150px;
    position: relative;
}

@media (max-width: 900px) {
    .mni-gsb-inner {
        padding-right: 70px;   /* Tablet: name hidden, avatar only */
    }
}

@media (max-width: 480px) {
    .mni-gsb-inner {
        padding-left: 12px;
        padding-right: 60px;   /* Mobile: compact avatar button */
    }
}

/* Form layout */
.mni-gsb-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Input wrapper (icon + input + synonym hint) */
.mni-gsb-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 0 12px;
    transition: background 0.2s ease, border-color 0.2s ease;
    gap: 8px;
}

.mni-gsb-input-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.5);
}

.mni-gsb-icon {
    font-size: 14px;
    opacity: 0.7;
    flex-shrink: 0;
}

/* The search input itself */
.mni-gsb-input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: #fff !important;
    font-size: 14px !important;
    padding: 9px 0 !important;
    font-family: inherit !important;
    min-width: 0;
}

.mni-gsb-input::placeholder {
    color: rgba(255, 255, 255, 0.55) !important;
}

/* "Also: carcinoma, tumor…" hint shown on search results pages */
.mni-gsb-also {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    flex-shrink: 0;
    display: none;          /* Hidden on mobile — shown on wider screens */
}

@media (min-width: 768px) {
    .mni-gsb-also { display: block; }
}

/* Submit button */
.mni-gsb-submit {
    background: #F68D2E;
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
    font-family: inherit;
    flex-shrink: 0;
}

.mni-gsb-submit:hover {
    background: #d47e00;
}

/* Live results dropdown — positions under the bar */
.mni-gsb-live-results {
    position: absolute !important;
    left: 24px !important;
    right: 24px !important;
    top: 100% !important;
    margin-top: 4px !important;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 9999;
}

/* Synonym hint below the bar */
.mni-gsb-synonyms {
    padding: 4px 0 0 0;
    font-size: 11px;
}

.mni-gsb-synonyms small {
    color: rgba(255, 255, 255, 0.65);
}

.mni-gsb-synonyms .mni-synonym-list {
    color: rgba(255, 255, 255, 0.9);
}

/* Hide the old [mni_search] shortcode page if search is now global */
/* (You can delete the Search page in WP, or just leave it — it won't conflict) */


/* ==========================================================================
   Search results page — full-width single-column layout
   (body gets class "mni-search-results-page" from PHP)
   ========================================================================== */

body.mni-search-results-page .ast-loop-wrap,
body.mni-search-results-page .ast-row,
body.mni-search-results-page .ast-grid-common-col,
body.mni-search-results-page .ast-article-post,
body.mni-search-results-page .search article {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    float: none !important;
    clear: both !important;
    display: block !important;
}

body.mni-search-results-page article,
body.mni-search-results-page .ast-article-post {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem 2rem !important;
    margin-bottom: 1.5rem !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

body.mni-search-results-page article:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

body.mni-search-results-page .entry-title a {
    color: #2c6fbb;
    text-decoration: none;
}

body.mni-search-results-page .entry-title a:hover {
    text-decoration: underline;
}

body.mni-search-results-page mark {
    background: #fff59d;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
}

body.mni-search-results-page article .entry-meta,
body.mni-search-results-page article .post-thumbnail,
body.mni-search-results-page article .ast-author-details,
body.mni-search-results-page article .read-more,
body.mni-search-results-page article footer { display: none !important; }

body.mni-search-results-page #secondary,
body.mni-search-results-page aside.widget-area { display: none !important; }

body.mni-search-results-page #primary,
body.mni-search-results-page .content-area { width: 100% !important; max-width: 100% !important; flex: 0 0 100% !important; }

body.mni-search-results-page .site-content > .ast-container { max-width: 900px !important; margin: 2rem auto !important; }
