/**
 * Enhanced Libraries Filter Styles
 * Modern, responsive styling for XMOS libraries search and filter functionality
 */

/* Filter Container */
.xmos-filter-container {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 32px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.xmos-filter-container:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Filter Header */
.xmos-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
}

.xmos-filter-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.xmos-results-count {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Search Input */
.xmos-search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.xmos-search-input {
    width: 100%;
    padding: 12px 16px 12px 48px !important;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    background-color: #ffffff;
    transition: all 0.3s ease;
    outline: none;
}

.xmos-search-input:focus {
    border-color: #1399db;
    box-shadow: 0 0 0 3px rgba(19, 153, 219, 0.1);
}

.xmos-search-input::placeholder {
    color: #9ca3af;
}

.xmos-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: 18px;
    pointer-events: none;
}

/* Filter Grid */
.xmos-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

@media (max-width: 768px) {
    .xmos-filters-grid {
        grid-template-columns: 1fr;
    }
}

/* Filter Groups */
.xmos-filter-group {
    display: flex;
    flex-direction: column;
}

.xmos-filter-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.xmos-filter-select {
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    background-color: #ffffff;
    color: #374151;
    transition: all 0.3s ease;
    outline: none;
    cursor: pointer;
}

.xmos-filter-select:focus {
    border-color: #1399db;
    box-shadow: 0 0 0 3px rgba(19, 153, 219, 0.1);
}

.xmos-filter-select:hover {
    border-color: #d1d5db;
}

/* Multi-select specific styles */
.xmos-multi-select {
    min-height: 80px;
    max-height: 120px;
    overflow-y: auto;
    resize: vertical;
}

.xmos-multi-select option {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.xmos-multi-select option:hover {
    background-color: #f3f4f6;
}

.xmos-multi-select option:checked {
    background-color: #1399db;
    color: #ffffff;
    font-weight: 500;
}

/* Custom Dropdown Styles */
.xmos-dropdown-wrapper {
    position: relative;
    width: 100%;
}

.xmos-dropdown-toggle {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    background-color: #ffffff;
    color: #374151;
    transition: all 0.3s ease;
    outline: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.xmos-dropdown-toggle:hover {
    border-color: #d1d5db;
}

.xmos-dropdown-toggle:focus,
.xmos-dropdown-toggle.active {
    border-color: #1399db;
    box-shadow: 0 0 0 3px rgba(19, 153, 219, 0.1);
}

.xmos-dropdown-text {
    flex: 1;
    color: #6b7280;
    font-size: 14px;
}

.xmos-dropdown-text.has-selection {
    color: #374151;
    font-weight: 500;
}

.xmos-dropdown-arrow {
    color: #6b7280;
    font-size: 12px;
    transition: transform 0.3s ease;
    margin-left: 8px;
}

.xmos-dropdown-toggle.active .xmos-dropdown-arrow {
    transform: rotate(180deg);
}

.xmos-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #ffffff;
    border: 2px solid #1399db;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.xmos-dropdown-menu.active {
    display: block;
    animation: slideDown 0.2s ease;
}

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

.xmos-checkbox-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
    margin: 0;
    font-weight: normal;
}

.xmos-checkbox-option:last-child {
    border-bottom: none;
}

.xmos-checkbox-option:hover {
    background-color: #f8fafc;
}

.xmos-checkbox-option input[type="checkbox"] {
    margin: 0 8px 0 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1399db;
}

.xmos-checkbox-text {
    flex: 1;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
}

/* Selected Filters Display */
.xmos-selected-filters {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.xmos-selected-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.xmos-selected-filters-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
}

.xmos-clear-all-btn {
    background: #ef4444;
    color: #ffffff;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.xmos-clear-all-btn:hover {
    background: #dc2626;
}

.xmos-selected-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.xmos-filter-tag {
    display: inline-flex;
    align-items: center;
    background: #1399db;
    color: #ffffff;
    padding: 6px 8px 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    gap: 6px;
    animation: fadeInTag 0.3s ease;
}

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

.xmos-filter-tag-label {
    opacity: 0.9;
}

.xmos-filter-tag-value {
    font-weight: 600;
}

