/**
 * Viewing History Styles
 *
 * Phase 1: (no visible UI — tracking only)
 * Phase 2: Continue Watching row + progress bars
 * Phase 3: Auto-play overlay (added later)
 */

/* ── Continue Watching Section (Phase 2) ─────────────────────────────────── */

.continue-watching-section {
    padding: 0;
    margin-bottom: 2rem;
}

.continue-watching-row {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}

.continue-watching-row::-webkit-scrollbar {
    height: 4px;
}

.continue-watching-row::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.continue-watching-card {
    flex: 0 0 calc((100% - 5 * 1rem) / 6);
    min-width: 180px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease;
}

.continue-watching-card:hover {
    transform: scale(1.05);
    text-decoration: none;
    color: inherit;
}

.continue-watching-thumbnail {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #1a1a1a;
}

.continue-watching-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.continue-watching-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.continue-watching-card:hover .continue-watching-play-icon {
    opacity: 1;
}

/* Progress bar at bottom of thumbnail */
.continue-watching-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
}

.continue-watching-progress-bar {
    height: 100%;
    background: #E50914;
    border-radius: 0 2px 0 0;
    transition: width 0.3s ease;
}

.continue-watching-info {
    padding: 0.5rem 0.25rem;
}

.continue-watching-meta {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.15rem;
}

.continue-watching-title {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Episode List Progress Bars (Phase 2 — show detail page) ─────────────── */

.episode-simple-item .episode-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
}

.episode-simple-item .episode-progress-bar {
    height: 100%;
    background: #E50914;
}

.episode-simple-thumbnail {
    position: relative;
}

/* ── Resume Button (Phase 2 — show detail page) ─────────────────────────── */

.viewing-history-resume {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: rgba(229, 9, 20, 0.1);
    border: 1px solid rgba(229, 9, 20, 0.3);
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    transition: background 0.2s ease;
}

.viewing-history-resume:hover {
    background: rgba(229, 9, 20, 0.2);
}

/* ── Episode Nav Buttons (prev/next below player) ────────────────────── */

.episode-nav-btn {
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease !important;
}

.episode-nav-btn:hover {
    color: #fff !important;
    text-decoration: none !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.episode-nav-prev:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.episode-nav-next:hover {
    background: rgba(229, 9, 20, 0.3) !important;
    border-color: rgba(229, 9, 20, 0.6) !important;
    color: #fff;
    text-decoration: none;
}

.viewing-history-resume .resume-icon {
    font-size: 1.5rem;
    color: #E50914;
}

.viewing-history-resume .resume-text {
    font-size: 0.875rem;
}

.viewing-history-resume .resume-title {
    font-weight: 600;
}

/* ── Auto-Play Overlay (Phase 3) ─────────────────────────────────────────── */

.autoplay-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.autoplay-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.autoplay-card {
    background: rgba(30, 30, 30, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 360px;
    width: 90%;
    text-align: center;
}

.autoplay-countdown {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 1rem;
}

.autoplay-next-info {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.25rem;
    text-align: left;
}

.autoplay-next-thumb {
    width: 100px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    aspect-ratio: 16 / 9;
    background: #1a1a1a;
}

.autoplay-next-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.autoplay-next-meta {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.25rem;
}

.autoplay-next-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
}

.autoplay-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.autoplay-actions .btn {
    min-width: 100px;
}

/* Tap to play button (iOS fallback) */
.tap-to-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 101;
    background: rgba(229, 9, 20, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.tap-to-play:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

/* ── Completion Card (end of show) ───────────────────────────────────────── */

.completion-card {
    text-align: center;
    padding: 2rem;
}

.completion-card h4 {
    color: #E50914;
    margin-bottom: 0.5rem;
}

.completion-card p {
    color: rgba(255, 255, 255, 0.6);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .continue-watching-card {
        flex: 0 0 calc((100% - 1rem) / 2);
        min-width: 150px;
    }

    .autoplay-card {
        padding: 1rem;
    }

    .autoplay-next-info {
        flex-direction: column;
        text-align: center;
    }

    .autoplay-next-thumb {
        width: 140px;
    }
}
