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

body {
    font-family: 'Roboto', Arial, sans-serif;
    background: #0f0f0f;
    color: #f1f1f1;
}

.container { max-width: 1400px; margin: 0 auto; padding: 20px; }

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}
header a { color: #3ea6ff; text-decoration: none; margin-left: 15px; }

a {
    color: #ffffff;
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

a:hover {
    color: ffffff;
    text-decoration: underline;
}

a:active {
    opacity: 0.7;
}

a:visited {
    color: #ffffff;
}

.btn { background: #ff0000; color: white !important; padding: 8px 14px; border-radius: 4px; }

.layout { display: flex; gap: 20px; }
.sidebar { width: 260px; flex-shrink: 0; }
.channel-list { list-style: none; margin-top: 10px; }
.channel-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px; border-bottom: 1px solid #222; font-size: 14px;
}
.remove { color: #f44 !important; text-decoration: none; }

.videos { flex: 1; }
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Vidéo card (fusion des deux blocs dupliqués) */
.video-card {
    position: relative;
    background: #1c1c1c;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s;
}
.video-card:hover { transform: scale(1.02); }
.video-card img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }

.video-info { padding: 10px; }
.video-title { font-size: 14px; font-weight: 500; margin-bottom: 5px; line-height: 1.3; }
.video-channel { font-size: 12px; color: #aaa; }
.video-date { font-size: 12px; color: #888; margin-top: 3px; }

.video-card.viewed {
    opacity: 0.55;
}
.video-card.viewed .video-title {
    color: #999;
}

.video-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.thumbnail-wrap {
    position: relative;
}
.thumbnail-wrap img {
    width: 100%;
    display: block;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.badge-new {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #ff0000;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.toggle-viewed-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}
.toggle-viewed-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.auth-box {
    max-width: 350px; margin: 100px auto; background: #1c1c1c;
    padding: 30px; border-radius: 8px;
}
.auth-box input {
    width: 100%; padding: 10px; margin-bottom: 12px;
    background: #0f0f0f; border: 1px solid #333; color: white; border-radius: 4px;
}
.auth-box button {
    width: 100%; padding: 10px; background: #ff0000; color: white;
    border: none; border-radius: 4px; cursor: pointer;
}
.error { color: #f44; margin-bottom: 10px; }
.success { color: #4f4; margin-bottom: 10px; }
.hint { margin-top: 15px; font-size: 13px; color: #999; }
code { background: #2a2a2a; padding: 2px 5px; border-radius: 3px; }

/* Toolbar avec filtres */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.filters {
    display: flex;
    gap: 8px;
}

.filters a {
    padding: 6px 14px;
    background: #1c1c1c;
    color: #ccc;
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    transition: background 0.2s;
}
.filters a:hover {
    background: #2a2a2a;
}
.filters a.active {
    background: #ff0000;
    color: white;
}

.btn-secondary {
    padding: 6px 14px;
    background: #2a2a2a;
    color: white;
    border: 1px solid #444;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
}
.btn-secondary:hover {
    background: #333;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
    font-size: 16px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 30px 0 10px;
    flex-wrap: wrap;
}
.pagination a {
    padding: 8px 14px;
    background: #1c1c1c;
    color: #ccc;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
}
.pagination a:hover {
    background: #2a2a2a;
}
.pagination a.active {
    background: #ff0000;
    color: white;
}
.pagination .ellipsis {
    color: #666;
    padding: 0 4px;
}
.pagination-info {
    text-align: center;
    color: #888;
    font-size: 13px;
}

.active-channel {
    font-weight: bold;
    background: #888888;
    border-radius: 4px;
}
.channel-name-link {
    text-decoration: none;
    color: inherit;
}
.channel-name-link:hover {
    text-decoration: underline;
}
.active-channel-filter {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #888888;
    border-radius: 4px;
}

.logo-ascii pre {
    font-family: 'Courier New', monospace;
    color: var(--accent, #ff4d4d);
    font-size: 14px;
    line-height: 1.1;
    margin: 0;
    text-shadow: 0 0 8px var(--accent-soft, rgba(255, 77, 77, 0.4));
    letter-spacing: 1px;
    white-space: pre;
}

/* ==========================================================
   RESPONSIVE MOBILE
   ========================================================== */

@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }

    .mobile-menu-btn {
        display: block;
        width: 100%;
        padding: 12px;
        margin-bottom: 15px;
        background: #1c1c1c;
        color: white;
        border: 1px solid #333;
        border-radius: 6px;
        font-size: 15px;
        font-weight: bold;
        cursor: pointer;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100vh;
        background: #181818;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 15px rgba(0,0,0,0.5);
        padding: 20px 15px;
        order: unset;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.6);
        z-index: 999;
    }

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

    .videos {
        order: 1;
    }
}

@media (min-width: 901px) {
    .mobile-menu-btn,
    .sidebar-overlay {
        display: none;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    header nav {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    header a {
        margin-left: 0;
        font-size: 14px;
    }
    .btn {
        padding: 8px 12px;
        font-size: 14px;
    }
    .video-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .video-info {
        padding: 8px;
    }
    .video-title {
        font-size: 15px;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .filters {
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .filters a {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .btn-secondary {
        width: 100%;
        text-align: center;
    }
    .channel-list li {
        font-size: 13px;
        padding: 10px 4px;
    }
    .auth-box {
        margin: 40px auto;
        max-width: 100%;
        padding: 20px;
    }
    .toggle-viewed-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    .pagination {
        gap: 4px;
        margin: 20px 0 10px;
    }
    .pagination a {
        padding: 6px 10px;
        font-size: 13px;
    }
    .empty-state {
        padding: 40px 15px;
        font-size: 14px;
    }
    .logo-ascii pre {
        font-size: 8px;
    }
}

@media (max-width: 360px) {
    .video-title {
        font-size: 14px;
    }
    .btn, .btn-secondary {
        font-size: 13px;
        padding: 8px 10px;
    }
}

.player-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.player-modal.open {
    display: flex;
}
.player-modal-content {
    width: 90%;
    max-width: 1000px;
    position: relative;
}
.player-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
}
.player-wrapper iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border-radius: 8px;
}
.player-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
}

@media (max-width: 600px) {
    .player-modal-content {
        width: 100%;
    }
    .player-close {
        top: -36px;
        font-size: 28px;
    }
}