/* Catalog Filter Styles */

/* Filter panel toggle transition */
#filtersPanel {
    transition: opacity 0.15s ease;
}

/* Main container */
.catalog-filters {
    background: rgba(31, 41, 55, 0.95);
    border-radius: 0.75rem;
    padding: 1.5rem;
    padding-top:1.0rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(75, 85, 99, 0.3);
    overflow-x: hidden;
}

/* Filter sections */
.filter-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.0rem;
    border-bottom: 1px solid rgba(75, 85, 99, 0.2);
}

.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Section headers */
.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    cursor: pointer;
    user-select: none;
    padding: 0.25rem 0;
}

.filter-header:hover {
    color: #60a5fa;
}

.filter-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-title i {
    font-size: 1rem;
    color: #60a5fa;
}

.filter-count {
    font-size: 0.75rem;
    color: #9ca3af;
    background: rgba(59, 130, 246, 0.1);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

/* Collapsible content */
.filter-content {
    transition: all 0.3s ease;
}

.filter-content.collapsed {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

/* Constellation collapsible body - needs explicit max-height for smooth animation */
#constellationBody {
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    padding-top: 4px;
}

#constellationBody.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Constellation collapse chevron */
.constellation-chevron {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    color: #6b7280;
    margin-left: 0.25rem;
}

.constellation-chevron.collapsed {
    transform: rotate(-90deg);
}

/* Search input */
.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(17, 24, 39, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 0.5rem;
    color: #e5e7eb;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #60a5fa;
    background: rgba(17, 24, 39, 0.8);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

.search-input::placeholder {
    color: #6b7280;
}

/* Checkbox groups */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.375rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.checkbox-group.single-column {
    grid-template-columns: 1fr;
}

.checkbox-group.three-column {
    grid-template-columns: repeat(3, 1fr);
}

.checkbox-group::-webkit-scrollbar {
    width: 6px;
}

.checkbox-group::-webkit-scrollbar-track {
    background: rgba(31, 41, 55, 0.5);
    border-radius: 3px;
}

.checkbox-group::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.5);
    border-radius: 3px;
}

.checkbox-group::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 165, 250, 0.5);
}

/* Checkbox items */
.checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.5rem;
    background: rgba(17, 24, 39, 0.3);
    border-radius: 0.375rem;
    transition: all 0.2s;
    cursor: pointer;
    min-height: 2.25rem;
}

.checkbox-item:hover {
    background: rgba(17, 24, 39, 0.6);
}

.checkbox-item input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    accent-color: #60a5fa;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label {
    flex: 1;
    font-size: 0.8125rem;
    color: #d1d5db;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
}

.checkbox-label > span:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.checkbox-label .count {
    font-size: 0.6875rem;
    color: #6b7280;
    margin-left: 0.25rem;
    flex-shrink: 0;
}

