.tfs-search-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1040; /* Just below fixed-top navbar (1030) or above depending on design */
    pointer-events: none;
}

.tfs-search-container .container {
    position: relative;
    pointer-events: none;
}

.tfs-search-tab {
    position: fixed;
    top: 30px; /* Align with navigation options */
    left: 0;
    background: #A21418;
    color: #fff;
    padding: 10px 15px 10px 15px;
    border-radius: 0 50px 50px 0;
    cursor: pointer;
    pointer-events: auto;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease, top 1.3s ease, width 0.3s ease; /* Match navbar transition */
    z-index: 1045; /* Above navbar */
    text-decoration: none;
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    width: 50px; /* Initial width for icon only */
}

.tfs-search-tab i {
    transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease;
    display: inline-block;
    vertical-align: middle;
}

.tfs-search-tab .search-label {
    font-size: 16px;
    font-weight: 600;
    margin-left: 0;
    opacity: 0;
    max-width: 0;
    display: inline-block;
    transition: all 0.3s ease;
    vertical-align: middle;
}

/* Adjust position when navbar is scrolled */
.scrolled ~ .tfs-search-container .tfs-search-tab,
.navbar.scrolled .tfs-search-tab,
body:has(.navbar.scrolled) .tfs-search-tab {
    top: 10px;
}

/* Handle WordPress Admin Bar */
.admin-bar .tfs-search-tab {
    top: 62px; /* 30px + 32px admin bar */
}

.admin-bar body:has(.navbar.scrolled) .tfs-search-tab {
    top: 42px; /* 10px + 32px admin bar */
}

@media (max-width: 1399px) {
    .tfs-search-tab {
        left: 0;
    }
}

@media (max-width: 1199px) {
    .tfs-search-tab {
        left: 0;
    }
}

@media (max-width: 991px) {
    .tfs-search-tab {
        display: none;
    }
}

/* Mobile search styling within navbar - Only for devices smaller than 992px */
@media (max-width: 991.98px) {
    #homepage .tfs-search-form {
        /*border-bottom: 1px solid rgba(0, 0, 0, 0.1);*/
        padding-bottom: 15px;
    }

    #homepage .tfs-search-form .btn-tfs {
        padding-top: 12px;
        padding-bottom: 12px;
        min-width: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #homepage .tfs-search-form .btn-tfs i {
        font-size: 20px;
        font-weight: bold;
    }

    #homepage .tfs-search-form input[type="search"] {
        border-radius: 4px;
        height: 50px;
        font-size: 18px;
    }
}

.tfs-search-tab:hover {
    width: 170px; /* Expanded width */
    background: linear-gradient(135deg, #c51a1f 0%, #A21418 100%);
    box-shadow: 0 15px 35px rgba(162, 20, 24, 0.5);
}

.tfs-search-tab:hover i {
    opacity: 0;
    width: 0;
    margin-right: 0;
    transform: translateX(-10px);
}

.tfs-search-tab:hover .search-label {
    opacity: 1;
    max-width: 150px;
    margin-left: 0;
}

@media (min-width: 992px) {
    .tfs-search-tab {
        display: flex;
    }
}

.tfs-search-overlay {
    position: fixed;
    top: -150px; /* Hide offscreen */
    left: 0;
    width: 100%;
    height: 120px;
    background: #fff;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    z-index: 1050;
}

.tfs-search-overlay.active {
    top: 0;
}

.tfs-search-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.tfs-search-backdrop.active {
    display: block;
    opacity: 1;
}

.tfs-search-overlay .container {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 100%;
}

.search-input-group-container {
    width: 100%;
    max-width: 800px;
}

.search-input-group {
    border-bottom: 2px solid #333;
    padding-bottom: 5px;
}

.search-input-group input[type="search"] {
    border: none;
    font-size: 24px;
    padding: 10px;
    background: transparent;
}

.search-input-group input[type="search"]:focus {
    box-shadow: none;
    outline: none;
}

.search-close-standalone {
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    padding: 10px;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
}

.search-input-group .btn-tfs {
    background: none !important;
    border: none !important;
    color: #333 !important;
    font-size: 24px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-input-group .btn-tfs i {
    display: none;
}

/* =============================================
   Mobile Search Overlay (independent of nav)
   ============================================= */
.tfs-mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1060;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tfs-mobile-search-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tfs-mobile-search-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.tfs-mobile-search-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 600px;
    margin: 80px 20px 0;
    background: #fff;
    border-radius: 12px;
    padding: 24px 20px 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(-30px);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.tfs-mobile-search-overlay.active .tfs-mobile-search-content {
    transform: translateY(0);
}

.tfs-mobile-search-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s ease;
}

.tfs-mobile-search-close:hover {
    color: #000;
}

.tfs-mobile-search-form-wrap {
    margin-top: 8px;
}

.tfs-mobile-search-form input[type="search"] {
    border-radius: 8px;
    height: 54px;
    font-size: 18px;
    border: 2px solid #e0e0e0;
    transition: border-color 0.2s ease;
}

.tfs-mobile-search-form input[type="search"]:focus {
    border-color: #A21418;
    box-shadow: 0 0 0 3px rgba(162, 20, 24, 0.15);
}

.tfs-mobile-search-form .btn-tfs {
    border-radius: 8px;
}

/* Hide mobile overlay on desktop */
@media (min-width: 992px) {
    .tfs-mobile-search-overlay {
        display: none;
    }
}
