/* QMJ Filters Styles */

/* Filter Trigger Button */
.filter-trigger {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    background: #059669;
    color: white;
    border: none;
    border-radius: 8px 0 0 8px;
    padding: 1rem 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    writing-mode: vertical-rl;
    font-size: 0.875rem;
    font-weight: 600;
}

.filter-trigger:hover {
    background: #047857;
    transform: translateY(-50%) translateX(-5px);
}

.filter-trigger.active {
    background: #047857;
    transform: translateY(-50%) translateX(-5px);
}

.filter-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
}

.filter-count {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 0.25rem;
    animation: bounceIn 0.3s ease;
}

/* Filter Sidebar */
.codes-filter-sidebar {
    position: fixed;
    top: 80px;
    right: -350px;
    width: 340px;
    height: calc(100vh - 100px);
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.codes-filter-sidebar.active {
    right: 0;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.filter-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.filter-toggle {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.filter-toggle:hover {
    background: #e5e7eb;
    color: #374151;
}

.filter-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.filter-section {
    margin-bottom: 1.5rem;
}

.filter-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.control-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.control-btn:active {
    transform: translateY(1px);
}

.codes-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
}

.code-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
}

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

.code-item:hover {
    background: #f9fafb;
}

.code-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 2px solid #d1d5db;
    border-radius: 3px;
    margin-right: 0.75rem;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.code-checkbox:checked ~ .checkmark {
    background-color: #059669;
    border-color: #059669;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.code-checkbox:checked ~ .checkmark:after {
    display: block;
}

.code-name {
    flex: 1;
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
}

.code-tag {
    font-size: 0.75rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    margin-left: 0.5rem;
}

.no-codes {
    text-align: center;
    padding: 2rem 1rem;
    color: #9ca3af;
}

.no-codes svg {
    margin: 0 auto 0.5rem;
    opacity: 0.5;
}

.no-codes p {
    margin: 0;
    font-size: 0.875rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.apply-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    background: #059669;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.apply-btn:hover {
    background: #047857;
}

.reset-btn {
    padding: 0.625rem 1rem;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: #e5e7eb;
    text-decoration: none;
    color: #374151;
}

.selected-filters {
    border-top: 1px solid #e5e7eb;
    padding-top: 1rem;
    margin-top: 1rem;
}

.selected-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.selected-tag {
    background: #059669;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.remove-tag {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.remove-tag:hover {
    opacity: 1;
}

/* Animations */
@keyframes bounceIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .codes-filter-sidebar {
        width: 320px;
        right: -330px;
    }
}

@media (max-width: 768px) {
    .filter-trigger {
        position: fixed;
        top: auto;
        bottom: 20px;
        right: 20px;
        transform: none;
        border-radius: 50%;
        width: 56px;
        height: 56px;
        padding: 0;
        writing-mode: initial;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .filter-trigger:hover {
        transform: scale(1.1);
    }
    
    .filter-trigger.active {
        transform: scale(1.1);
        background: #047857;
    }
    
    .filter-text {
        display: none;
    }
    
    .filter-count {
        position: absolute;
        top: -5px;
        right: -5px;
        background: #dc2626;
        color: white;
        font-size: 0.75rem;
        margin: 0;
    }
    
    .codes-filter-sidebar {
        width: 100%;
        right: -100%;
        top: 60px;
        height: calc(100vh - 80px);
        border-radius: 0;
    }
    
    .codes-filter-sidebar.active {
        right: 0;
    }
}

@media (max-width: 480px) {
    .filter-trigger {
        width: 48px;
        height: 48px;
        bottom: 15px;
        right: 15px;
    }
}

/* Filter Status Indicator */
.filter-status {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #dc2626;
    border-radius: 50%;
    border: 2px solid white;
}

/* Custom scrollbar for codes list */
.codes-list::-webkit-scrollbar {
    width: 4px;
}

.codes-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

.codes-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.codes-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Focus states for accessibility */
.code-checkbox:focus + .checkmark {
    outline: 2px solid #059669;
    outline-offset: 2px;
}

.control-btn:focus,
.apply-btn:focus,
.reset-btn:focus {
    outline: 2px solid #059669;
    outline-offset: 2px;
}

.filter-trigger:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Loading state */
.filter-loading {
    pointer-events: none;
    opacity: 0.7;
}

.filter-loading .apply-btn {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Empty state */
.filter-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
}

.filter-empty svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

/* Backdrop for mobile */
@media (max-width: 768px) {
    .filter-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .filter-backdrop.active {
        opacity: 1;
        visibility: visible;
    }
}