.xmos-filter-tag-remove {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.xmos-filter-tag-remove:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Filter Actions */
.xmos-filter-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

@media (max-width: 768px) {
    .xmos-filter-actions {
        justify-content: stretch;
    }
    
    .xmos-filter-actions button {
        flex: 1;
    }
}

.xmos-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.xmos-btn-secondary {
    background-color: #f9fafb;
    color: #374151;
    border-color: #e5e7eb;
}

.xmos-btn-secondary:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.xmos-btn-primary {
    background-color: #1399db;
    color: #ffffff;
    border-color: #1399db;
}

.xmos-btn-primary:hover {
    background-color: #0284c7;
    border-color: #0284c7;
}

/* Results Container */
.xmos-libraries-results {
    position: relative;
    min-height: 200px;
    transition: opacity 0.3s ease;
}

.xmos-libraries-results.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Loader */
.xmos-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10;
}

.xmos-loader.active {
    opacity: 1;
    visibility: visible;
}

.xmos-loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #1399db;
    border-radius: 50%;
    animation: xmos-spin 1s linear infinite;
}

@keyframes xmos-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced Table Styles */
.libtable {
    width: 100%;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

.libtable thead {
    background: linear-gradient(135deg, #1399db 0%, #0284c7 100%);
    color: #ffffff;
}

.libtable thead th {
    padding: 16px 12px;
    font-weight: 600;
    text-align: left;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    width: 150px;
}
.libtable thead th.text-left {
    width: auto;
}
.libtable thead th:first-child {
    width: 155px;
}

.libtable tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s ease;
}

.libtable tbody tr:hover {
    background-color: ##efef4;
}

.libtable tbody tr:last-child {
    border-bottom: none;
}

.libtable tbody td {
    padding: 5px 10px;
    vertical-align: top;
    font-size: 14px;
    color: #374151;
}

.libtable tbody td a {
    color: #1399db;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.libtable tbody td a:hover {
    color: #0284c7;
    text-decoration: underline;
}

/* Category Headers */
.xmos-category-header {
    padding: 10px 0;
    margin: 20px 0 10px 0;
    text-align: center;
}

.xmos-category-header h3 {
    margin: 0;
    text-transform: uppercase;
    font-weight: 400;
}

/* Error Message */
.xmos-error-message {
    text-align: center;
    padding: 40px 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
}

.xmos-error-message p {
    margin: 0 0 16px 0;
    font-size: 16px;
}

.xmos-retry-btn {
    background: #dc2626;
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.xmos-retry-btn:hover {
    background: #b91c1c;
}

/* No Results */
.xmos-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.xmos-no-results-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.xmos-no-results h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #374151;
}

.xmos-no-results p {
    margin: 0;
    font-size: 14px;
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .xmos-filter-container {
        padding: 10px;
        margin-bottom: 20px;
    }
    
    .xmos-filter-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .xmos-multi-select {
        min-height: 60px;
        max-height: 100px;
    }
    
    .xmos-dropdown-menu {
        max-height: 150px;
    }
    
    .xmos-checkbox-option {
        padding: 8px 12px;
    }
    
    .xmos-checkbox-text {
        font-size: 13px;
    }
    
    .xmos-selected-filters-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .xmos-selected-filters-list {
        gap: 6px;
    }
    
    .xmos-filter-tag {
        font-size: 11px;
        padding: 4px 6px 4px 10px;
    }
    
    .xmos-filter-tag-remove {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }
    
    .libtable {
        font-size: 12px;
    }
    
    .libtable thead th,
    .libtable tbody td {
        padding: 12px 8px;
    }
    
    .xmos-category-header {
        margin: 20px 0 12px 0;
        padding: 12px 0;
    }
    
    .xmos-category-header h3 {
        font-size: 18px;
    }
}

/* Accessibility Improvements */
.xmos-filter-select:focus,
.xmos-search-input:focus,
.xmos-btn:focus {
    outline: 2px solid #1399db;
    outline-offset: 2px;
}

/* Dark mode support (if theme supports it) 
@media (prefers-color-scheme: dark) {
    .xmos-filter-container {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .xmos-search-input,
    .xmos-filter-select {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .libtable {
        background: #1f2937;
    }
    
    .libtable tbody tr:hover {
        background-color: #374151;
    }
}
*/