/* Header Search Styles */
.header-search-container {
    position: relative;
    max-width: 300px;
    width: 300px;
    margin: 0;
    flex: 0 0 auto;
    z-index: 1001;
}

/* Override the display: contents for navbar-header when search is present */
.navbar-container .navbar-header {
    display: flex !important;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.header-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 6px 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.header-search-wrapper:focus-within {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    background: white;
}

.header-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 4px 8px;
    background: transparent;
    color: #333;
    width: 100%;
}

.header-search-input::placeholder {
    color: #999;
    font-size: 13px;
}

.header-search-icon {
    color: #5a7fa7;
    font-size: 16px;
    margin-right: 6px;
}

.header-search-clear {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 14px;
    display: none;
    transition: color 0.2s;
}

.header-search-input:not(:placeholder-shown) + .header-search-clear {
    display: block;
}

.header-search-clear:hover {
    color: #333;
}

/* Search Dropdown */
#search-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-height: 500px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    border: 1px solid #ddd;
}

#search-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease;
}

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

.search-dropdown-item {
    display: block;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover,
.search-dropdown-item.active {
    background: #f8f9fa;
}

.search-item-title {
    font-size: 15px;
    font-weight: 600;
    color: #2c5282;
    margin-bottom: 6px;
    line-height: 1.4;
}

.search-item-title mark {
    background: #fff3cd;
    color: inherit;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
}

.search-item-meta {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.search-item-journal {
    color: #5a7fa7;
    font-weight: 600;
}

.search-item-citation {
    color: #888;
}

.search-item-authors {
    font-size: 13px;
    color: #777;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-dropdown-empty {
    padding: 24px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.search-dropdown-empty small {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #666;
    word-wrap: break-word;
}

/* Custom Scrollbar for Dropdown */
#search-dropdown::-webkit-scrollbar {
    width: 8px;
}

#search-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 8px;
}

#search-dropdown::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 8px;
}

#search-dropdown::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-search-container {
        max-width: 250px;
        width: 250px;
    }

    .header-search-wrapper {
        padding: 5px 12px;
        border-radius: 18px;
    }

    .header-search-input {
        font-size: 13px;
    }
    
    .header-search-input::placeholder {
        font-size: 12px;
    }

    #search-dropdown {
        max-height: 400px;
    }

    .search-dropdown-item {
        padding: 12px 15px;
    }

    .search-item-title {
        font-size: 14px;
    }

    .search-item-meta,
    .search-item-authors {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .header-search-container {
        max-width: 180px;
        width: 180px;
    }
    
    .header-search-wrapper {
        border-radius: 16px;
        padding: 4px 10px;
    }
    
    .header-search-input::placeholder {
        content: "Search...";
    }

    #search-dropdown {
        max-height: 300px;
    }
}
