/* Modern Tag Selector Styles - OnlyPans Inspired */

.tag-selector {
    position: relative;
}

.tag-selector-dropdown {
    border: 1px solid #dee2e6 !important;
    border-radius: 0.375rem !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    background-color: white !important;
    background: white !important;
    z-index: 1060 !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
    visibility: visible !important;
}

.tag-selector-dropdown.d-none {
    display: none !important;
}

.tag-selector-dropdown:not(.d-none) {
    display: block !important;
}

.tag-selector .btn {
    min-height: 42px;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.tag-selector .btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.tag-groups-container {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #6c757d #f8f9fa;
}

/* Mobile responsive fixes */
@media (max-width: 768px) {
    .tag-groups-container {
        max-height: 50vh;
    }
    
    .tag-selector .badge {
        max-width: 120px;
        font-size: 0.7rem;
    }
    
    /* Allow JavaScript to control positioning on mobile */
    .tag-selector .dropdown-menu {
        max-width: none;
    }
}

.tag-groups-container::-webkit-scrollbar {
    width: 6px;
}

.tag-groups-container::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.tag-groups-container::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 3px;
}

.tag-group-header {
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 1;
}

.tag-group-tags {
    padding: 0.75rem;
    background-color: white !important;
    background: white !important;
}

.tag-groups-container {
    background-color: white !important;
    background: white !important;
}

.tag-item {
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
}

.tag-item:hover {
    background-color: #f8f9fa;
    transform: translateX(2px);
}

.tag-item.selected {
    background-color: #0d6efd;
    color: white;
}

.tag-item.selected:hover {
    background-color: #0b5ed7;
}

.tag-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #0d6efd;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease-in-out;
    flex-shrink: 0;
}

.tag-checkbox.checked {
    background-color: white;
    border-color: white;
}

.tag-selector .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
    display: inline-flex;
    align-items: center;
    max-width: 200px;
}

.tag-selector .badge .btn-close {
    font-size: 0.6rem;
    margin-left: 0.25rem;
    opacity: 0.8;
}

.tag-selector .badge .btn-close:hover {
    opacity: 1;
}

.tag-item-content {
    flex-grow: 1;
    min-width: 0;
}

.tag-item-name {
    font-weight: 500;
    display: flex;
    align-items: center;
    margin-bottom: 0.125rem;
}

.tag-item-description {
    font-size: 0.8rem;
    color: #6c757d;
    line-height: 1.2;
}

.tag-icon {
    margin-right: 0.5rem;
    font-size: 1rem;
    flex-shrink: 0;
}

.custom-tag-badge {
    font-size: 0.6rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
    color: #6c757d;
    background-color: transparent;
    margin-left: 0.5rem;
}

.tag-search-input {
    border: none;
    border-bottom: 1px solid #dee2e6;
    border-radius: 0;
    padding: 0.75rem;
    font-size: 0.9rem;
}

.tag-search-input:focus {
    box-shadow: none;
    border-bottom-color: #0d6efd;
}

.no-tags-found {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
}

.tag-count {
    font-size: 0.75rem;
    color: #6c757d;
    margin-left: auto;
}

/* Animation for dropdown */
.tag-selector-dropdown {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease-in-out;
}

.tag-selector-dropdown:not(.d-none) {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tag-selector-dropdown {
        position: fixed;
        top: 50% !important;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 400px;
        max-height: 80vh;
    }
    
    .tag-groups-container {
        max-height: calc(80vh - 60px);
    }
    
    .tag-selector .badge {
        max-width: 150px;
        font-size: 0.7rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .tag-selector-dropdown {
        background-color: #212529;
        border-color: #495057;
    }
    
    .tag-group-header {
        background-color: #343a40;
        border-bottom-color: #495057;
    }
    
    .tag-item:hover {
        background-color: #343a40;
    }
    
    .tag-item-description {
        color: #adb5bd;
    }
    
    .tag-search-input {
        background-color: #212529;
        color: white;
        border-bottom-color: #495057;
    }
    
    .tag-search-input:focus {
        border-bottom-color: #0d6efd;
    }
}

/* Focus states for accessibility */
.tag-item:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.tag-selector .btn:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Loading state */
.tag-selector.loading .tag-selector-dropdown::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.tag-selector.loading .tag-selector-dropdown::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    color: #6c757d;
}