.checkbox-item:has(input:checked) {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.checkbox-item:has(input:checked) .checkbox-label {
    color: #60a5fa;
    font-weight: 500;
}

/* Quick filter buttons */
.quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.quick-filters .btn-xs {
    padding: 0.2rem 0.375rem;
    font-size: 0.7rem;
}

/* Active state for filter buttons */
.btn.active,
[id^="const-sort-"].active {
    background: rgba(59, 130, 246, 0.3) !important;
    border-color: #60a5fa !important;
    color: #60a5fa !important;
    font-weight: 500;
}

/* Magnitude range */
.magnitude-range {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(17, 24, 39, 0.3);
    border-radius: 0.5rem;
}

.magnitude-input {
    width: 4.5rem;
    padding: 0.5rem;
    background: rgba(17, 24, 39, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 0.375rem;
    color: #e5e7eb;
    font-size: 0.875rem;
    text-align: center;
}

.mag-preset-btn {
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    line-height: 1.2;
    background: rgba(55, 65, 81, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: 0.25rem;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s;
}

.mag-preset-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #60a5fa;
    color: #e5e7eb;
}

.spectral-btn.active-spectral {
    background: rgba(59, 130, 246, 0.3);
    border-color: #60a5fa;
    color: #e5e7eb;
    font-weight: bold;
}

.magnitude-input:focus {
    outline: none;
    border-color: #60a5fa;
    background: rgba(17, 24, 39, 0.8);
}

.magnitude-separator {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Visibility options */
.visibility-options {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.visibility-option {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.625rem;
    background: rgba(17, 24, 39, 0.3);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: fit-content;
}

.visibility-option:hover {
    background: rgba(17, 24, 39, 0.6);
}

.visibility-option input[type="radio"] {
    margin-right: 0.75rem;
    accent-color: #60a5fa;
}

.visibility-option label {
    font-size: 0.875rem;
    color: #d1d5db;
    cursor: pointer;
}

.visibility-option:has(input:checked) {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

/* Constellation multi-select */
.constellation-select-wrapper {
    position: relative;
    margin-bottom: 0.75rem;
}

.constellation-search {
    width: 100%;
    padding: 0.625rem 1rem;
    padding-left: 2.5rem;
    background: rgba(17, 24, 39, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 0.5rem;
    color: #e5e7eb;
    font-size: 0.875rem;
}

.constellation-search-icon {
    position: absolute;
    left: 0.875rem;
    top: 0.625rem;
    color: #6b7280;
    pointer-events: none;
}

/* Checkbox grids for catalogs, object types, and constellations */
.catalog-grid,
.objecttype-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    max-height: 280px;
    overflow-y: auto;
}

.constellation-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    max-height: 450px;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(17, 24, 39, 0.2);
    border-radius: 0.5rem;
    padding: 0.5rem;
    margin-top: 0.75rem;
}

/* Catalog grid has only 3 columns since there are fewer items */
.catalog-grid {
    grid-template-columns: repeat(3, 1fr);
    max-height: 150px;
}

/* Group labels separating stellar / DSO / solar system */
.objecttype-group-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    padding: 0.25rem 0.125rem 0.125rem;
    margin-top: 0.375rem;
}

.objecttype-group-label:first-child {
    margin-top: 0;
}

/* Object type grid has 3 columns for better readability of longer names */
.objecttype-grid {
    grid-template-columns: repeat(3, 1fr);
}

.catalog-checkbox,
.objecttype-checkbox,
.constellation-checkbox {
    display: flex;
    align-items: center;
    padding: 0.25rem 0.375rem;
    background: rgba(17, 24, 39, 0.5);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.catalog-checkbox:hover,
.objecttype-checkbox:hover,
.constellation-checkbox:hover {
    background: rgba(17, 24, 39, 0.8);
}

.catalog-checkbox input[type="checkbox"],
.objecttype-checkbox input[type="checkbox"],
.constellation-checkbox input[type="checkbox"] {
    width: 0.875rem;
    height: 0.875rem;
    margin-right: 0.375rem;
    accent-color: #60a5fa;
    cursor: pointer;
    flex-shrink: 0;
}

.catalog-checkbox label,
.objecttype-checkbox label,
.constellation-checkbox label {
    cursor: pointer;
    color: #d1d5db;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem;
}

.catalog-checkbox:has(input:checked),
.objecttype-checkbox:has(input:checked),
.constellation-checkbox:has(input:checked) {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(96, 165, 250, 0.4);
}

.catalog-checkbox:has(input:checked) label,
.objecttype-checkbox:has(input:checked) label,
.constellation-checkbox:has(input:checked) label {
    color: #60a5fa;
    font-weight: 500;
}

.selected-constellations {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
    min-height: 2rem;
}

.constellation-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 9999px;
    color: #60a5fa;
    font-size: 0.75rem;
    font-weight: 500;
}

.constellation-tag button {
    background: none;
    border: none;
    color: #fca5a5;  /* Light red color for better visibility */
    cursor: pointer;
    padding: 0;
    margin-left: 0.25rem;
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1;
    transition: all 0.2s;
}

.constellation-tag button:hover {
    color: #ef4444;  /* Brighter red on hover */
    transform: scale(1.2);
}

/* Action buttons */
.filter-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Removed - using standard .btn .btn-primary and .btn-danger classes */

/* Responsive adjustments */
@media (max-width: 1024px) {
    .checkbox-group {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .objecttype-grid,
    .constellation-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .visibility-options {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .catalog-filters {
        padding: 1rem;
    }
    
    .filter-section {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }
    
    .checkbox-group {
        max-height: 200px;
        grid-template-columns: 1fr;
    }
    
    .catalog-grid,
    .objecttype-grid,
    .constellation-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .visibility-options {
        flex-direction: column;
    }
}

/* Sticky search bar: flex on mobile/collapsed, subgrid on md+ with filters */
#stickySearchBar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
@media (min-width: 768px) {
    #stickySearchBar:not(.no-subgrid) {
        display: grid;
        grid-template-columns: subgrid;
        column-gap: 1rem;
        align-items: center;
    }
}

/* Night mode for sticky search bar */
body[data-theme="night"] #stickySearchBar { background: #1a0505 !important; }

/* Hide type and constellation columns on narrow screens */
@media (max-width: 639px) {
    .compact-hide-col { display: none !important; }
    #resultsTable th:first-child,
    #resultsTable td:first-child { width: 28px; padding-left: 4px !important; padding-right: 0 !important; }
    #resultsTable .catalog-name-cell { max-width: 0; }
    #resultsTable .catalog-actions-cell { width: 152px; }
}

/* Active filter indicator */
.filter-active-indicator {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    background: #10b981;
    border-radius: 50%;
    margin-left: 0.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Tooltip for counts */
.count-tooltip {
    position: relative;
    cursor: help;
}

.count-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    right: 0;
    background: rgba(17, 24, 39, 0.95);
    color: #e5e7eb;
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10;
    margin-bottom: 0.25rem;
    border: 1px solid rgba(75, 85, 99, 0.3);
}

/* ============================================================
   NIGHT VISION MODE
   ============================================================ */

/* Main container */
body[data-theme="night"] .catalog-filters {
    background: rgba(45, 10, 10, 0.95);
    border-color: rgba(127, 29, 29, 0.4);
}

/* Section borders */
body[data-theme="night"] .filter-section {
    border-bottom-color: rgba(127, 29, 29, 0.3);
}

/* Section headers */
body[data-theme="night"] .filter-header:hover {
    color: #f87171;
}

body[data-theme="night"] .filter-title {
    color: #fca5a5;
}

body[data-theme="night"] .filter-title i {
    color: #f87171;
}

body[data-theme="night"] .filter-count {
    color: #993333;
    background: rgba(239, 68, 68, 0.1);
}

/* Search inputs */
body[data-theme="night"] .search-input {
    background: rgba(26, 5, 5, 0.5);
    border-color: rgba(127, 29, 29, 0.4);
    color: #fca5a5;
}

body[data-theme="night"] .search-input:focus {
    border-color: #ef4444;
    background: rgba(26, 5, 5, 0.8);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

body[data-theme="night"] .search-input::placeholder {
    color: #7f3333;
}

/* Scrollbars */
body[data-theme="night"] .checkbox-group::-webkit-scrollbar-track {
    background: rgba(26, 5, 5, 0.5);
}

body[data-theme="night"] .checkbox-group::-webkit-scrollbar-thumb {
    background: rgba(127, 29, 29, 0.5);
}

body[data-theme="night"] .checkbox-group::-webkit-scrollbar-thumb:hover {
    background: rgba(239, 68, 68, 0.5);
}

/* Checkbox items */
body[data-theme="night"] .checkbox-item {
    background: rgba(26, 5, 5, 0.3);
}

body[data-theme="night"] .checkbox-item:hover {
    background: rgba(26, 5, 5, 0.6);
}

body[data-theme="night"] .checkbox-item input[type="checkbox"] {
    accent-color: #ef4444;
}

body[data-theme="night"] .checkbox-label {
    color: #d4a0a0;
}

body[data-theme="night"] .checkbox-label .count {
    color: #7f3333;
}

body[data-theme="night"] .checkbox-item:has(input:checked) {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(248, 113, 113, 0.3);
}

body[data-theme="night"] .checkbox-item:has(input:checked) .checkbox-label {
    color: #f87171;
}

/* Active filter/sort buttons */
body[data-theme="night"] .btn.active,
body[data-theme="night"] [id^="const-sort-"].active {
    background: rgba(239, 68, 68, 0.3) !important;
    border-color: #f87171 !important;
    color: #f87171 !important;
}

/* Magnitude inputs */
body[data-theme="night"] .magnitude-range {
    background: rgba(26, 5, 5, 0.3);
}

body[data-theme="night"] .magnitude-input {
    background: rgba(26, 5, 5, 0.5);
    border-color: rgba(127, 29, 29, 0.4);
    color: #fca5a5;
}

body[data-theme="night"] .magnitude-input:focus {
    border-color: #ef4444;
    background: rgba(26, 5, 5, 0.8);
}

body[data-theme="night"] .magnitude-separator {
    color: #7f3333;
}

body[data-theme="night"] .mag-preset-btn {
    background: rgba(26, 5, 5, 0.5);
    border-color: rgba(127, 29, 29, 0.4);
    color: #993333;
}

body[data-theme="night"] .mag-preset-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #f87171;
    color: #fca5a5;
}

/* Visibility options (radio buttons) */
body[data-theme="night"] .visibility-option {
    background: rgba(26, 5, 5, 0.3);
}

body[data-theme="night"] .visibility-option:hover {
    background: rgba(26, 5, 5, 0.6);
}

body[data-theme="night"] .visibility-option input[type="radio"] {
    accent-color: #ef4444;
}

body[data-theme="night"] .visibility-option label {
    color: #d4a0a0;
}

body[data-theme="night"] .visibility-option:has(input:checked) {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(248, 113, 113, 0.3);
}

/* Constellation chevron */
body[data-theme="night"] .constellation-chevron {
    color: #7f3333;
}

/* Constellation search */
body[data-theme="night"] .constellation-search {
    background: rgba(26, 5, 5, 0.5);
    border-color: rgba(127, 29, 29, 0.4);
    color: #fca5a5;
}

body[data-theme="night"] .constellation-search-icon {
    color: #7f3333;
}

/* Grid checkboxes (catalog, object type, constellation) */
body[data-theme="night"] .constellation-grid {
    background: rgba(26, 5, 5, 0.2);
}

body[data-theme="night"] .catalog-checkbox,
body[data-theme="night"] .objecttype-checkbox,
body[data-theme="night"] .constellation-checkbox {
    background: rgba(26, 5, 5, 0.5);
}

body[data-theme="night"] .catalog-checkbox:hover,
body[data-theme="night"] .objecttype-checkbox:hover,
body[data-theme="night"] .constellation-checkbox:hover {
    background: rgba(26, 5, 5, 0.8);
}

body[data-theme="night"] .catalog-checkbox input[type="checkbox"],
body[data-theme="night"] .objecttype-checkbox input[type="checkbox"],
body[data-theme="night"] .constellation-checkbox input[type="checkbox"] {
    accent-color: #ef4444;
}

body[data-theme="night"] .catalog-checkbox label,
body[data-theme="night"] .objecttype-checkbox label,
body[data-theme="night"] .constellation-checkbox label {
    color: #d4a0a0;
}

body[data-theme="night"] .catalog-checkbox:has(input:checked),
body[data-theme="night"] .objecttype-checkbox:has(input:checked),
body[data-theme="night"] .constellation-checkbox:has(input:checked) {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(248, 113, 113, 0.4);
}

body[data-theme="night"] .catalog-checkbox:has(input:checked) label,
body[data-theme="night"] .objecttype-checkbox:has(input:checked) label,
body[data-theme="night"] .constellation-checkbox:has(input:checked) label {
    color: #f87171;
}

/* Group labels */
body[data-theme="night"] .objecttype-group-label {
    color: #993333;
}

/* Constellation tags */
body[data-theme="night"] .constellation-tag {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(248, 113, 113, 0.3);
    color: #f87171;
}

/* Active filter indicator (green dot → red) */
body[data-theme="night"] .filter-active-indicator {
    background: #ef4444;
}

/* Tooltips */
body[data-theme="night"] .count-tooltip:hover::after {
    background: rgba(26, 5, 5, 0.95);
    color: #fca5a5;
    border-color: rgba(127, 29, 29, 0.4);
}