/* Header Search Styles */

/* Mobile/PC Utility Classes */
@media (min-width: 771px) {
    .sp-only { display: none !important; }
}
@media (max-width: 770px) {
    .pc-only { display: none !important; }
}

/* Search Container for header.php */
.header_search_container {
    position: absolute;
    top: 50%;
    right: 60px; /* Beside burger menu (56px width) */
    transform: translateY(-50%);
    z-index: 10;
}

/* Desktop Search Form (header.php subpages) — always visible, pill style */
.header-desktop-search {
    display: flex;
    align-items: center;
    margin-right: 12px;
}

.header-desktop-search form {
    display: flex;
    position: relative;
    width: 240px;
}

.header-desktop-search .search-field {
    flex-grow: 1;
    padding: 8px 38px 8px 16px;
    background: #fcfaf8;
    border: 1px solid #eee;
    border-radius: 30px;
    font-size: 13px;
    outline: none;
    transition: opacity 0.2s;
    width: 100%;
    box-sizing: border-box;
    color: #333;
}

.header-desktop-search .search-field:focus {
    background: #fff;
    box-shadow: 0 0 5px rgba(0,0,0,0.05);
}

.header-desktop-search .search-submit {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-desktop-search .search-submit svg {
    width: 18px;
    height: 18px;
    fill: #999;
}

/* Search Container for front-page.php */
#nav_area .nav_toggle_button .search_toggle_holder {
    position: absolute !important;
    top: 50% !important;
    right: 50px !important; /* Move it between the pink button and the burger menu */
    transform: translateY(-50%) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    cursor: pointer !important;
    z-index: 99 !important;
    width: 55px !important;
    margin: 0 !important;
}

#nav_area .nav_toggle_button .toggle_holder:not(.search_toggle_holder) {
    right: 0px !important;
}

.search_button {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #d7a766;
    transition: 0.3s;
}

.search_button svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
}

.search_button span, 
.search_toggle_holder small {
    font-size: 11px;
    margin-top: -5px;
    font-weight: bold;
    color: #333;
}

/* Specific for front-page.php coloring */
.nav_toggle_button .search_button {
    color: #FC7EA2;
}

/* Toggleable Search Field */
#header-search-bar {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: auto;
    background: #fff;
    padding: 15px 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    z-index: 999;
    display: none !important;
    box-sizing: border-box;
    border-radius: 0 0 10px 10px; /* Slight round at bottom of container */
}

#header-search-bar.active {
    display: block !important;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#header-search-bar form {
    display: flex;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

#header-search-bar input[type="text"],
#header-search-bar .search-field {
    flex-grow: 1;
    padding: 12px 45px 12px 25px; /* Extra padding on right for icon */
    background: #f8f8f8;
    border: 1.5px solid #e8e0d8;
    border-radius: 30px; /* Pill shape */
    font-size: 14px;
    transition: 0.3s;
    outline: none;
}

#header-search-bar input[type="text"]:focus,
#header-search-bar .search-field:focus {
    border-color: #d7a766;
    background: #fff;
}

/* Redesign Submit Button as Icon */
#header-search-bar input[type="submit"],
#header-search-bar .search-submit {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 35px;
    height: 35px;
    background: transparent url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>') center no-repeat;
    background-size: 20px;
    color: transparent;
    border: none;
    cursor: pointer;
    font-size: 0; /* Hide text */
}

#header-search-bar input[type="submit"]:hover,
#header-search-bar .search-submit:hover {
    filter: brightness(0.8);
}

/* Header Overlap Prevention (Mobile) */
@media (max-width: 770px) {
    .nav_toggle_button {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding-right: 110px !important; /* Space for search (55px) + burger (55px) */
        min-height: 80px !important;
    }

    .main_logo {
        flex: 0 1 auto !important;
        max-width: 35% !important;
    }

    .language-switcher {
        display: none;
        flex: 0 1 auto !important;
        margin-left: auto !important;
        margin-right: 15px !important;
        font-size: 11px !important;
        gap: 5px !important;
        white-space: nowrap !important;
        align-items: center !important;
    }

    .language-switcher img {
        width: 16px !important;
        height: auto !important;
    }

    .beside_header_nav {
        position: static !important; /* Move into flex flow */
        transform: none !important;
        flex: 0 0 auto !important;
        margin-right: 5px !important;
    }

    .beside_header_nav a {
        width: auto !important;
        min-width: 100px !important;
        padding: 10px 12px !important;
        font-size: 13px !important;
        border-radius: 20px !important;
        text-align: center !important;
    }

    /* Fixed absolute icons at the very right */
    #nav_area .nav_toggle_button .search_toggle_holder {
        position: absolute !important;
        right: 55px !important;
        left: auto !important;
        margin: 0 !important;
    }

    #nav_area .nav_toggle_button .toggle_holder:not(.search_toggle_holder) {
        position: absolute !important;
        right: 0px !important;
        left: auto !important;
        margin: 0 !important;
    }
}

/* Scoped Styles for Subpages Mobile Search Bar */
#header #header-search-bar {
    background: #fff;
    padding: 15px 0; /* Remove horizontal padding here */
    border-top: 1px solid #f0f0f0;
    left: 50% !important;
    right: auto !important;
    width: 100vw !important;
    margin-left: -50vw !important;
    box-sizing: border-box !important;
}

#header #header-search-bar form {
    padding: 0 15px; /* Add horizontal padding to form instead */
    max-width: 100%; /* Ensure it's not restricted on mobile */
    box-sizing: border-box !important;
}

#header #header-search-bar .search-field {
    background: #fcfaf8;
    border: 1.5px solid #e8e0d8;
    padding: 10px 45px 10px 20px;
    font-size: 14px;
}

#header #header-search-bar .search-submit svg {
    fill: #999;
}
