/* Channel Grid Layout */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(12vw, 15vw, 18vw), 1fr));
    gap: 1.04vw;
    padding: 1.04vw;
    width: 100%;
    overflow-y: auto;
    max-height: calc(100vh - 23.15vh); /* Adjusted for responsive header/filters */
}

/* Fixed column classes replaced by responsive auto-fill grid
.channel-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.channel-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.channel-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.channel-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
.channel-grid.cols-7 { grid-template-columns: repeat(7, 1fr); }
*/

/* Channel Card */
.channel-card {
    width: 100%;
    height: 16.67vh;
    background-color: #1a1a1a;
    border-radius: 0.625vw;
    position: relative;
    overflow: hidden;
    border: 0.16vw solid transparent;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.channel-card.focused {
    border-color: #2196F3;
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 0 0.78vw rgba(33, 150, 243, 0.4);
    background-color: #2a2a2a;
}

.channel-logo-container {
    height: 11.11vh;
    width: 100%;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.52vw;
}

.channel-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.channel-info {
    padding: 0.52vw;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.channel-name {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-group {
    font-size: 0.75rem;
    color: #B0B0B0;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badges */
.channel-badges {
    position: absolute;
    top: 0.46vh;
    right: 0.26vw;
    display: flex;
    gap: 0.26vw;
    z-index: 2;
}

.badge-hd {
    background-color: #2196F3;
    color: white;
    font-size: 0.625rem;
    font-weight: bold;
    padding: 0.19vh 0.31vw;
    border-radius: 0.21vw;
}

.badge-num {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 0.19vh 0.31vw;
    border-radius: 0.21vw;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Favorites Badge */
.badge-favorite {
    position: absolute;
    top: 0.93vh;
    left: 0.52vw;
    font-size: 1.375rem;
    cursor: pointer;
    z-index: 5;
    transition: transform 0.2s;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.badge-favorite:hover {
    transform: scale(1.2);
}

.badge-favorite.filled {
    color: #FFD700;
}

.badge-favorite.empty {
    color: #B0B0B0;
}

/* Search Bar */
.search-container {
    display: flex;
    align-items: center;
    margin-bottom: 1.85vh;
    padding: 0 1.04vw;
}

.search-bar {
    background-color: #2a2a2a;
    border: 0.1vw solid #424242;
    border-radius: 0.42vw;
    padding: 0.52vw 1.04vw;
    color: #fff;
    font-size: 1.125rem;
    width: 20.83vw;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.search-bar.focused {
    border-color: #2196F3;
    background-color: #3a3a3a;
}

.search-icon {
    margin-right: 0.52vw;
    color: #B0B0B0;
}

/* Group Filter */
.group-filter-container {
    display: flex;
    overflow-x: auto;
    padding: 0.93vh 1.04vw;
    margin-bottom: 0.93vh;
    white-space: nowrap;
    scrollbar-width: none; /* Firefox */
    align-items: center;
    min-height: 4.5vh;
}

.group-filter-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.group-btn {
    padding: 0.74vh 1.04vw;
    margin-right: 0.78vw;
    background-color: #2a2a2a;
    border-radius: 1.04vw;
    color: #B0B0B0;
    font-size: 1rem;
    border: 0.1vw solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.group-btn.active {
    background-color: #E50914;
    color: white;
}

.group-btn.focused {
    border-color: #E50914;
    background-color: #3a3a3a;
    color: white;
}

.group-btn.active.focused {
    background-color: #E50914;
    border-color: white;
}

.group-btn .badge {
    display: inline-block;
    margin-left: 0.52vw;
    padding: 0.19vh 0.52vw;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 0.52vw;
    font-size: 0.875rem;
    font-weight: bold;
}

.group-btn.active .badge {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Sorting Container */
.sort-container {
    display: flex;
    align-items: center;
    gap: 0.52vw;
    margin-left: 1.04vw;
}

.sort-btn {
    padding: 0.74vh 0.83vw;
    background-color: #2a2a2a;
    border: 0.1vw solid #424242;
    border-radius: 0.42vw;
    color: #B0B0B0;
    font-size: 0.875rem;
    cursor: pointer;
}

.sort-btn.active {
    background-color: #2196F3;
    color: white;
    border-color: #2196F3;
}

.sort-btn.focused {
    border-color: #2196F3;
    background-color: #3a3a3a;
}

/* Playlist List Styles */
.playlist-list {
    display: flex;
    flex-direction: column;
    gap: 0.78vw;
    padding: 1.04vw;
}

.playlist-item {
    background-color: #1a1a1a;
    border-radius: 0.42vw;
    padding: 1.04vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 0.1vw solid transparent;
}

.playlist-item.focused {
    border-color: #2196F3;
    background-color: #2a2a2a;
}

.playlist-info h3 {
    margin-bottom: 5px;
    color: #fff;
}

.playlist-meta {
    color: #B0B0B0;
    font-size: 0.875rem;
    margin-bottom: 0.46vh;
}

.playlist-actions {
    display: flex;
    gap: 0.52vw;
}

/* Modal Styles override/addition */
.form-group {
    margin-bottom: 1.85vh;
    text-align: left;
}

.form-label {
    display: block;
    margin-bottom: 0.74vh;
    color: #B0B0B0;
}

.form-input {
    width: 100%;
    padding: 0.625vw;
    background-color: #2a2a2a;
    border: 0.1vw solid #424242;
    border-radius: 0.42vw;
    color: white;
    font-size: 1rem;
}

.form-input.focused {
    border-color: #2196F3;
    outline: none;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.04vw;
    padding: 1.04vw;
    margin-top: 1.85vh;
    color: #fff;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 2.6vw;
    color: #B0B0B0;
    font-size: 1.25rem;
    grid-column: 1 / -1;
}

/* Media Queries for Channel Grid Density */

/* 720p TVs - Fewer columns */
@media screen and (max-width: 1280px) and (max-height: 720px) {
    .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(18vw, 1fr));
        gap: 1.2vw;
    }
    
    .channel-card {
        height: 18vh;
    }
    
    .channel-logo-container {
        height: 12vh;
    }
    
    .search-bar {
        width: 25vw;
    }
}

/* 1080p TVs - Default */
@media screen and (min-width: 1281px) and (max-width: 1920px) {
    .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(15vw, 1fr));
    }
}

/* 4K TVs - More columns */
@media screen and (min-width: 1921px) {
    .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(12vw, 1fr));
        gap: 0.9vw;
    }
    
    .channel-card {
        height: 15vh;
    }
    
    .channel-logo-container {
        height: 10vh;
    }
    
    .search-bar {
        width: 18vw;
    }
    
    .badge-favorite {
        font-size: 1.2rem;
    }
}
