/* ==========================================================================
   1. COMMENTS SECTION (Global)
   ========================================================================== */
.btn-submit-comment { 
    background: var(--primary-red); 
    color: #fff; 
    border: none; 
    border-radius: 6px; 
    padding: 12px 24px; 
    font-size: 0.95rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    gap: 8px; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
}

.btn-submit-comment:hover { 
    background: var(--primary-red-darker); 
    transform: translateY(-2px); 
    box-shadow: 0 4px 12px rgba(229, 9, 20, 0.3); 
}

.btn-submit-comment:active { transform: translateY(0); }

.comment-form { width: 100%; max-width: none; display: block; }
.comment-form .form-group { width: 100%; display: block; margin-bottom: 16px; }

.comment-textarea {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: #fff;
    border-radius: .25rem;
    padding: 1rem;
    width: 100%;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-textarea:focus {
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.1);
}

.comment-form-section {
    background: #252d38;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.form-title {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   2. MODERN BANNER SLIDER
   ========================================================================== */
.banner {
    position: relative;
    width: 100%;
    height: 240px;
    overflow: hidden;
    background: var(--bg-card);
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.banner__gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--bg-card) 0%, rgba(26, 32, 41, 0.85) 40%, rgba(26, 32, 41, 0.6) 100%);
    z-index: 1;
    pointer-events: none;
}

.banner__wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    inset: 0;
    z-index: 3;
}

/* Animation au chargement initial (gérée par le wrapper pour éviter les glitchs) */
.banner.is-loaded .banner__wrapper {
    animation: fadeInUp 0.6s ease forwards;
}

.banner__item {
    flex: 0 0 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: white;
    padding: 15px 30px;
    box-sizing: border-box;
}

.banner__content {
    position: relative;
    max-width: 900px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 24px;
}

.banner__poster {
    flex-shrink: 0;
    width: 160px;
    height: 220px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.banner__poster img { width: 100%; height: 100%; object-fit: cover; }
.banner__info { flex: 1; padding-right: 15px; }

.banner__title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    font-family: 'Oswald', 'Arial Narrow', 'Arial', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    line-height: 1.2;
}

.banner__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    font-size: 0.85rem;
    color: #aaa;
}

