/* News tags section */
.news-tags-section {
    margin: 1.5rem 0;
}

.tags-section-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--gray-light-medium-color);
    padding-bottom: 0.5rem;
}

.news-tags-container {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.news-tags-label {
    margin-right: 1rem;
    font-weight: 500;
    padding-top: 0.5rem;
}

/* News search area container */
.news-search-area {
    width: 100%;
    margin-bottom: 1.5rem;
    position: relative;
}

.news-filters-container {
    display: flex;
    align-items: stretch;
    margin-bottom: 0.5rem;
    justify-content: flex-end;
    position: relative;
    z-index: 999; /* Higher than the loading screen */
}

/* News search container */
.news-search {
    width: 100%;
    max-width: 800px;
    position: relative;
}

.news-search-container {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    background-color: #fff;
    z-index: 3;
}

#news-search-bar {
    padding-left: 3.5rem;
    padding-right: 5rem; /* Space for both clear and search buttons */
    border-radius: 4px;
}

/* Tags dropdown */
.tags-dropdown-button {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-right: 1px solid #ced4da;
    color: #495057;
    padding: 0 0.75rem;
    font-size: 1rem;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s ease;
    min-width: 3rem;
}

.tags-dropdown-button:hover {
    background-color: rgba(0,0,0,0.03);
    color: #0066cc;
}

.tags-dropdown-button.active {
    color: #0066cc;
}

/* Display tag count */
.tags-dropdown-button[data-count]:after {
    content: attr(data-count);
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--primary-light-medium-color);
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Selected tags display */
.news-selected-tags {
    position: absolute;
    top: 100%;
    right: 0;
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    transition: all 0.2s ease;
    justify-content: flex-end;
    z-index: 1;
}

.news-selected-tags:empty {
    display: none;
}

.selected-tag-item {
    display: flex;
    align-items: center;
    background-color: var(--primary-light-4-color);
    border: 1px solid var(--primary-light-1-color);
    color: var(--primary-medium-color);
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    max-width: fit-content;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-tag-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--primary-medium-color);
    margin-left: 0.25rem;
    cursor: pointer;
    padding: 0.125rem;
    border-radius: 50%;
}

.remove-tag-btn:hover {
    background-color: rgba(0, 102, 204, 0.1);
}

.more-tags-indicator {
    display: flex;
    align-items: center;
    background-color: var(--gray-light-color);
    border: 1px solid var(--gray-medium-color);
    color: var(--gray-medium-dark-color);
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    cursor: help;
    transition: all 0.2s ease;
}

/* News tag item in dropdown */
.news-tag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--gray-light-color);
    border: 1px solid var(--gray-light-medium-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    overflow: hidden;
    margin-bottom: 0.4rem;
    width: 100%;
    text-align: left;
}

.news-tag-item.selected {
    background-color: var(--primary-light-4-color);
    border-color: var(--primary-light-1-color);
    color: var(--primary-medium-color);
    position: relative;
}

.news-tag-item.selected::before {
    content: "✓";
    position: absolute;
    left: 0.5rem;
    color: var(--primary-medium-color);
    font-weight: bold;
}

.news-tag-item.selected .tag-name {
    padding-left: 1rem;
    color: var(--primary-medium-color);
}

.news-tag-item.selected .tag-count {
    background-color: var(--primary-light-4-color);
    color: var(--primary-medium-color);
}

.news-tag-item:hover {
    background-color: var(--primary-light-4-color);
    transform: translateY(-1px);
}

/* Tags search box */
.tags-search-box {
    padding: 0.75rem;
    border-bottom: 1px solid var(--gray-light-medium-color);
}

.tags-search-input-container {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    justify-content: center;    
    gap: 0.5rem;
}

.tags-search-input {
    flex: 1;
    font-size: 0.875rem;
    border: 1px solid var(--gray-light-medium-color);
    border-radius: 4px;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem; /* Space for clear button */
    position: relative; /* Ensure the input is a positioning context */
}

.tags-search-input:focus {
    border-color: var(--primary-light-1-color);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
    outline: none;
}

/* Clear all tags button */
.clear-all-tags-btn {
    background: none;
    border: none;
    color: var(--gray-medium-dark-color);
    font-size: 0.875rem;
    cursor: pointer;
    height: 100%;
    padding: 0 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: fit-content;
}

.clear-all-tags-btn:not(:disabled):hover {
    color: var(--gray-dark-color);
    background-color: rgba(0, 0, 0, 0.05);
}

.clear-all-tags-btn:disabled {
    opacity: 0.5;
}

/* Tags search clear button */
.tags-search-clear-button {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--gray-medium-dark-color);
    padding: 0.25rem;
    cursor: pointer;
    transition: color 0.2s ease;
    z-index: 1;
    font-size: 0.875rem; /* Match input font size */
}

.tags-search-clear-button:hover {
    color: var(--gray-dark-color);
}

.tags-search-clear-button.hidden {
    visibility: hidden;
}

/* Tags list styles */
.news-tags-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
}

.tag-name {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--gray-medium-dark-color);
}

.tag-count {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 24px;
    height: 24px;
    font-size: 0.75rem;
    background-color: var(--gray-light-color);
    border-radius: 12px;
    padding: 0 0.5rem;
    color: var(--gray-medium-dark-color);
}

/* No matches message */
.no-matches-msg {
    width: 100%;
    padding: 1rem;
    text-align: center;
    color: var(--gray-medium-dark-color);
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .news-search-area {
        padding-bottom: 4rem; /* More space for tags on mobile */
    }
    
    .news-filters-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .news-search {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .tags-dropdown-button {
        width: 100%;
        justify-content: center;
    }
    
    .tags-dropdown-content {
        width: 100%;
        max-width: 100%;
        right: 0;
        left: 0;
    }
    
    .news-selected-tags {
        max-width: 100%;
    }
}

/* Update dropdown content styles */
.tags-dropdown-content {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 999;
    display: none;
    min-width: 280px;
    max-width: 90vw;
    width: 100%;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
}

.tags-dropdown-content.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* Error state styles */

.error-state .error-icon {
    color: #dc2626;
}

.article-tag {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.375rem;
    background-color: var(--gray-light-color);
    color: var(--primary-medium-color);
    border: 1px solid var(--gray-light-medium-color);
    pointer-events: none;
    width: auto;
}