body {
    background-color: #f8f9fa;
    font-size: 16px;
    margin: 0;
    padding-bottom: 100px; /* Space for footer */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand img {
    height: 40px;
    width: auto;
}

#video-player {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #000;
}

#main-section {
    height: calc(100vh - 70px - 100px); /* Adjust for navbar and footer */
    overflow: auto;
}

#channels-section {
    height: 100%;
    padding: 15px;
    overflow: hidden;
}

.channels-header {
    background: #fff;
    border-radius: 8px;
    z-index: 10;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dark-mode .channels-header {
    background: #2a2a2a;
}

.channel-stats {
    font-size: 0.9rem;
    color: #555;
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.dark-mode .channel-stats {
    color: #ccc;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
	margin: 10px;
}

.filter-btn, .resync-btn, .dark-mode-toggle, .favorites-btn, .watch-later-btn {
    font-size: 0.85rem;
    padding: 5px 15px;
    transition: all 0.3s ease;
}

.filter-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.filter-btn[data-filter="active"].active {
    background-color: #28a745;
    border-color: #28a745;
}

.filter-btn[data-filter="offline"].active {
    background-color: #dc3545;
    border-color: #dc3545;
}

.resync-btn {
    background-color: #17a2b8;
    color: white;
    border-color: #17a2b8;
}

.resync-btn:hover {
    background-color: #138496;
    border-color: #117a8b;
}

.favorites-btn {
    background-color: #ffc107;
    color: #fff;
    border-color: #ffc107;
}

.favorites-btn:hover {
    background-color: #e0a800;
    border-color: #d39e00;
}

.watch-later-btn {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

.watch-later-btn:hover {
    background-color: #0056b3;
    border-color: #004085;
}

.channels-list {
    max-height: calc(100vh - 375px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
    background-color: #adb5bd;
}

.channels-list::-webkit-scrollbar {
    width: 8px;
}

.channels-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.channels-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.dark-mode .channels-list {
    background-color: #343a40;
}

.dark-mode .channels-list::-webkit-scrollbar-track {
    background: #1f1f1f;
}

.dark-mode .channels-list::-webkit-scrollbar-thumb {
    background: #666;
}

.playlist-container {
    padding: 0 10px;
}

.category-section {
    margin-bottom: 20px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.dark-mode .category-section {
    background: #2a2a2a;
}

.category-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #ffffff, #f1f3f5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
}

.dark-mode .category-header {
    background: linear-gradient(135deg, #2a2a2a, #222);
}

.category-header:hover {
    background: linear-gradient(135deg, #f1f3f5, #e9ecef);
}

.dark-mode .category-header:hover {
    background: linear-gradient(135deg, #333, #2a2a2a);
}

.category-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}

.dark-mode .category-title {
    color: #e0e0e0;
}

.category-count {
    font-size: 0.9rem;
    color: #666;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 12px;
}

.dark-mode .category-count {
    color: #bbb;
    background: #444;
}

.toggle-btn {
    background: none;
    border: none;
    font-size: 1rem;
    color: #666;
    cursor: pointer;
    padding: 0 10px;
    transition: transform 0.3s ease;
}

.toggle-btn:hover {
    transform: scale(1.1);
}

.dark-mode .toggle-btn {
    color: #bbb;
}

.channel-list {
    padding: 15px;
    transition: height 0.3s ease;
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-width, 280px), 1fr));
    gap: 15px;
}

.list-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.channel-list.collapsed {
    height: 0;
    padding: 0;
    overflow: hidden;
}

.channel-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
}

.dark-mode .channel-card {
    background: #333;
    border-color: #444;
}

.channel-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
}

.dark-mode .channel-card:hover {
    background: #3a3a3a;
}

.channel-content {
    display: flex;
    align-items: center;
    padding: 12px;
}

.channel-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 4px;
    margin-right: 15px;
    transition: transform 0.3s ease;
    background: #eee; /* Fallback background for broken images */
}

.channel-card:hover .channel-icon {
    transform: scale(1.05);
}

.channel-info {
    flex: 1;
    min-width: 0;
}

.channel-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark-mode .channel-name {
    color: #e0e0e0;
}

