/* Book Filters - Advanced Filter UI */

.book-filters {
    background: #ffffff;
    border-radius: 12px;
    padding: var(--spacing-6, 24px);
    margin-bottom: var(--spacing-6, 24px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Quick Filter Tabs */
.book-filters__tabs-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-5, 20px);
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: var(--spacing-2, 8px);
}

.book-filters__tabs {
    display: flex;
    gap: var(--spacing-2, 8px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.book-filters__toggle-link {
    background: none;
    border: none;
    padding: var(--spacing-2, 8px) 0;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 1px dotted #9ca3af;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin-left: var(--spacing-4, 16px);
}

.book-filters__toggle-link:hover {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.filter-tab {
    background: transparent;
    border: none;
    padding: var(--spacing-2, 8px) var(--spacing-4, 16px);
    font-size: 15px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.filter-tab:hover {
    background: #f3f4f6;
    color: #374151;
}

.filter-tab.active {
    color: #2563eb;
    background: #eff6ff;
}

.filter-tab.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 2px;
    background: #2563eb;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

/* Advanced Filters Row */
.book-filters__advanced-row {
    display: flex;
    gap: 24px;
    padding: 16px 0;
    border-bottom: 1px solid #e5e7eb;
    align-items: start;
    flex-wrap: wrap;
}

.book-filters__advanced-row--primary {
    padding-top: 0;
}

.book-filters__advanced-row:last-child {
    border-bottom: none;
    margin-bottom: 16px;
}

/* Additional Filters Container */
.book-filters__additional {
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.4s ease;
    max-height: 0;
    opacity: 0;
}

.book-filters__additional.show {
    max-height: 2000px;
    opacity: 1;
}

.book-filters__filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.book-filters__filter-group--full {
    flex: 1 1 100%;
}

.book-filters__filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.book-filters__filter-label svg {
    width: 16px;
    height: 16px;
    color: #9ca3af;
}

.book-filters__select {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.book-filters__select:hover {
    border-color: #9ca3af;
}

.book-filters__select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tag Filter */
.book-filters__tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.book-filters__tag-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.book-filters__tag-checkbox:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.book-filters__tag-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.book-filters__tag-checkbox input[type="checkbox"]:checked + .book-filters__tag-label {
    font-weight: 600;
    color: #2563eb;
}

.book-filters__tag-checkbox:has(input[type="checkbox"]:checked) {
    background: #eff6ff;
    border-color: #3b82f6;
}

.book-filters__tag-label {
    color: #6b7280;
    transition: all 0.2s ease;
}

/* Filter Controls */
.book-filters__controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4, 16px);
}

.book-filters__form {
    width: 100%;
}

.book-filters__row {
    display: flex;
    gap: var(--spacing-3, 12px);
    align-items: center;
    flex-wrap: wrap;
}

/* Search Input */
.book-filters__search {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.book-filters__search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.book-filters__input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s ease;
}

.book-filters__input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Sort Dropdown */
.book-filters__sort {
    min-width: 180px;
}

/* Action Buttons */
.book-filters__actions {
    display: flex;
    gap: var(--spacing-2, 8px);
}

.book-filters__button {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2, 8px);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
}

.book-filters__button--primary {
    background: #2563eb;
    color: #ffffff;
}

.book-filters__button--primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}

.book-filters__button--secondary {
    background: #f3f4f6;
    color: #6b7280;
}

.book-filters__button--secondary:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Filter Chips */
.book-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-2, 8px);
    animation: fadeIn 0.3s ease;
}

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

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2, 8px);
    padding: 6px 12px;
    background: #eff6ff;
    color: #1e40af;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    animation: chipSlideIn 0.3s ease;
}

@keyframes chipSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.filter-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #1e40af;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.filter-chip__remove:hover {
    background: #dbeafe;
    transform: rotate(90deg);
}

.filter-chip__remove svg {
    display: block;
}

/* Results Counter */
.book-filters__results {
    padding-top: var(--spacing-3, 12px);
    border-top: 1px solid #e5e7eb;
}

