/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #161819;
    color: #ffffff;
    line-height: 1.6;
}


/* Main Content */
.main-content {
    padding: 2rem 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

/* Filters Sidebar */
.filters-sidebar {
    background-color: #1f2022;
    border-radius: 0;
    padding: 0;
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    width: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: left 0.3s ease;
    z-index: 2000;
}

/* Logo général */
.logo {
    width: 100%;
    height: auto;
    display: block;
}

.sidebar-logo {
    display: none;
}

/* Logo mobile en haut de la page */
@media (max-width: 767px) {
    .sidebar-logo {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 1rem;
        background-color: #1f2022;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1500;
        border: none;
        width: 100%;
    }

    .logo {
        width: 100px;
        height: auto;
    }

    /* Ajoute un espace en haut pour le logo fixe */
    .main-content {
        padding-top: 8rem;
    }
}

/* Logo dans la sidebar sur desktop */
@media (min-width: 768px) and (max-width: 1919px) {
    .filters-sidebar {
        border-radius: 8px;
    }

    .sidebar-logo {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid #2a2a2a;
        background-color: #1f2022;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .logo {
        width: 100%;
        max-width: 100%;
        height: auto;
    }
}

.filters-sidebar.active {
    left: 0;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1.5rem 1.5rem 0 1.5rem;
}

.filters-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.clear-filters {
    background: none;
    border: none;
    color: #2490FF;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: underline;
}

.clear-filters:hover {
    color: #1a7acc;
}

.filter-group {
    margin-bottom: 1.5rem;
    padding: 0 1.5rem;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: #b0b0b0;
}

.sort-select {
    width: 100%;
    padding: 0.75rem;
    background-color: #2a2a2a;
    color: #ffffff;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
}

.filter-category {
    margin-bottom: 1rem;
    border-bottom: 1px solid #2a2a2a;
    padding: 0 1.5rem 1rem 1.5rem;
}

.filter-category-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 0.75rem 0;
    font-size: 0.95rem;
    font-weight: 500;
}

.filter-category-toggle .chevron {
    transition: transform 0.3s ease;
}

.filter-category-toggle.active .chevron {
    transform: rotate(180deg);
}

.filter-options {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 0.75rem;
}

.filter-category-toggle.active + .filter-options {
    display: flex;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #d0d0d0;
}

.filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2490FF;
}

.filter-option:hover span {
    color: #ffffff;
}

.mobile-view-results {
    width: calc(100% - 3rem);
    margin: 1.5rem 1.5rem;
    padding: 0.875rem;
    background-color: #2490FF;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.mobile-view-results:hover {
    background-color: #1a7acc;
}

/* Programs Section */
.programs-section {
    width: 100%;
}

.programs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Search Bar */
.search-bar {
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background-color: #2a2a2a;
    color: #ffffff;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #2490FF;
}

.search-input::placeholder {
    color: #808080;
}

.programs-header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.mobile-filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: #2a2a2a;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.3s ease;
}

.mobile-filter-toggle:hover {
    background-color: #3a3a3a;
}

/* Active Filters */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: #2a2a2a;
    border-radius: 20px;
    font-size: 0.875rem;
}

.active-filter-tag button {
    background: none;
    border: none;
    color: #b0b0b0;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
}

.active-filter-tag button:hover {
    color: #ffffff;
}

/* Programs Grid */
.programs-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.program-card {
    background-color: #1f2022;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
    cursor: pointer;
}

.program-card:hover {
    transform: translateY(-4px);
    opacity: 0.9;
}

.program-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: linear-gradient(135deg, #2490FF 0%, #1a7acc 100%);
    position: relative;
}

.program-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.program-image .placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.3);
}

.program-tags {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    gap: 0.5rem;
}

.program-tag {
    padding: 0.25rem 0.75rem;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.program-tag.new {
    background-color: #1BCD7B;
    color: #000000;
}

.program-tag.unavailable {
    background-color: #FF4444;
    color: #FFFFFF;
}

.program-content {
    padding: 1.5rem;
}

.program-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.program-description {
    color: #b0b0b0;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.program-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #808080;
    line-height: 1.3;
}

.program-meta-item {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    white-space: nowrap;
}

/* Responsive Design */
@media (min-width: 768px) and (max-width: 1919px) {
    .programs-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mobile-filter-toggle {
        display: none;
    }

    .menu-toggle {
        display: none;
    }

    .main-nav {
        display: flex;
    }

    .filters-sidebar {
        position: static;
        width: auto;
        left: auto;
    }

    .container {
        grid-template-columns: 280px 1fr;
    }

    .mobile-view-results {
        display: none;
    }
}

@media (min-width: 1024px) and (max-width: 1919px) {
    .programs-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .programs-header h1 {
        font-size: 2.5rem;
    }
}

/* Overlay for mobile filters */
.filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1999;
}

