/* =====================================================
   Header Search Styles
   Real-time search box with dropdown results
   ===================================================== */

/* Mobile Search Trigger Icon (shown on mobile only) */
.mobile-search-trigger {
    display: none;
    background: none;
    border: none;
    color: var(--heading-color, #1a1a2e);
    font-size: 22px;
    padding: 8px;
    cursor: pointer;
    margin-left: auto;
    margin-right: 10px;
}

/* Desktop Search Wrapper */
.header-search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
}

.header-search {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e1e5eb;
    border-radius: 50px;
    padding: 0 5px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-search:focus-within {
    background: #ffffff;
    border-color: var(--base-color, #4361ee);
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.15);
}

.header-search__input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 15px;
    font-size: 14px;
    color: #333333;
    outline: none;
    min-width: 150px;
}

.header-search__input::placeholder {
    color: #9ca3af;
}

.header-search__btn,
.header-search__clear {
    background: hsl(var(--base));
    border: none;
    color: #fff;
    width: 38px; /* Slightly larger */
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin: 3px; /* Add margin so it sits inside nicely */
}

.header-search__btn:hover {
    background: var(--base-color-dark, #3651de);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.header-search__btn i {
    font-size: 18px;
    font-weight: 600;
}

.header-search__clear {
    background: #f1f3f5; /* Light subtle grey for clear */
    color: #868e96;
    width: 32px;
    height: 32px;
    margin-right: 2px;
}

.header-search__clear:hover {
    background: #e9ecef;
    color: #fa5252;
}

/* Dropdown */
.header-search__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.header-search__dropdown.show {
    display: block;
    animation: dropdownShow 0.2s ease;
}

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

/* Search Results */
.search-results {
    padding: 8px 0;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
    gap: 12px;
}

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

.search-result-item__image {
    width: 60px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.search-result-item__info {
    flex: 1;
    min-width: 0;
}

.search-result-item__title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-item__meta {
    font-size: 12px;
    color: #6c757d;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-result-item__date {
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-result-item__price {
    color: var(--base-color, #4361ee);
    font-weight: 600;
}

/* Loading & No Results */
.search-loading,
.search-no-results {
    padding: 24px 16px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

.search-loading i {
    font-size: 20px;
    margin-right: 8px;
}

.search-no-results i {
    display: block;
    font-size: 32px;
    margin-bottom: 8px;
    color: #dee2e6;
}

/* View All Link */
.search-view-all {
    display: block;
    padding: 14px 16px;
    text-align: center;
    color: var(--base-color, #4361ee);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border-top: 1px solid #eee;
    transition: background 0.2s;
}

.search-view-all:hover {
    background: #f8f9fa;
    color: var(--base-color-dark, #3651de);
}

/* Section Header */
.search-section-header {
    padding: 10px 16px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =====================================================
   Mobile Search Overlay (Fullscreen)
   ===================================================== */

.mobile-search-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    z-index: 9999;
    flex-direction: column;
}

.mobile-search-overlay.show {
    display: flex;
    animation: slideInFromRight 0.25s ease;
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.mobile-search-overlay__header {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    gap: 10px;
    background-color: hsl(var(--base));
    color: #fff;
}

.mobile-search-overlay__back {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-search-overlay__input-wrap {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.mobile-search-overlay__input {
    width: 100%;
    border: none;
    padding: 12px 15px;
    font-size: 15px;
    color: #333;
    outline: none;
}

.mobile-search-overlay__input::placeholder {
    color: #9ca3af;
}

.mobile-search-overlay__btn {
    background: var(--base-color, #4361ee);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}

.mobile-search-overlay__body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    /* Hide Scrollbar */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.mobile-search-overlay__body::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

/* Recent Searches */
.mobile-search-recent__title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.mobile-search-recent__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-search-recent__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

.mobile-search-recent__item:hover {
    background: #f8f9fa;
    margin: 0 -15px;
    padding-left: 15px;
    padding-right: 15px;
}

.mobile-search-recent__item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #333;
}

.mobile-search-recent__item-left i {
    color: #9ca3af;
    font-size: 16px;
}

.mobile-search-recent__item-delete {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 5px;
}

/* Mobile Results */
.mobile-search-results {
    margin-top: 20px;
}

/* Mobile specific result adjustments */
.mobile-results-list .search-result-item {
    padding: 12px 0; /* Remove horizontal padding */
    border-bottom: 1px solid #f0f0f0;
}

.mobile-results-list {
    display: flex;
    flex-direction: column;
    gap: 0; /* Remove gap */
}

.mobile-view-all {
    display: block;
    padding: 14px;
    text-align: center;
    color: var(--base-color, #4361ee);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 15px;
}

/* =====================================================
   Responsive: Show/Hide elements
   ===================================================== */

@media (max-width: 991px) {
    /* Show mobile trigger, hide desktop search */
    .mobile-search-trigger {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
        margin-right: 12px; /* Jarak antara search dan hamburger */
        position: relative;
        z-index: 1;
        
        /* Modern Styling */
        width: 42px;
        height: 42px;
        border-radius: 12px;
        background: #fff;
        border: 1px solid #e1e5eb;
        color: var(--base-color, #4361ee);
        font-size: 20px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        transition: all 0.3s ease;
    }

    .mobile-search-trigger:active {
        transform: scale(0.95);
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }
    
    /* Hide search icon when menu is expanded */
    .navbar-collapse.show ~ .mobile-search-trigger,
    .navbar-collapse.collapsing ~ .mobile-search-trigger {
        display: none !important;
    }
    
    .desktop-search {
        display: none !important;
    }
    
    /* Adjust navbar for mobile - align items horizontally */
    .header .navbar {
        flex-wrap: nowrap;
        position: static;
        align-items: center; /* Ensure vertical alignment */
        padding-top: 5px;
        padding-bottom: 5px;
    }
    
    .header .navbar-brand {
        flex-shrink: 0;
        margin-right: auto;
    }
    
    /* Modern Hamburger Button Styling */
    .header .navbar-toggler {
        flex-shrink: 0;
        position: relative;
        z-index: 2;
        margin-left: 0;
        padding: 0;
        
        /* Match Search Icon Style - Clean White Look */
        width: 42px;
        height: 42px;
        display: flex; /* Flex to center icon */
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        background: #fff; /* White background */
        border: 1px solid #e1e5eb; 
        color: var(--base-color, #4361ee); /* Blue icon */
        transition: all 0.3s ease;
    }

    .header .navbar-toggler:active {
        transform: scale(0.95);
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }

    .header .navbar-toggler i {
        font-size: 24px; /* Slightly larger icon */
    }
    
    /* Fix navbar collapse positioning - Full Width */
    .header .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        background: #fff;
        padding: 20px;
        box-shadow: 0 15px 30px rgba(0,0,0,0.1);
        z-index: 100;
        border-top: 1px solid #f0f0f0;
        border-radius: 0 0 20px 20px; /* Rounded bottom corners */
    }
}

@media (min-width: 992px) {
    /* Desktop: show search wrapper, hide mobile trigger */
    .mobile-search-trigger {
        display: none;
    }
    
    .desktop-search {
        display: block;
    }
    
    .mobile-search-overlay {
        display: none !important;
    }
}
