.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: -16px;
    z-index: 500;
    background: var(--bg-main);
    padding: 16px 0 0;
    margin-top: -16px;
}

.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 8px 4px 12px;
    min-height: 25px;
    position: sticky;
    top: 42px;
    z-index: 490;
    background: var(--bg-main);
    border-bottom: 1px solid transparent;
}

.results-info:not(:empty) {
    border-color: var(--border);
    margin-bottom: 8px;
}

.results-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #eff6ff;
    color: var(--primary);
    border: 1px solid #dbeafe;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.filter-badge:hover {
    background: #dbeafe;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.badge-label {
    opacity: 0.5;
    font-weight: 500;
}

.remove-filter {
    cursor: pointer;
    width: 14px;
    height: 14px;
    opacity: 0.6;
    transition: all 0.2s;
    margin-left: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.remove-filter:hover {
    opacity: 1;
    color: var(--red);
    background: rgba(239, 68, 68, 0.1);
}

.remove-filter svg,
.remove-filter i {
    width: 14px !important;
    height: 14px !important;
    stroke-width: 2.5px;
}

.results-count {
    color: var(--primary);
    font-weight: 700;
}

.search-box {
    position: relative;
    flex: 1;
}

.search-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.table-filter {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.table-filter:hover {
    border-color: var(--primary);
}

.table-filter-container {
    position: relative;
    width: 200px;
}

.custom-multiselect {
    position: relative;
    width: 100%;
}

.multiselect-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 42px;
    padding: 0 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.multiselect-trigger:hover {
    border-color: var(--primary);
}

.multiselect-trigger i {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.multiselect-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    max-height: 300px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow-y: auto;
    display: none;
    padding: 8px;
}

.multiselect-search-container {
    padding: 8px;
    margin-bottom: 4px;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-bottom: 1px solid var(--border);
}

.multiselect-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.multiselect-search:focus {
    border-color: var(--primary);
}

.genre-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.85rem;
}

.genre-option .option-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.genre-option .option-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.genre-option:has(input:checked) .option-count {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.custom-multiselect.active .multiselect-options {
    display: block;
    animation: slideDown 0.2s cubic-bezier(0, 0, 0.2, 1);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.genre-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.85rem;
}

.genre-option:hover {
    background: #f1f5f9;
}

.genre-option.hidden {
    display: none;
}

.genre-option:has(input:checked) {
    background: #eef2ff;
    color: var(--primary);
    font-weight: 600;
}

.genre-option input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.clear-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.clear-btn:hover {
    background: #fecaca;
    transform: translateY(-1px);
}

.clear-btn i {
    width: 16px;
    height: 16px;
}

/* Base Table */
.table-wrapper {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    /* overflow: hidden; */
    /* Removed to allow poster images to scale out of the container on hover */
    box-shadow: var(--shadow);
    position: relative;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

/* Maintain rounded corners for the table since overflow: hidden is gone */
th:first-child {
    border-top-left-radius: 16px;
}

th:last-child {
    border-top-right-radius: 16px;
}

.poster-cell {
    width: 60px;
}

.poster-cell:hover {
    position: relative;
    z-index: 2000;
}

th {
    background: #f8fafc;
    padding: 12px 16px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 83px;
    /* Default sticky top */
    z-index: 480;
    transition: top 0.2s ease;
}

/* Push table headers further down when filter badges are active and growing the height */
.results-info:has(.filter-badge)~.table-wrapper thead th {
    top: 109px;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    /* position: relative; */
    /* Removed to allow position: sticky from parent th to work */
    white-space: nowrap;
}

th.sortable:hover {
    background: #f1f5f9;
    color: var(--primary);
}

th.sortable.active-sort {
    background: #eff6ff;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

th.sortable i,
th.sortable svg {
    width: 14px;
    height: 14px;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0;
    transition: all 0.2s;
    color: var(--primary);
}

th.sortable:hover i,
th.sortable:hover svg {
    opacity: 0.4;
}

th.sortable.active-sort i,
th.sortable.active-sort svg {
    opacity: 1;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}


.poster-img {
    width: 44px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    background: #f1f5f9;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, z-index 0s;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1;
}

.poster-cell:hover .poster-img {
    transform: translateX(110%) scale(4);
    transform-origin: left center;
    z-index: 2000;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    border-color: var(--primary);
    transition-delay: 0.1s;
}

/* Service Icons & Badges */
.service-icon-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.service-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    object-fit: cover;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: help;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.service-icon:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.service-badge-fallback {
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-main);
    background: #f1f5f9;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.service-badge.service-na {
    background: #fff1f2;
    color: var(--red);
    border: 1px solid #fecdd3;
    opacity: 0.8;
}


.badge {
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f1f5f9;
}

.badge.scanning {
    background: #e0f2fe;
    color: var(--blue);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 16px 24px;
    background: white;
    border-top: 1px solid var(--border);
    border-radius: 0 0 16px 16px;
    position: relative;
    /* Ensure it stays above/below based on order */
    z-index: 2;
}

#page-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Table Responsive */
@media (max-width: 1024px) {
    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filters {
        justify-content: flex-start;
    }
}