/* ==========================================================================
   h-omeyocan-cms - Pagefind Search Customization
   Custom styling to match site design
   ========================================================================== */

/* --- Pagefind CSS Variables --- */
.pagefind-ui
{
    --pagefind-ui-scale: 1;
    --pagefind-ui-primary: #2585BC;
    --pagefind-ui-text: #2c3e50;
    --pagefind-ui-background: #ffffff;
    --pagefind-ui-border: #e0e0e0;
    --pagefind-ui-border-width: 1px;
    --pagefind-ui-border-radius: 4px;
    --pagefind-ui-font: 'Roboto Condensed', sans-serif;
}

/* --- Search Form Container --- */
.pagefind-ui__form
{
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

/* --- Hide default search icon --- */
.pagefind-ui__search-input::before,
.pagefind-ui__drawer::before,
.pagefind-ui__form::before
{
    display: none !important;
    content: none !important;
}

/* --- Fix drawer to not push button --- */
.pagefind-ui__drawer
{
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: 100% !important;
}

/* Remove the wrapper styling that adds the search icon */
.pagefind-ui__form
{
    background: none !important;
    border: none !important;
}

/* --- Search Input Customization --- */
.pagefind-ui__search-input
{
    padding: 0.5rem 1rem !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    font-family: 'Roboto Condensed', sans-serif !important;
    font-size: 0.9rem !important;
    width: 250px !important;
    height: 38px !important;
    line-height: normal !important;
    transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
    background-image: none !important;
    background-color: white !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

/* Make placeholder text more visible */
.pagefind-ui__search-input::placeholder
{
    color: #666666 !important;
    font-weight: 400 !important;
    opacity: 1 !important;
}

.pagefind-ui__search-input:focus
{
    outline: none !important;
    border-color: #2585BC !important;
    box-shadow: 0 0 0 3px rgba(37, 133, 188, 0.1) !important;
}

/* Hide placeholder when search bar is focused */
.pagefind-ui__search-input:focus::placeholder
{
    opacity: 0 !important;
}

/* --- Search Button - Style the clear button as submit --- */
.pagefind-ui__search-clear
{
    background-color: #2585BC !important;
    margin-top: -7px !important;
    color: white !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    width: 38px !important;
    height: 38px !important;
    position: relative !important;
}

/* Replace X with trash icon using CSS */
.pagefind-ui__search-clear::before
{
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 16 16'%3E%3Cpath fill='%23ffffff' fill-rule='evenodd' d='M3.47 3.47a.75.75 0 0 1 1.06 0L8 6.94l3.47-3.47a.75.75 0 1 1 1.06 1.06L9.06 8l3.47 3.47a.75.75 0 1 1-1.06 1.06L8 9.06l-3.47 3.47a.75.75 0 0 1-1.06-1.06L6.94 8 3.47 4.53a.75.75 0 0 1 0-1.06' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* Hide the default X text */
.pagefind-ui__search-clear::after
{
    display: none !important;
}

.pagefind-ui__search-clear:hover
{
    background-color: #1e6a99 !important;
}

/* Hide button when suppressed, but keep space to prevent layout shift */
.pagefind-ui__search-clear.pagefind-ui__suppressed
{
    opacity: 0 !important;
    pointer-events: none !important;
    transform: none !important;
}

/* --- Results Dropdown --- */
.pagefind-ui__results-area
{
    position: absolute !important;
    z-index: 100 !important;
    left: -100% !important;
    width: 600px !important;
    background: white !important;
}

.pagefind-ui__results
{
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    background: white !important;
    max-height: 500px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.pagefind-ui__result
{
    padding: 1rem !important;
    border-bottom: 1px solid #e0e0e0 !important;
    list-style: none !important;
}

.pagefind-ui__result:last-child
{
    border-bottom: none !important;
}

.pagefind-ui__result-link
{
    display: flex !important;
    gap: 1rem !important;
    text-decoration: none !important;
    color: inherit !important;
    align-items: flex-start !important;
}

.pagefind-ui__result:hover
{
    background-color: rgba(37, 133, 188, 0.05) !important;
}

/* --- Result Thumbnail --- */
.pagefind-ui__result-image
{
    flex-shrink: 0 !important;
    width: 120px !important;
    height: 80px !important;
    overflow: hidden !important;
    border-radius: 4px !important;
    background-color: #f5f5f5 !important;
}

.pagefind-ui__result-image img
{
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

/* --- Result Text Content --- */
.pagefind-ui__result-inner
{
    flex: 1 !important;
    min-width: 0 !important;
}

.pagefind-ui__result-title
{
    color: #2585BC !important;
    font-weight: 600 !important;
    font-size: 1rem !important;
    margin-bottom: 0.5rem !important;
    line-height: 1.4 !important;
}

.pagefind-ui__result-excerpt
{
    color: #2c3e50 !important;
    font-size: 0.9rem !important;
    line-height: 1.6 !important;
    margin: 0 !important;
}

.pagefind-ui__result-excerpt mark
{
    background-color: #fff59d !important;
    color: #000 !important;
    padding: 0.1em 0.2em !important;
    border-radius: 2px !important;
    font-weight: 600 !important;
}

/* --- Message Styling --- */
.pagefind-ui__message
{
    padding: 0.5rem 1rem !important;
    text-align: center !important;
    color: #666 !important;
    font-size: 0.9rem !important;
    background: white !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
}

/* --- Load More Button --- */
.pagefind-ui__button
{
    margin: 0 !important;
    padding: 0.75rem 1.5rem !important;
    background: white !important;
    color: #2585BC !important;
    border: 1px solid #e0e0e0 !important;
    border-top: none !important;
    border-radius: 0 0 4px 4px !important;
    font-family: 'Roboto Condensed', sans-serif !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, color 0.2s ease !important;
    width: 100% !important;
    text-align: center !important;
}

.pagefind-ui__button:hover
{
    background-color: rgba(37, 133, 188, 0.05) !important;
    color: #1e6a99 !important;
}

/* --- Hide Filters --- */
.pagefind-ui__filter-panel,
.pagefind-ui__filter-block
{
    display: none !important;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px)
{
    .pagefind-ui__search-input
{
        width: 180px !important;
    }

    .pagefind-ui__results-area
{
        width: 500px !important;
    }
}

@media (max-width: 480px)
{
    .pagefind-ui__form
    {
        flex-direction: row;
        align-items: center;
        gap: 0 !important;
    }

    .pagefind-ui__search-input
    {
        flex: 1 !important;
        width: 100% !important;
        border-radius: 4px 0 0 4px !important;
        height: calc(38px * 0.75) !important;
    }

    .pagefind-ui__search-clear
    {
        border-radius: 0 4px 4px 0 !important;
        margin-left: -1px !important;
        height: calc(38px * 0.75) !important;
        width: calc(38px * 0.75) !important;
    }

    .pagefind-ui__results-area
    {
        position: fixed !important;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        max-height: calc(100vh - 120px) !important;
        border-radius: 0 !important;
    }
}
