:root {
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --primary-variant-color: #3700b3;
    --secondary-color: #03dac6;
    --on-background-color: #ffffff;
    --on-surface-color: #e0e0e0;
    --border-color: #2c2c2c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--on-background-color);
    line-height: 1.6;
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background-color: var(--surface-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease;
    overflow: hidden;
    height: 100%;
}

.sidebar-header {
    padding: 15px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-container {
    display: flex;
    align-items: center;
    overflow: hidden;
    flex-grow: 1;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    margin-right: 10px;
}

.sidebar-title {
    font-size: 1.2rem;
    white-space: nowrap;
}

.language-switcher-container {
    position: relative;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--on-surface-color);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px;
    z-index: 20;
    min-width: 100px;
}

.language-option {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
}

.language-option:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.language-option.active {
    background-color: var(--primary-variant-color);
    font-weight: bold;
}

.top-right-controls {
    position: absolute;
    top: 15px;
    left: 280px;
    transform: translateX(-100%);
    padding-right: 15px;
    z-index: 20;
    display: flex;
    gap: 5px;
    transition: left 0.3s ease;
}

.collapse-btn {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--on-surface-color);
    cursor: pointer;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.icon-btn i {
    width: 20px;
    height: 20px;
}

.collapse-btn i {
    transition: transform 0.3s ease;
}

.filter-container {
    padding: 10px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    width: 90%;
    /* Control the overall width */
    margin: 0 auto;
    /* Center it */
}

.filter-btn {
    background-color: transparent;
    color: var(--on-surface-color);
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
    font-size: 0.8rem;
    white-space: nowrap;
    text-align: center;
    position: relative;
}

/* Create grid lines */
.filter-btn:nth-child(1),
.filter-btn:nth-child(2) {
    border-bottom: 1px solid var(--border-color);
}

.filter-btn:nth-child(1),
.filter-btn:nth-child(3) {
    border-right: 1px solid var(--border-color);
}

.filter-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: var(--background-color);
}

.secondary-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    gap: 10px;
}

.secondary-header h2 {
    margin: 0;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.secondary-header.search-active h2 {
    display: none;
}

.search-wrapper {
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.search-input {
    width: 100%;
    padding: 4px 8px;
    border: none;
    border-bottom: 1px solid var(--primary-color);
    background-color: transparent;
    color: var(--on-surface-color);
    outline: none;
    flex-grow: 1;
}

#list-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

#list-container.loading {
    display: flex;
    justify-content: center;
    align-items: center;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 12px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item .list-item-text {
    margin-left: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.3s ease;
    flex-grow: 1;
}

.favorite-btn {
    background: none;
    border: none;
    color: var(--on-surface-color);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    flex-shrink: 0;
}

.favorite-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.favorite-btn .lucide-star {
    color: #f0ad4e;
    /* A nice yellow for the star */
}

.favorite-btn .lucide-star.favorited {
    fill: #f0ad4e;
}

.list-item i:empty {
    display: none;
}

.list-item i:empty+.list-item-text {
    margin-left: 0;
}

.list-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.list-item.active {
    background-color: var(--primary-variant-color);
    font-weight: bold;
}

.list-item i,
.list-item .flag-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.list-item .flag-icon {
    border-radius: 2px;
}

/* Collapsed state */
body.sidebar-collapsed .sidebar {
    width: 0;
}

body:not(.sidebar-collapsed) .top-right-controls {
    /* No change needed here, left is calculated */
}

body.sidebar-collapsed .top-right-controls {
    left: 0;
    transform: translateX(15px);
}

body.sidebar-collapsed .collapse-btn {
    transform: rotate(180deg);
}

body.sidebar-collapsed .top-right-controls {
    left: 15px;
    transform: translateX(0);
}

body.sidebar-collapsed #language-switcher-container {
    display: none;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #000;
}

.video-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#video-player {
    width: 100%;
    height: 100%;
    background-color: #000;
}

.player-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--on-surface-color);
    height: 100%;
    width: 100%;
}

.placeholder-logo {
    width: 128px;
    height: 128px;
    margin-bottom: 20px;
}

.placeholder-text {
    font-size: 1.2rem;
}

.hidden {
    display: none;
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-color);
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 900;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
}

/* Overlay for modal-like sidebar */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#overlay.show {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    /* --- Portrait Mode --- */
    @media (orientation: portrait) {
        #sidebar {
            position: fixed;
            left: 0;
            top: 0;
            height: 100%;
            width: 85vw;
            max-width: 320px;
            transform: translateX(-100%);
            transition: transform 0.3s ease;
            z-index: 1000;
        }

        #sidebar.show {
            transform: translateX(0);
        }

        .main-content {
            margin-left: 0;
        }

        .top-right-controls {
            display: none;
        }

        .mobile-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
    }

    /* --- Landscape Mode (Option B) --- */
    @media (orientation: landscape) {
        .mobile-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        #sidebar {
            position: fixed;
            left: 0;
            top: 0;
            height: 100%;
            width: 40vw;
            /* Smaller width for landscape */
            max-width: 280px;
            transform: translateX(-100%);
            transition: transform 0.3s ease;
            z-index: 1000;
        }

        #sidebar.show {
            transform: translateX(0);
        }

        .main-content {
            margin-left: 0;
        }

        .top-right-controls {
            display: none;
        }
    }
}

/* Helper class to hide elements on desktop */
@media (min-width: 769px) {
    .hidden-desktop {
        display: none;
    }
}