.book-filters__count {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Smooth Content Transitions */
.book-filters__form,
.book-filters__chips,
.book-filters__results {
    transition: all 0.3s ease;
}

/* Loading State */
.book-filters--loading {
    opacity: 0.6;
    pointer-events: none;
}

.book-filters--loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Focus Visible for Accessibility */
.filter-tab:focus-visible,
.book-filters__input:focus-visible,
.book-filters__select:focus-visible,
.book-filters__button:focus-visible,
.filter-chip__remove:focus-visible,
.book-filters__tag-checkbox:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .book-filters__advanced-row {
        flex-direction: column;
        gap: 20px;
    }
    
    .book-filters__filter-group {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 768px) {
    .book-filters {
        padding: var(--spacing-4, 16px);
    }
    
    .book-filters__tabs-container {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-2, 8px);
    }
    
    .book-filters__tabs {
        gap: var(--spacing-1, 4px);
        padding-bottom: var(--spacing-1, 4px);
        border-bottom: none;
    }
    
    .book-filters__toggle-link {
        margin-left: 0;
        text-align: center;
        padding: var(--spacing-2, 8px);
        border-bottom: 1px solid #e5e7eb;
    }
    
    .filter-tab {
        padding: var(--spacing-2, 8px) var(--spacing-3, 12px);
        font-size: 14px;
    }
    
    .book-filters__advanced-row {
        padding: 12px 0;
        gap: 16px;
    }
    
    .book-filters__filter-label {
        font-size: 12px;
    }
    
    .book-filters__row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .book-filters__search {
        min-width: 100%;
    }
    
    .book-filters__sort {
        min-width: 100%;
    }
    
    .book-filters__actions {
        width: 100%;
    }
    
    .book-filters__button {
        flex: 1;
        justify-content: center;
    }
    
    .book-filters__chips {
        gap: var(--spacing-1, 4px);
    }
    
    .filter-chip {
        font-size: 13px;
        padding: 5px 10px;
    }
    
    .book-filters__tag-list {
        gap: 6px;
    }
    
    .book-filters__tag-checkbox {
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* Dark Mode Support */
[data-theme="dark"] .book-filters {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .book-filters__tabs-container {
    border-bottom-color: #374151;
}

[data-theme="dark"] .book-filters__toggle-link {
    color: #9ca3af;
    border-bottom-color: #6b7280;
}

[data-theme="dark"] .book-filters__toggle-link:hover {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

[data-theme="dark"] .filter-tab {
    color: #9ca3af;
}

[data-theme="dark"] .filter-tab:hover {
    background: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] .filter-tab.active {
    color: #60a5fa;
    background: #1e3a8a;
}

[data-theme="dark"] .book-filters__advanced-row {
    border-bottom-color: #374151;
}

[data-theme="dark"] .book-filters__filter-label {
    color: #9ca3af;
}

[data-theme="dark"] .book-filters__select,
[data-theme="dark"] .book-filters__input {
    background: #111827;
    border-color: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] .book-filters__select:hover,
[data-theme="dark"] .book-filters__input:hover {
    border-color: #4b5563;
}

[data-theme="dark"] .book-filters__select:focus,
[data-theme="dark"] .book-filters__input:focus {
    border-color: #3b82f6;
    background: #1f2937;
}

[data-theme="dark"] .book-filters__tag-checkbox {
    background: #111827;
    border-color: #374151;
}

[data-theme="dark"] .book-filters__tag-checkbox:hover {
    background: #1f2937;
    border-color: #4b5563;
}

[data-theme="dark"] .book-filters__tag-checkbox:has(input[type="checkbox"]:checked) {
    background: #1e3a8a;
    border-color: #3b82f6;
}

[data-theme="dark"] .book-filters__tag-label {
    color: #9ca3af;
}

[data-theme="dark"] .book-filters__tag-checkbox input[type="checkbox"]:checked + .book-filters__tag-label {
    color: #60a5fa;
}

[data-theme="dark"] .book-filters__button--secondary {
    background: #374151;
    color: #9ca3af;
}

[data-theme="dark"] .book-filters__button--secondary:hover {
    background: #4b5563;
    color: #e5e7eb;
}

[data-theme="dark"] .filter-chip {
    background: #1e3a8a;
    color: #93c5fd;
}

[data-theme="dark"] .filter-chip__remove {
    color: #93c5fd;
}

[data-theme="dark"] .filter-chip__remove:hover {
    background: #1e40af;
}

[data-theme="dark"] .book-filters__results {
    border-top-color: #374151;
}

[data-theme="dark"] .book-filters__count {
    color: #9ca3af;
}


/* Mobile Filter Bar */
.mobile-filter-bar {
    display: none;
    position: sticky;
    top: 64px;
    z-index: 40;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mobile-filter-bar__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    max-width: 100%;
}

.mobile-filter-bar__info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.mobile-filter-bar__icon {
    flex-shrink: 0;
    color: #6b7280;
}

.mobile-filter-bar__text {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-filter-bar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mobile-filter-bar__button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mobile-filter-bar__button:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.mobile-filter-bar__button--primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    position: relative;
}

.mobile-filter-bar__button--primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.mobile-filter-bar__button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.mobile-filter-bar__badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #dc2626;
    color: #ffffff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

/* Mobile Floating Filter Button */
.mobile-floating-filter-button {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 45;
    width: 56px;
    height: 56px;
    background: #2563eb;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    animation: fadeInUp 0.3s ease;
}

.mobile-floating-filter-button:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

.mobile-floating-filter-button:active {
    transform: translateY(0);
}

.mobile-floating-filter-button svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.mobile-floating-filter-button__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #dc2626;
    color: #ffffff;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Show mobile components and hide desktop on mobile */
@media (max-width: 768px) {
    /* Hide desktop filters completely on mobile */
    .book-filters {
        display: none !important;
    }
    
    /* Show mobile filter bar */
    .mobile-filter-bar {
        display: block;
    }
    
    /* Show mobile floating button */
    .mobile-floating-filter-button {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Dark mode for mobile components */
[data-theme="dark"] .mobile-filter-bar {
    background: #1f2937;
    border-bottom-color: #374151;
}

[data-theme="dark"] .mobile-filter-bar__text {
    color: #e5e7eb;
}

[data-theme="dark"] .mobile-filter-bar__icon {
    color: #9ca3af;
}

[data-theme="dark"] .mobile-filter-bar__button {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

[data-theme="dark"] .mobile-filter-bar__button:hover {
    background: #4b5563;
    border-color: #6b7280;
}

[data-theme="dark"] .mobile-filter-bar__button--primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

[data-theme="dark"] .mobile-filter-bar__button--primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

[data-theme="dark"] .mobile-floating-filter-button {
    background: #2563eb;
}

[data-theme="dark"] .mobile-floating-filter-button:hover {
    background: #1d4ed8;
}