.filter-overlay.active {
    display: block;
}

/* Scrollbar Styling */
.filters-sidebar::-webkit-scrollbar {
    width: 8px;
}

.filters-sidebar::-webkit-scrollbar-track {
    background: #1f2022;
}

.filters-sidebar::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

.filters-sidebar::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Program Action Buttons */
.program-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #2a2a2a;
}

.program-action-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-documents {
    background-color: #2490FF;
    color: #ffffff;
}

.btn-documents:hover {
    background-color: #1a7acc;
    transform: translateY(-2px);
}

.btn-plex {
    background-color: #E5A00D;
    color: #000000;
    border: none;
}

.btn-plex:hover {
    background-color: #CC8F0B;
    transform: translateY(-2px);
}

/* PDF Modal */
.pdf-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    padding: 1rem;
    overflow-y: auto;
}

.pdf-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-modal-content {
    background-color: #1f2022;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pdf-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pdf-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
}

.pdf-modal-close {
    background: none;
    border: none;
    color: #b0b0b0;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.pdf-modal-close:hover {
    background-color: #2a2a2a;
    color: #ffffff;
}

.pdf-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.pdf-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pdf-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: #2a2a2a;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: #ffffff;
}

.pdf-item:hover {
    background-color: #3a3a3a;
    transform: translateX(4px);
}

.pdf-icon {
    width: 40px;
    height: 40px;
    background-color: #2490FF;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.pdf-info {
    flex: 1;
    min-width: 0;
}

.pdf-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.pdf-size {
    font-size: 0.75rem;
    color: #808080;
}

.pdf-loading {
    text-align: center;
    padding: 2rem;
    color: #808080;
}

.pdf-empty {
    text-align: center;
    padding: 2rem;
    color: #808080;
}

.pdf-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

@media (max-width: 768px) {
    .program-actions {
        flex-direction: column;
    }

    .pdf-modal-content {
        max-height: 95vh;
    }
}

/* TV Mode Styles */
.tv-mode {
    cursor: none;
}

.tv-mode * {
    cursor: none !important;
}

.tv-mode .sidebar-logo {
    padding: 1.25rem;
}

.tv-mode .logo {
    width: 100%;
    max-width: 100%;
}

/* Focus visible pour navigation télécommande */
.tv-focused {
    outline: 4px solid #2490FF !important;
    outline-offset: 4px;
    box-shadow: 0 0 20px rgba(36, 144, 255, 0.6) !important;
    transform: scale(1.05);
    z-index: 100;
    position: relative;
}

/* Ajuste la taille des textes pour TV */
.tv-mode .program-title {
    font-size: 1rem;
}

.tv-mode .program-description {
    font-size: 0.75rem;
    line-height: 1.4;
}

.tv-mode .program-meta {
    font-size: 0.7rem;
}

/* Boutons pour TV */
.tv-mode button,
.tv-mode .program-action-btn {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    min-height: 42px;
}

.tv-mode .pdf-name {
    font-size: 0.9rem;
}

.tv-mode .sidebar-logo img {
    max-width: 140px;
}

