/* Global Search Plugin Styles */

.global-search-container {
    position: relative;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.global-search-form {
    position: relative;
}

.global-search-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    background-color: #fff;
    border-radius: 999px;
    padding: 4px 6px;
    box-shadow: 0 8px 40px 0 rgba(30, 100, 255, 0.18);
    transition: all 0.3s ease;
}

.global-search-wrapper:focus-within {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
    background-color: #ffffff;
}

.global-search-input {
    flex: 1;
    border: none !important;
    background: transparent;
    outline: none;
    background: transparent !important;
    font-size: 16px;
    color: var(--text-primary) !important;
    padding: 10px 48px 10px 0;
    border-radius: 999px;
    box-shadow: none;
    margin: 0;
    order: 1;
    font-family: 'Noto Sans HK', sans-serif !important;
    font-weight: 500 !important;
}

.global-search-input::placeholder {
    color: #B2BAC8;
    font-size: 16px !important;
    font-weight: 500 !important;
    font-family: 'Noto Sans HK', sans-serif !important;
    opacity: 1 !important;
}

.global-search-dropdowns {
    display: flex;
    align-items: center;
    margin: 0 12px 0 0;
    order: 0;
}

.global-search-categories-dropdown {
    position: relative;
    order: 0;
}

.global-search-dropdown-toggle {
    background: none !important;
    box-shadow: none !important;
    color: #B2BAC8;
    border: none;
    font-weight: 600;
    font-size: 16px !important;
    padding: 8px 22px 8px 18px;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s, color 0.2s;
    outline: none;
    margin-right: 0;
}

.global-search-dropdown-toggle:hover,
.global-search-dropdown-toggle:active,
.global-search-dropdown-toggle:focus {
    color: #B2BAC8 !important;
    background: none !important;
    box-shadow: none !important;
}

.global-search-dropdown-toggle svg {
    margin-left: 8px;
}

.global-search-dropdown-content {
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #fff;
    min-width: 180px;
    box-shadow: 0 8px 32px 0 rgba(30, 100, 255, 0.13) !important;
    z-index: 1000;
    border-radius: 10px;
    margin-top: 10px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.global-search-categories-dropdown.active .global-search-dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.global-search-dropdown-content ul {
    list-style: none;
    padding: 10px 0;
    margin: 0;
}

.global-search-dropdown-content li {
    padding: 0;
    margin: 0;
}

.global-search-dropdown-content label {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 16px;
    color: var(--text-primary) !important;
    font-family: 'Noto Sans HK', sans-serif !important;
}

.global-search-dropdown-content label:hover {
    background-color: #f5f5f5;
}

.global-search-dropdown-content input[type="radio"] {
    margin-right: 10px;
}

.global-search-submit {
    background-color: #3174cc;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin: 0 0 0 8px;
    padding: 0;
    order: 2;
}

.global-search-submit:hover {
    background-color: #2760ab;
}

.global-search-submit svg {
    color: #fff;
    width: 18px;
    height: 18px;
}

/* Tags dropdown */
.global-search-tags-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin-top: 5px;
    padding: 15px;
    z-index: 999;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.global-search-input:focus ~ .global-search-tags-dropdown,
.global-search-tags-dropdown:hover {
    display: block;
}

.global-search-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.global-search-tag-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #eef5ff;
    color: #3174cc;
    font-size: 16px !important;
    font-weight: 500 !important;
    font-family: 'Noto Sans HK', sans-serif !important;
}

.global-search-tag-item:hover {
    background-color: #3174cc;
    color: #fff;
}

.global-search-tag-item .tag-name {
    font-size: 16px;
    line-height: 24px;
}

/* New Dropdown Styles - Modern Category Dropdown */
.gsp-keywords-dropdown-wrapper {
    position: relative;
    display: inline-block;
    margin-right: 12px;
    vertical-align: middle;
}

.gsp-keywords-dropdown-toggle {
    background: none !important;
    box-shadow: none !important;
    color: #B2BAC8;
    border: none;
    font-family: 'Noto Sans HK', sans-serif !important;
    font-weight: 500 !important;
    font-size: 16px !important;
    padding: 8px 22px 8px 18px;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s, color 0.2s;
    outline: none;
    margin-right: 0;
    line-height: 24px;
}

