/* ===== AniAni - Player / Watch / Read Styles ===== */

/* ===== Player Header ===== */
.player-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.player-header.sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
}

.player-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.player-back-btn:hover {
    background: var(--accent);
    color: var(--text-bright);
}

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

.player-header-title {
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-header-sub {
    font-size: 13px;
    color: var(--text-muted);
}

.player-nav-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== Episode Grid ===== */
.episode-range-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    overflow-x: auto;
    background: var(--bg-primary);
}

.episode-range-tab {
    padding: 6px 16px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.episode-range-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.episode-range-tab.active {
    background: var(--accent);
    color: var(--text-bright);
}

.episode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 16px 24px;
}

.episode-card {
    position: relative;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid var(--border);
}

.episode-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.episode-card.watched {
    border-color: var(--accent-green);
    background: rgba(76, 175, 80, 0.05);
}

.episode-card-number {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.episode-card-title {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.episode-watched-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 18px;
    color: var(--accent-green);
}

.episode-unwatched-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 18px;
    color: var(--text-muted);
    opacity: 0.3;
}

.episode-card:hover .episode-unwatched-icon {
    opacity: 0.7;
    color: var(--accent);
}

.episode-card.watched .episode-card-number {
    color: var(--accent-green);
}

.episode-play-icon {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 20px;
    color: var(--text-muted);
    opacity: 0.4;
    transition: all var(--transition-fast);
}

.episode-card:hover .episode-play-icon {
    opacity: 1;
    color: var(--accent);
}

.episode-check-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.3;
    transition: all var(--transition-fast);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.episode-check-btn:hover {
    opacity: 1;
    color: var(--accent);
}

.episode-check-btn.checked {
    opacity: 1;
    color: var(--accent-green);
}

.episode-check-btn .material-symbols-rounded {
    font-size: 20px;
}

/* ===== Season List ===== */
.season-list {
    padding: 16px 24px 0;
}

.season-list-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.season-list-items {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.season-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid var(--border);
    flex: 0 0 auto;
    min-width: 200px;
    max-width: 280px;
}

.season-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.season-item.current {
    border-color: var(--accent);
    background: var(--accent-dim);
    cursor: default;
}

.season-item-img {
    width: 40px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

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

.season-item-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.season-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Episode Section Header ===== */
.episode-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px 0;
    font-size: 16px;
    font-weight: 600;
}

.episode-section-progress {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

/* ===== Video Player ===== */
.video-player-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    background: var(--bg-primary);
}

.video-player-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
}

.video-player-native {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

/* ===== Player Settings Dropdown ===== */
.player-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 180px;
    z-index: 100;
    margin-bottom: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.player-dropdown-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px 4px;
}
.player-dropdown-menu .btn.active {
    background: var(--accent);
    color: #fff;
}
.qual-lvl-btn {
    font-size: 12px !important;
    padding: 3px 8px !important;
}

/* ===== Caption Size Classes ===== */
.video-player-native::cue {
    font-size: 1.2em;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 2px 6px;
}
.video-player-native.cap-small::cue {
    font-size: 0.85em;
}
.video-player-native.cap-medium::cue {
    font-size: 1.2em;
}
.video-player-native.cap-large::cue {
    font-size: 1.8em;
}

/* Caption Background Styles */
.video-player-native.cap-bg-box::cue {
    background: rgba(0,0,0,0.7);
}
.video-player-native.cap-bg-shadow::cue {
    background: transparent;
    text-shadow: 0 0 4px #000, 0 0 4px #000, 1px 1px 2px #000, -1px -1px 2px #000;
}
.video-player-native.cap-bg-none::cue {
    background: transparent;
    text-shadow: none;
}

/* ===== Chapter List ===== */
.chapter-list {
    padding: 16px 24px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.chapter-volume-group {
    margin-bottom: 20px;
}

.chapter-volume-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.chapter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.chapter-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.chapter-item.read {
    opacity: 0.6;
    border-left: 3px solid var(--accent-green);
}

.chapter-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chapter-item-number {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.chapter-item-title {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chapter-item-group {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-read-icon {
    font-size: 18px;
    color: var(--accent-green);
}

/* ===== Manga Reader - Strip Mode ===== */
.manga-reader-strip {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #1a1a1a;
    min-height: 100vh;
}

.manga-strip-page {
    width: 100%;
    max-width: 800px;
    height: auto;
    display: block;
}

.manga-chapter-nav-bottom {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

/* ===== Manga Reader - Single Page Mode ===== */
.manga-reader-single {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #1a1a1a;
    min-height: calc(100vh - 80px);
}

.manga-single-page-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    cursor: pointer;
    padding: 16px;
    min-height: 60vh;
}

.manga-single-page {
    max-width: 100%;
    max-height: calc(100vh - 160px);
    object-fit: contain;
}

.manga-single-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    width: 100%;
    justify-content: center;
}

.manga-page-indicator {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: center;
}

/* ===== Floating Controls ===== */
.manga-reader-floating-controls {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}

.manga-reader-floating-controls .btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    box-shadow: 0 4px 12px var(--shadow-heavy);
    backdrop-filter: blur(8px);
}

/* ===== Loading & Error States ===== */
.player-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
}

.player-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-tertiary);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: rotate 0.8s linear infinite;
}

.player-loading p {
    color: var(--text-muted);
    font-size: 14px;
}

.player-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.player-error p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 12px;
    max-width: 400px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .player-header {
        padding: 12px 16px;
        gap: 10px;
    }

    .player-header-title {
        font-size: 15px;
    }

    .player-nav-buttons {
        flex-direction: column;
        gap: 4px;
    }

    .player-nav-buttons .btn {
        font-size: 11px;
        padding: 4px 10px;
    }

    .episode-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
        padding: 12px 16px;
    }

    .episode-card {
        padding: 10px 12px;
    }

    .episode-card-number {
        font-size: 16px;
    }

    .chapter-list {
        padding: 12px 16px;
    }

    .chapter-item {
        padding: 10px 12px;
    }

    .chapter-item-group {
        display: none;
    }

    .season-list {
        padding: 12px 16px 0;
    }

    .season-item {
        min-width: 160px;
        padding: 8px 10px;
    }

    .manga-reader-floating-controls {
        bottom: 70px;
        right: 12px;
    }

    .manga-single-page {
        max-height: calc(100vh - 200px);
    }

    .manga-strip-page {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .player-header {
        flex-wrap: wrap;
    }

    .player-nav-buttons {
        width: 100%;
        flex-direction: row;
        justify-content: center;
    }

    .episode-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .episode-card-title {
        display: none;
    }
}