/* Améliore la visibilité des cartes de programmes */
.tv-mode .program-card {
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.tv-mode .program-card.tv-focused {
    border-color: #2490FF;
}

/* Modal optimisé pour TV */
.tv-mode .pdf-modal {
    z-index: 9999 !important;
}

.tv-mode .pdf-modal.active {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.tv-mode .pdf-modal.active .pdf-modal-content {
    display: flex !important;
    flex-direction: column !important;
    max-width: 80vw !important;
    max-height: 85vh !important;
    background-color: #1f2022 !important;
    border-radius: 12px !important;
    overflow-y: auto !important;
    width: 100%;
}

.tv-mode .pdf-modal-header {
    padding: 1.5rem;
}

.tv-mode .pdf-modal-header h2 {
    font-size: 1.5rem;
}

.tv-mode .pdf-modal-close {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
}

.tv-mode .pdf-item {
    padding: 1.25rem;
    font-size: 1rem;
}

/* Focus pour les inputs */
.tv-mode input:focus,
.tv-mode select:focus {
    outline: 4px solid #2490FF;
    outline-offset: 2px;
}

/* Styles spécifiques pour le mode TV */
.tv-mode .container {
    grid-template-columns: 200px 1fr;
    max-width: 99%;
    padding: 0.75rem;
}

.tv-mode .filters-sidebar {
    position: static;
    transform: none !important;
    width: 200px;
    border-radius: 8px;
    padding: 0.5rem;
}

.tv-mode .filters-header {
    padding: 0.5rem;
    margin-bottom: 0.75rem;
}

.tv-mode .filters-header h2 {
    font-size: 1rem;
}

.tv-mode .clear-filters {
    font-size: 0.75rem;
}

.tv-mode .mobile-filter-toggle,
.tv-mode .mobile-view-results {
    display: none;
}

/* Ajuste les tailles de texte pour TV */
.tv-mode h1 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
}

.tv-mode .search-input {
    font-size: 0.8rem;
    padding: 0.5rem 0.7rem;
}

.tv-mode .filter-section h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.tv-mode .filter-option label {
    font-size: 0.75rem;
}

.tv-mode .sort-select {
    font-size: 0.75rem;
    padding: 0.4rem;
}

/* Optimisations spécifiques pour mode TV uniquement */
.tv-mode .programs-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.tv-mode .program-card {
    border-radius: 10px;
}

.tv-mode .program-image {
    height: 220px;
}

.tv-mode .program-content {
    padding: 0.85rem;
}

.tv-mode .program-actions {
    gap: 0.6rem;
    margin-top: 0.85rem;
}

.tv-mode .program-action-btn {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.tv-mode .badge {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.tv-mode .tv-focused {
    outline: 6px solid #2490FF !important;
    outline-offset: 6px;
    box-shadow: 0 0 30px rgba(36, 144, 255, 0.8) !important;
    transform: scale(1.05);
}

.tv-mode .active-filters {
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tv-mode .filter-tag {
    font-size: 1rem;
    padding: 0.75rem 1.25rem;
}

/* Cartes cliquables */
.program-card[style*="cursor: pointer"]:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(36, 144, 255, 0.3);
}

/* Program Detail Page */
.program-detail-view {
    width: 100%;
    min-height: 100vh;
    background: #1a1a1a;
    position: relative;
}

.program-detail-back {
    position: absolute;
    top: 2rem;
    left: 2rem;
    background: rgba(42, 42, 42, 0.9);
    backdrop-filter: blur(10px);
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.program-detail-back:hover {
    background: rgba(58, 58, 58, 0.95);
    transform: translateX(-4px);
}

.program-detail-hero {
    width: 100%;
    min-height: 60vh;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: flex-end;
    padding: 3rem;
    position: relative;
}

.program-detail-hero-content {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.program-detail-title {
    font-size: 3.5rem;
    color: #fff;
    margin: 0 0 1rem 0;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    font-weight: 700;
}

.program-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.program-detail-meta-item {
    background: rgba(42, 42, 42, 0.9);
    backdrop-filter: blur(10px);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
}

.program-detail-body {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem;
}

.program-detail-description {
    color: #d0d0d0;
    font-size: 1.2rem;
    line-height: 1.8;
    margin: 0 0 2.5rem 0;
}

.program-detail-actions {
    display: flex;
    gap: 1.5rem;
    max-width: 600px;
}

.program-detail-btn {
    flex: 1;
    padding: 1.25rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.program-detail-btn.btn-documents {
    background: #2490FF;
    color: white;
}

.program-detail-btn.btn-documents:hover {
    background: #1a7dd9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(36, 144, 255, 0.5);
}

.program-detail-btn.btn-plex {
    background: #e5a00d;
    color: white;
}

.program-detail-btn.btn-plex:hover {
    background: #cc8f0b;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229, 160, 13, 0.5);
}

/* Responsive pour mobile */
@media (max-width: 768px) {
    .program-detail-back {
        top: 1rem;
        left: 1rem;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .program-detail-hero {
        min-height: 50vh;
        padding: 2rem 1.5rem;
    }

    .program-detail-title {
        font-size: 2rem;
    }

    .program-detail-meta-item {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
    }

    .program-detail-body {
        padding: 2rem 1.5rem;
    }

    .program-detail-description {
        font-size: 1rem;
    }

    .program-detail-actions {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Optimisations pour TV */
.tv-mode .program-detail-back {
    top: 1.5rem;
    left: 1.5rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
}

.tv-mode .program-detail-hero {
    min-height: 55vh;
    padding: 2.5rem 1.5rem;
}

.tv-mode .program-detail-title {
    font-size: 2.5rem;
}

.tv-mode .program-detail-meta-item {
    font-size: 0.9rem;
    padding: 0.65rem 1.1rem;
}

.tv-mode .program-detail-body {
    padding: 2.5rem 1.5rem;
}

.tv-mode .program-detail-description {
    font-size: 1.05rem;
    line-height: 1.6;
}

.tv-mode .program-detail-btn {
    padding: 1rem 1.75rem;
    font-size: 1rem;
}

/* Ensure detail view spans the full grid (not stuck in the sidebar column) */
.program-detail-view {
    grid-column: 1 / -1;
    z-index: 1000;
}