.banner__meta-item { display: flex; align-items: center; gap: 5px; font-size: 0.9rem; }
.banner__meta-item i { color: var(--primary-red); font-size: 0.85rem; }
.banner__meta-item--live, .banner__meta-item--live i { color: #4ade80; }

.banner__pulse {
    width: 6px; height: 6px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.banner__synopsis {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #bbb;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.banner__actions { display: flex; gap: 10px; margin-top: auto; }

.banner__btn {
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.banner__btn--primary {
    background: linear-gradient(135deg, var(--primary-red) 0%, #b30000 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(197, 0, 0, 0.3);
}

.banner__btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(197, 0, 0, 0.4);
}

.banner__controls {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    z-index: 4;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    padding: 0 15px;
}

.banner__control {
    background: linear-gradient(135deg, rgba(30,30,30,0.9) 0%, rgba(50,50,50,0.9) 100%);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: all;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.banner__control:hover {
    background: linear-gradient(135deg, var(--primary-red) 0%, #b30000 100%);
    transform: scale(1.1);
}

.banner__indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 4;
}

.banner__indicator {
    width: 24px; height: 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    padding: 0;
}

.banner__indicator.is-active { /* Changé de --active à is-active pour cohérence JS */
    background: var(--primary-red);
    width: 32px;
    box-shadow: 0 0 10px rgba(197, 0, 0, 0.6);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .banner.is-loaded .banner__wrapper, 
    .banner__pulse { animation: none; }
}

/* ==========================================================================
   3. EPISODE LIST & ROWS
   ========================================================================== */
.episodes-list-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    background-color: var(--bg-card);
    border-radius: 5px;
}

.episodes-list { display: flex; flex-direction: column; gap: 8px; }
.season-block { margin-bottom: 20px; }

.season-title {
    background: linear-gradient(135deg, var(--primary-red) 0%, #8b0000 100%);
    color: #fff;
    padding: 12px 16px;
    margin: 0 0 12px 0;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 6px;
    font-family: 'Oswald', sans-serif;
}

.episode-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #252d38;
    border: 1px solid #30363d;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    gap: 16px;
}

.episode-row:hover {
    background: #2d3748;
    border-color: var(--primary-red);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.episode-row__thumbnail {
    flex-shrink: 0;
    width: 120px; height: 68px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #30363d;
}

.episode-row__thumbnail img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.episode-row__info { flex: 1; min-width: 0; }
.episode-row__number { font-size: 14px; font-weight: 600; color: #fff; display: block; }
.episode-row__lang { flex-shrink: 0; }

.badge-lang-vostfr, .badge-lang-vf {
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-lang-vostfr { background: var(--primary-red); }
.badge-lang-vf { background: #0d6efd; }

/* ==========================================================================
   4. GLOBAL COMPONENTS, BUTTONS & BADGES
   ========================================================================== */
.content-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.anime-list-container #searchForm { display: flex; align-items: stretch; gap: 6px; width: 100%; }
.anime-list-container .search-input, 
.anime-list-container .form__input { 
    flex: 1; height: 44px; background-color: var(--bg-card); border: 1px solid var(--border-color); 
    border-radius: var(--radius-sm); color: #fff; font-size: .95rem; padding: .5rem .75rem; 
}
.anime-list-container .search-input:focus, 
.anime-list-container .form__input:focus { border-color: var(--primary-red); }
.anime-list-container .search-btn-custom, 
.anime-list-container .form__submit { 
    height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--primary-red); 
    display: inline-flex; align-items: center; justify-content: center; background-color: var(--primary-red); 
    color: #fff; font-weight: 700; text-transform: uppercase; padding: 0 1rem; cursor: pointer; 
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .5rem 1rem; border: none; border-radius: .25rem;
    font-weight: 600; text-decoration: none; gap: .5rem;
    cursor: pointer; transition: background-color .2s, color .2s;
}
.btn-sm { padding: .25rem .5rem; font-size: .75rem; }
.btn-primary { background-color: var(--primary-red); color: #fff; }
.btn-primary:hover { background-color: var(--primary-red-darker); }
.btn-secondary { background-color: var(--bg-card); color: #fff; }
.btn-secondary:hover { background-color: var(--sidebar-border); }
.btn-outline-light { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; }
.btn-outline-light:hover { background: rgba(255,255,255,.1); }

.badge, .tag {
    display: inline-block; padding: .25rem .5rem; border-radius: .25rem;
    font-size: .75rem; font-weight: 700; text-transform: uppercase;
}
.badge-ongoing, .tag--ongoing { background-color: #0d6efd; color: #fff; }
.badge-finished, .tag--finished { background-color: #6c757d; color: #fff; }
.tag--year { background-color: #343a40; color: #fff; }

/* ==========================================================================
   5. MODALS & FORMS
   ========================================================================== */
.modal {
    position: fixed; inset: 0; display: none;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,.65); z-index: 1100;
}

/* FIX: Hook CSS sur classe d'état et non sur attribut ARIA */
.modal.is-open { display: flex; }
.modal.show { display: flex; }

.modal__dialog { max-width: 600px; width: 90%; }
.modal__content { 
    background-color: var(--bg-premium-black); border: 1px solid var(--border-color); 
    color: var(--text-primary); border-radius: .25rem; 
}
.modal__header { 
    display: flex; align-items: center; justify-content: space-between; 
    padding: .5rem 1rem; border-bottom: 1px solid var(--border-color); 
}
.modal__title { margin: 0; font-size: 1rem; font-weight: 600; }
.modal__close { 
    background: transparent; border: none; width: 1.5rem; height: 1.5rem; 
    position: relative; cursor: pointer; font-size: 1.2rem; color: #fff; 
}
.modal--dark .modal__content { background-color: var(--main-dark); border: 1px solid #333; color: #fff; }
.modal--dark .modal__header { border-bottom: 1px solid #333; }

.form { display: block; }
.form__group { margin-bottom: 1rem; }
.form__label { display: block; margin-bottom: .25rem; font-weight: 600; color: #fff; }
.form__actions { margin-top: .75rem; display: flex; align-items: center; justify-content: flex-end; gap: .5rem; }
.form input { 
    background-color: var(--bg-card); border: 1px solid var(--border-color); color: #fff; 
    border-radius: .25rem; padding: .5rem .75rem; width: 100%; outline: none; 
}
.form input:focus { border-color: var(--primary-red); }
.form__error { color: var(--primary-red); }
.form__hint { color: var(--text-muted); font-size: .8rem; }

.report-form .form__group { margin-bottom: 1.5rem; }
.report-form .form__label { font-size: 0.95rem; color: #fff; display: flex; align-items: center; }

/* FIX: Suppression du !important, augmentation propre de la spécificité */
.modal .modal-body.p-4 { padding: 1.5rem; }

/* Centralized red button styles */
.btn.btn-download {
    background-color: var(--primary-red);
    border: 1px solid var(--primary-red);
    color: #fff;
}

.btn.btn-download:hover {
    background-color: var(--primary-red-darker);
    border-color: var(--primary-red-darker);
}

/* ==========================================================================
   6. DETAIL CARDS & SIDEBAR
   ========================================================================== */
.anime-detail-card { margin-top: 0; display: block; }
.anime-detail-card + .anime-detail-card { margin-top: 24px; }

.header-banner,
.anime-detail-card .card-header-red,
.sidebar-header {
    margin-bottom: 0; border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--primary-red) 0%, #8b0000 100%);
    position: relative; z-index: 2;
    display: flex; align-items: center; justify-content: space-between;
    min-height: 44px;
}

.header-banner--flat { box-shadow: none; }

.anime-detail-card .card-header-red h1,
.anime-detail-card .card-header-red h2,
.anime-detail-card .card-header-red h3 {
    margin: 0; color: white; font-size: 1.2rem;
    text-transform: uppercase; font-weight: bold; line-height: 1.2;
}

.anime-detail-card .comments-section {
    margin-top: 0; padding: 20px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color); border-top: none;
    border-radius: 0 0 6px 6px;
    position: relative; z-index: 1;
}

.header-banner__left { display: flex; align-items: center; gap: 10px; }
.header-banner__title { margin: 0; color: white; font-size: 1.2rem; text-transform: uppercase; font-weight: bold; line-height: 1.2; }

.sidebar-comment-list { display: flex; flex-direction: column; }
.sidebar-comment {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px;
    border-bottom: 1px solid var(--border-color); text-decoration: none; transition: background 0.2s;
}
.sidebar-comment:hover { background: rgba(255,255,255,0.05); }
.sidebar-comment:last-child { border-bottom: none; }
.sidebar-comment-avatar img { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; }
.sidebar-comment-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.sidebar-comment-header { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 4px; }
.sidebar-comment-header .username { color: var(--blue-primary); font-weight: bold; font-size: 0.9rem; }
.sidebar-comment-header .time { color: var(--text-muted); font-size: 0.75rem; }
.sidebar-comment-body { color: var(--text-secondary); font-size: 0.85rem; font-style: italic; white-space: normal; word-break: break-word; }

/* ==========================================================================
   7. SCROLLBARS
   ========================================================================== */
.episodes-list-container::-webkit-scrollbar,
.ep-menu::-webkit-scrollbar,
.watchlist-scroll-container::-webkit-scrollbar { width: 10px; height: 10px; }

.episodes-list-container::-webkit-scrollbar-track,
.ep-menu::-webkit-scrollbar-track,
.watchlist-scroll-container::-webkit-scrollbar-track { background: var(--bg-body); border-radius: 10px; }

.episodes-list-container::-webkit-scrollbar-thumb,
.ep-menu::-webkit-scrollbar-thumb,
.watchlist-scroll-container::-webkit-scrollbar-thumb { background: var(--primary-red); border-radius: 10px; border: 2px solid var(--bg-body); }

.episodes-list-container::-webkit-scrollbar-thumb:hover,
.ep-menu::-webkit-scrollbar-thumb:hover,
.watchlist-scroll-container::-webkit-scrollbar-thumb:hover { background: var(--primary-red-darker); }

.episodes-list-container, .ep-menu, .watchlist-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-red) var(--bg-body);
}

/* Top item background image styles */
.top-item {
    position: relative;
    overflow: hidden;
    display: block;
}

.top-item-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    filter: none;
    -webkit-filter: none;
}

.top-overlay,
.top-content {
    position: relative;
    z-index: 1;
}

/* Ensure no grayscale on hidden tab content */
#top-week-content .top-item-bg,
#top-24h-content .top-item-bg {
    filter: none;
    -webkit-filter: none;
}

/* Fix top content blocks background to stay black */
#top-content-wrapper,
#top-24h-content,
#top-week-content {
    background: #000;
}

/* Fix toggle button to be transparent with black background */
.tabs-right-controls .toggle {
    background: transparent;
    border: none !important;
}

/* Toggle label styles */
.toggle-label {
    margin-left: 0.25rem;
    font-size: 0.875rem;
    color: #fff;
}

/* Fix toggle button background to match red banner */
.sidebar-header .toggle {
    background: transparent;
    border: none;
}

/* Top tabs styles */
.tabs-header {
    display: flex;
    background: var(--bg-card);
    align-items: center;
    padding: 8px;
    border-radius: 6px 6px 0 0;
}

.tab-btn {
    background: transparent;
    color: #aaa;
    border: none;
    cursor: pointer;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s ease, background 0.2s ease;
}

.tab-btn.active {
    background: var(--primary-red);
    color: #fff;
    border-radius: 4px;
}

.tab-btn:hover:not(.active) {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

.tab-btn:focus-visible {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
}

/* ==========================================================================
   8. RESPONSIVE MEDIA QUERIES
   ========================================================================== */

@media (max-width: 1024px) {
    .banner { height: 280px; }
    .banner__gradient { background: linear-gradient(180deg, var(--bg-card) 0%, rgba(26, 32, 41, 0.8) 60%, var(--bg-card) 100%); }
    .banner__content { flex-direction: column; text-align: center; padding: 15px; gap: 12px; }
    .banner__poster { width: 120px; height: 170px; max-width: 35%; }
    .banner__info { padding-right: 0; }
    .banner__title { font-size: 1.3rem; }
    .banner__meta { justify-content: center; font-size: 0.8rem; }
    .banner__actions { justify-content: center; }
}

@media (max-width: 768px) {
    .banner { height: 260px; }
    .banner__item { padding: 12px 15px; }
    .banner__content { padding: 10px; gap: 10px; }
    .banner__poster { width: 100px; height: 140px; max-width: 30%; }
    .banner__title { font-size: 1.1rem; }
    .banner__meta { font-size: 0.75rem; gap: 8px; }
    .banner__actions { flex-direction: column; align-items: center; }
    .banner__btn { width: 100%; justify-content: center; padding: 8px 14px; font-size: 0.8rem; }
    
    .banner__control { width: 44px; height: 44px; font-size: 1rem; }
    .banner__indicators { bottom: 10px; gap: 6px; }
    .banner__indicator { width: 24px; height: 10px; }
    .banner__indicator.is-active { width: 32px; }

    .episodes-list-container { max-height: 60vh; }
    .episode-row { padding: 10px 12px; gap: 12px; }
    .episode-row__thumbnail { width: 80px; height: 45px; }
    .episode-row__number { font-size: 13px; }
    .badge-lang-vostfr, .badge-lang-vf { font-size: 10px; padding: 3px 6px; }

    .comment-form-section { padding: 16px; margin-top: 16px; }
    .form-title { font-size: 1rem; margin-bottom: 12px; }
    .comment-textarea { padding: 0.875rem; font-size: 0.9rem; }
    .btn-submit-comment { padding: 10px 20px; font-size: 0.9rem; width: 100%; }
}

@media (max-width: 480px) {
    .banner { height: 220px; }
    .banner__title { font-size: 1rem; }
    .banner__meta { font-size: 0.7rem; }
    .banner__poster { width: 80px; height: 110px; max-width: 25%; }
    .banner__control { width: 40px; height: 40px; }
    .banner__indicator { width: 20px; height: 12px; }

    .episode-row { padding: 8px 10px; gap: 10px; }
    .episode-row__thumbnail { width: 70px; height: 40px; }
    .episode-row__number { font-size: 12px; }

    .comment-form-section { padding: 12px; margin-top: 12px; }
    .form-title { font-size: 0.95rem; margin-bottom: 10px; }
    .comment-textarea { padding: 0.75rem; font-size: 0.85rem; }
    .btn-submit-comment { padding: 8px 16px; font-size: 0.85rem; }
}

@media (max-width: 380px) {
    .banner__poster { display: none; }
    .banner__content { flex-direction: column; align-items: center; text-align: center; }

    .banner { height: 200px; }
    .banner__title { font-size: 0.9rem; }
    .banner__poster { width: 70px; height: 100px; max-width: 22%; }
}