.channel-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active { background: #28a745; }
.status-dot.offline { background: #dc3545; }
.status-dot.unknown { background: #ffc107; }
.status-dot.api { background: #007bff; }

.status-text {
    font-size: 0.85rem;
    color: #666;
}

.dark-mode .status-text {
    color: #bbb;
}

.channel-actions {
    display: flex;
    gap: 5px;
}

.fav-btn, .watch-later-btn, .share-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    padding: 5px;
    cursor: pointer;
    color: #ccc;
    transition: color 0.3s ease;
}

.fav-btn.active { color: #ff4444; }
.watch-later-btn.active { color: #007bff; }
.fav-btn:hover, .watch-later-btn:hover, .share-btn:hover { color: #666; }
.dark-mode .fav-btn, .dark-mode .watch-later-btn, .dark-mode .share-btn { color: #999; }
.dark-mode .fav-btn:hover, .dark-mode .watch-later-btn:hover, .dark-mode .share-btn:hover { color: #ccc; }

.modal-fullscreen .modal-dialog {
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    margin: 0;
}

.modal-fullscreen .modal-content {
    height: 100vh;
    border: none;
    border-radius: 0;
    overflow: hidden;
    position: relative;
}

.modal-fullscreen .modal-header {
    flex-shrink: 0;
    padding: 10px;
    border-bottom: none;
}

.modal-fullscreen .modal-body {
    flex: 1;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.video-container {
    flex: 1;
    width: 100%;
    max-height: calc(100vh - 60px);
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    position: relative;
}

.playback-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-container:hover .playback-controls,
.video-container.active .playback-controls {
    opacity: 1;
}

.pip-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
}

.pip-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.epg-container {
    flex-shrink: 0;
    max-height: 40vh;
    overflow-y: auto;
    padding: 10px;
    display: none;
}

.epg-entry {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 1050;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    border: 2px solid #ccc;
    font-size: 1.4rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 1;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.close-btn:hover {
    background: #fff;
    color: #dc3545;
    border-color: #dc3545;
    transform: rotate(90deg);
}

.dark-mode .close-btn {
    background: rgba(80, 80, 80, 0.95);
    color: #fff;
    border-color: #888;
}

.dark-mode .close-btn:hover {
    background: #666;
    border-color: #dc3545;
}

.video-container:hover .close-btn,
.video-container.active .close-btn {
    opacity: 1;
}

.player-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    z-index: 999;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: fadeInOut 3s ease-in-out;
    display: none;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; }
}

#back-to-categories {
    display: none;
    margin-bottom: 15px;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.user-profile-selection {
    padding: 20px;
    text-align: center;
}

.profile-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.profile-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dark-mode .profile-item {
    background: #333;
}

.theme-blue {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
}

.theme-green {
    --primary-color: #28a745;
    --secondary-color: #17a2b8;
}

.theme-default {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
}

.theme-blue .navbar, .theme-green .navbar {
    background-color: var(--primary-color) !important;
}

.theme-blue .category-header, .theme-green .category-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.theme-blue .category-header:hover, .theme-green .category-header:hover {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
}

/* Footer Styles */
.footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: #f1f3f5;
    padding: 10px 0;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.dark-mode .footer {
    background: #222;
    color: #ccc;
}

.credit {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.dark-mode .credit {
    color: #bbb;
}

.disclaimer {
    margin: 5px 0 0;
    font-size: 0.75rem;
    color: #888;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.dark-mode .disclaimer {
    color: #999;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .navbar-brand img { height: 30px; }
    .btn { font-size: 0.9rem; padding: 0.5rem 1rem; }
    .channel-icon { width: 40px; height: 40px; }
    .grid-layout { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .epg-container { max-height: 30vh; }
    .filter-buttons { flex-wrap: wrap; }
    .channels-list { max-height: calc(100vh - 300px); }
    .modal-dialog { max-width: 100%; margin: 0; }
    .footer { padding: 8px 0; }
    .credit { font-size: 0.85rem; }
    .disclaimer { font-size: 0.7rem; }
}

@media (max-width: 576px) {
    .navbar-nav { text-align: center; flex-direction: column; gap: 10px; }
    .grid-layout { grid-template-columns: 1fr; }
    .channel-content { flex-direction: column; align-items: flex-start; }
    .channel-icon { width: 35px; height: 35px; margin: 0 0 10px 0; }
    .channel-status { width: 100%; justify-content: space-between; }
    .channel-actions { width: 100%; justify-content: space-around; }
    .channels-header { padding: 10px; }
    .channel-stats { font-size: 0.8rem; gap: 8px; }
    .channels-list { max-height: calc(100vh - 280px); }
    .modal-fullscreen .modal-body { padding: 0; }
    .video-container { max-height: calc(100vh - 50px); }
    .playback-controls { bottom: 10px; }
    .close-btn { width: 35px; height: 35px; font-size: 1.2rem; top: 10px; right: 10px; }
    .settingsModal .modal-dialog { max-width: 95%; }
    .footer { padding: 5px 0; }
    .credit { font-size: 0.8rem; }
    .disclaimer { font-size: 0.65rem; max-width: 95%; }
}