.gsp-keywords-dropdown-toggle:hover,
.gsp-keywords-dropdown-toggle:active,
.gsp-keywords-dropdown-toggle:focus {
    color: #B2BAC8 !important;
    background: none !important;
    box-shadow: none !important;
}

.gsp-keywords-dropdown-toggle svg {
    margin-left: 8px;
}

.gsp-keywords-dropdown-menu {
    min-width: 140px;
    width: auto;
    display: none;
    position: absolute;
    left: 0;
    top: 110%;
    background: #fff;
    box-shadow: 0 8px 32px 0 rgba(30, 100, 255, 0.13) !important;
    border-radius: 16px;
    z-index: 100;
    margin-top: 6px;
}

.gsp-keywords-dropdown-menu.open {
    display: block;
}

.gsp-keywords-dropdown-item {
    padding: 12px 24px;
    font-size: 16px;
    color: var(--text-primary) !important;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 24px !important;
    text-align: left;
    width: 100%;
    transition: background 0.18s, color 0.18s;
    font-family: 'Noto Sans HK', sans-serif !important;
}

.gsp-keywords-dropdown-item:hover {
    background: none;
    color: #3174cc;
}

.gsp-keywords-dropdown-item-clear {
    color: #222;
    font-weight: 500;
}

.gsp-keywords-dropdown-item:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.gsp-keywords-dropdown-item:last-child {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Fix for dropdown spacing issues on medium screens */
@media (max-width: 922px) {
    .gsp-keywords-dropdown-item {
        padding: 8px 16px;
        font-size: 16px;
        line-height: 24px !important;
    }
    
    .global-search-tags-dropdown {
        max-height: 250px;
    }
    
    .global-search-tag-item {
        padding: 6px 12px;
        margin-bottom: 0;
        height: auto;
        min-height: unset;
        box-sizing: border-box;
        font-size: 16px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        max-height: 32px;
        line-height: 24px;
    }
    
    .global-search-tag-item .tag-name {
        font-size: 16px;
        line-height: 20px;
        max-height: 1.2em;
        display: inline-block;
        vertical-align: middle;
    }
    
    .global-search-tags-list {
        gap: 8px;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    #ast-mobile-header {
        position: fixed;
        top: 0;
        width: 100%;
        z-index: 1002; /* Increased to ensure it's above search bar */
        height: 60px;
        overflow: visible; /* Ensure no overflow hides the burger menu */
    }
    
    .global-search-container.mobile-view {
        width: auto;
    }
    
    .global-search-container.mobile-view .global-search-wrapper {
        padding: 0;
        background-color: transparent;
        box-shadow: none;
    }
    
    .global-search-container.mobile-expanded .global-search-form {
        width: 100% !important;
    }
    
    .global-search-container.mobile-view .global-search-input,
    .global-search-container.mobile-view .global-search-dropdowns {
        display: none;
    }
    
    .global-search-container.mobile-view .global-search-submit {
        width: 32px;
        height: 32px;
        background-color: #3174cc;
    }
    
    .global-search-container.mobile-view .global-search-submit svg {
        width: 24px;
        height: 24px;
    }
    
    /* Sliding search bar styles */
    .global-search-container.mobile-sliding {
        position: fixed;
        top: var(--navbar-height, 60px);
        left: 0;
        width: 100%;
        z-index: 1000; /* Below header */
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        padding: 12px 16px;
        box-sizing: border-box;
        transform: translateY(-100%);
        transition: transform 0.2s ease;
    }
    
    .global-search-container.mobile-sliding.below-navbar {
        top: var(--navbar-height, 60px);
        margin-top: 0;
        border-top: none;
    }
    
    .global-search-container.mobile-sliding.visible {
        transform: translateY(0);
        transition: transform 0.25s ease-out;
    }
    
    .global-search-container.mobile-sliding.visible.at-top {
        box-shadow: none;
    }
    
    .global-search-container.mobile-sliding:not(.visible) {
        transition: transform 0.15s ease-in;
    }
    
    .global-search-container.mobile-sliding .global-search-wrapper {
        background-color: #fff;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        padding: 0 6px 0 18px;
        margin: 0;
        width: 100%;
        display: flex;
        align-items: center;
        border-radius: 24px;
        height: 44px;
        position: relative;
        overflow: visible !important;
    }
    
    .global-search-container.mobile-sliding .global-search-input {
        display: block;
        color: #333;
        font-size: 16px;
        padding: 8px 0;
        width: calc(100% - 46px);
        margin-right: 6px;
    }
    
    .global-search-container.mobile-sliding .global-search-input::placeholder {
        color: #B2BAC8;
        opacity: 0.8;
    }
    
    .global-search-container.mobile-sliding .global-search-submit {
        background-color: #3174cc;
        width: 36px;
        height: 36px;
        min-width: 36px;
        margin: 0;
        position: relative;
        right: 0;
        border-radius: 50%;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
        z-index: 10;
        cursor: pointer;
    }
    
    .global-search-container.mobile-sliding .global-search-submit:hover {
        background-color: #2c69b8;
    }
    
    .global-search-container.mobile-sliding .global-search-submit svg {
        width: 24px;
        height: 24px;
        color: #fff;
    }
    
    .global-search-container.mobile-sliding .global-search-input,
    .global-search-container.mobile-sliding .global-search-submit {
        display: block;
    }
    
    .global-search-container.mobile-sliding .global-search-dropdowns {
        display: flex !important;
    }
    
    /* Expanded search overlay */
    .global-search-container.mobile-expanded {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(255, 255, 255, 0.98);
        z-index: 9999;
        padding: 20px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        overflow-y: auto;
    }
    
    .global-search-container.mobile-expanded .global-search-wrapper {
        width: 100%;
        margin-top: 100px;
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
        background-color: #f9f9f9;
        border-radius: 40px;
        padding: 2px 6px 2px 18px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .global-search-container.mobile-expanded .global-search-input {
        display: block;
        color: #333;
    }
    
    .global-search-container.mobile-expanded .global-search-input::placeholder {
        color: #8e8e8e;
    }
    
    .global-search-container.mobile-expanded .global-search-dropdowns {
        display: block;
    }
    
    .global-search-container.mobile-expanded .global-search-submit {
        display: none;
    }
    
    .global-search-container.mobile-expanded .global-search-tags-dropdown {
        width: 90%;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 5px;
        display: block !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Close icon in navbar for expanded mode */
    .global-search-container.mobile-expanded .global-search-close-btn {
        display: block;
        position: absolute;
        top: 20px;
        right: 20px;
        background: none;
        border: none;
        font-size: 28px;
        color: #333;
        cursor: pointer;
        z-index: 10000;
        padding: 10px;
        line-height: 1;
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
    }

    .global-search-container.mobile-expanded .global-search-close-btn::before {
        content: '\2715';
        font-weight: bold;
    }

    /* Fix for dropdown position when in sliding mode */
    .global-search-container.mobile-sliding .gsp-keywords-dropdown-menu {
        top: 100%;
        background-color: #fff;
        border: 1px solid rgb(255, 255, 255);
    }
    
    .global-search-container.mobile-sliding .gsp-keywords-dropdown-item {
        color: #3174cc;
    }
    
    .global-search-container.mobile-sliding .gsp-keywords-dropdown-item:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }
    
    /* Responsive styles for the dropdown */
    .gsp-keywords-dropdown-wrapper {
        margin-right: 4px;
    }
    
    .gsp-keywords-dropdown-toggle {
        font-size: 16px;
        padding: 6px 10px 6px 10px;
    }
    
    .gsp-keywords-dropdown-menu {
        min-width: 120px;
        font-size: 16px;
    }
    
    .gsp-keywords-dropdown-item {
        padding: 8px 14px;
        font-size: 16px;
    }
}

.global-search-container.mobile-sliding .global-search-tags-dropdown {
    display: none !important;
}

/* Override any hover or focus state that might show the dropdown */
.global-search-container.mobile-sliding .global-search-input:focus ~ .global-search-tags-dropdown,
.global-search-container.mobile-sliding .global-search-tags-dropdown:hover,
.global-search-container.mobile-view .global-search-tags-dropdown {
    display: none !important;
}

.gsp-keywords-dropdown-wrapper.active .gsp-keywords-dropdown-menu {
    display: block;
}

.global-search-container.mobile-expanded .gsp-keywords-dropdown-menu {
    z-index: 200;
}

/* Hide tags dropdown when category dropdown is active */
.gsp-keywords-dropdown-wrapper.active ~ * .global-search-tags-dropdown,
.global-search-wrapper:has(.gsp-keywords-dropdown-wrapper.active) ~ .global-search-tags-dropdown {
    display: none !important;
} 

.global-search-container.mobile-expanded .gsp-keywords-dropdown-toggle,
.global-search-container.mobile-expanded .global-search-dropdown-toggle {
    background: none !important;
    box-shadow: none !important;
    color: #B2BBC8 !important;
}

@media (max-width: 455px) {
    .global-search-input::placeholder {
        font-size: 16px !important;
    }
    .global-search-dropdown-toggle,
    .gsp-keywords-dropdown-toggle {
        font-size: 16px !important;
    }
}

.global-search-container.mobile-sliding .global-search-input::placeholder,
.global-search-container.mobile-expanded .global-search-input::placeholder,
.global-search-container.mobile-sliding .global-search-dropdown-toggle,
.global-search-container.mobile-expanded .global-search-dropdown-toggle,
.global-search-container.mobile-sliding .gsp-keywords-dropdown-toggle,
.global-search-container.mobile-expanded .gsp-keywords-dropdown-toggle {
    font-family: 'Noto Sans HK', sans-serif !important;
}

/* Desktop collapsed state: only show icon, hide bar */
@media (min-width: 769px) {
    .global-search-container {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        width: 100%;
        position: relative;
    }
    .global-search-wrapper {
        flex-direction: row;
        right: 0;
    }
    .global-search-toggle-btn {
        margin-left: 0;
        margin-right: 0;
        position: static;
        right: auto;
    }
    .global-search-input {
        padding-right: 16px;
        padding-left: 0;
        order: 1;
    }
    .global-search-dropdowns {
        order: 0;
    }
    .global-search-toggle-btn {
        order: 2;
    }
    .global-search-container.desktop-collapsed .global-search-wrapper {
        width: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
        min-width: 0 !important;
        pointer-events: none;
    }
    .global-search-container:not(.desktop-collapsed) .global-search-wrapper {
        width: 420px !important;
        opacity: 1 !important;
        overflow: visible !important;
        min-width: 420px !important;
        pointer-events: auto;
    }
    .global-search-toggle-btn svg,
    .global-search-submit svg {
        width: 24px !important;
        height: 24px !important;
    }
}

/* Remove debug styles and keep search icon simple and white */
.global-search-toggle-btn {
    background: #3174cc;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin: 0 0 0 8px;
    padding: 0;
    position: relative;
    z-index: 3;
    box-shadow: 0 2px 8px 0 rgba(30, 100, 255, 0.10);
}

.global-search-toggle-btn svg {
    color: #fff;
    width: 18px;
    height: 18px;
}

.global-search-toggle-btn:hover {
    background-color: #2760ab;
}

@media (max-width: 768px) {
    .global-search-toggle-btn {
        display: none !important;
    }
    .global-search-submit {
        display: flex !important;
    }
    .global-search-toggle-btn svg,
    .global-search-submit svg {
        width: 24px !important;
        height: 24px !important;
    }
}

@media (min-width: 769px) {
    .global-search-submit {
        display: none !important;
    }
    .global-search-toggle-btn {
        display: flex !important;
    }
    .global-search-container {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        position: relative;
    }
}

/* Push content down when search bar is visible */
@media (max-width: 768px) {
    
    #ast-mobile-header {
        height: 60px;
        position: fixed;
        top: 0;
        z-index: 1002; /* Ensure header is above search bar */
        overflow: visible; /* Prevent overflow from hiding burger menu */
    }
    
    .global-search-container.mobile-sliding.visible {
        position: fixed;
        top: var(--navbar-height, 60px);
        z-index: 1000; /* Below header */
        background-color: #3174cc;
    }
    
    body.global-search-active {
        padding-top: 138px !important; /* 70px (header) + 68px (search bar with padding) */
    }
    
    /* Ensure burger menu is visible and clickable */
    #ast-mobile-header .menu-toggle {
        position: relative;
        z-index: 1003; /* Above header and search bar */
        pointer-events: auto !important;
        opacity: 1 !important; /* Ensure visibility */
        display: block !important; /* Ensure it's not hidden */
    }
    
    /* Adjust header content to prevent overlap */
    #ast-mobile-header .main-header-bar-navigation {
        z-index: 1003;
    }
    body:not(.global-search-active) .global-search-container.mobile-sliding {
    transform: translateY(-100%);
    }

    body:not(.global-search-active) #ast-mobile-header {
        position: relative;
        z-index: 0;
    }

    body:not(.global-search-active) .content-container {
        margin-top: 60px; /* Adjust based on navbar height */
    }
    
}