/* --- VARIABLES --- */
:root {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --accent: #38bdf8;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --star: #fbbf24;
    --ongoing: #ef4444;
    --complete: #22c55e;
}

/* --- RESET & BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

body.noscroll {
    overflow: hidden;
}

/* --- BUTTONS --- */
.btn {
    display: inline-block;
    background: var(--card-bg);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-2px);
}

/* --- UNIFIED NAVBAR --- */
.navbar {
    background: rgba(15, 23, 42, 0.98);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
}

.logo span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 25px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 500;
    transition: 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

.search-box input {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    width: 220px;
    outline: none;
}

/* --- LAYOUT --- */
.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

.section-title {
    margin: 30px 0 15px;
    font-size: 1.2rem;
    font-weight: 700;
}

/* --- MOVIE GRID & CARDS --- */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
}

.movie-card {
    transition: 0.2s;
    cursor: pointer;
}

.movie-card:hover {
    transform: translateY(-5px);
}

.movie-card:hover h3 {
    color: var(--accent);
}

.poster,
.poster-placeholder {
    position: relative;
    aspect-ratio: 2/3;
    background: #242f3e;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

/* Dummy Gradients */
.g-1 {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
}

.g-2 {
    background: linear-gradient(135deg, #581c87, #a855f7);
}

.g-3 {
    background: linear-gradient(135deg, #064e3b, #10b981);
}

.g-4 {
    background: linear-gradient(135deg, #7c2d12, #f97316);
}

/* Labels */
.label {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.55rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 3px;
    color: #fff;
    text-transform: uppercase;
}

.ongoing {
    background: var(--ongoing);
}

.complete {
    background: var(--complete);
}

.quality {
    background: rgba(0, 0, 0, 0.6);
    left: 6px;
    right: auto;
}

/* Card Info */
.card-info h3 {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.rating-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.star-icon {
    color: var(--star);
    font-size: 0.8rem;
}

.rating-val {
    font-size: 0.75rem;
    font-weight: 700;
}

.meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    display: flex;
    gap: 5px;
}

/* --- VIDEO PLAYER PAGE SPECIFIC --- */
.player-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.video-info {
    margin: 20px 0;
}

.metadata {
    color: var(--accent);
    font-size: 0.9rem;
    margin: 5px 0;
}

.description {
    color: var(--text-dim);
    max-width: 800px;
    font-size: 0.95rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-top: 30px;
}

.episodes-list {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
}

.episode-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.episode-item:hover {
    background: rgba(56, 189, 248, 0.2);
}

.episode-item.active {
    border-left: 4px solid var(--accent);
    background: rgba(56, 189, 248, 0.1);
}

.ep-num {
    font-weight: bold;
    margin-right: 15px;
    min-width: 25px;
}

.ep-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.ep-dur {
    font-size: 0.8rem;
    color: var(--text-dim);
}

footer {
    text-align: center;
    padding: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 40px;
    color: var(--text-dim);
    font-size: 0.75rem;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .logo {
        z-index: 1001;
        position: relative;
    }

    .burger {
        display: block;
        cursor: pointer;
        z-index: 1001;
        position: relative;
    }

    .burger div {
        width: 25px;
        height: 3px;
        background-color: var(--text);
        margin: 5px;
        transition: all 0.3s ease;
    }

    .nav-links {
        position: fixed;
        right: 0px;
        height: 100vh;
        top: 0;
        background-color: #1e293b;
        /* Fallback */
        background: rgba(30, 41, 59, 0.98);
        backdrop-filter: blur(10px);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        /* Start from top to allow scroll */
        /* Center items vertically */
        width: 60%;
        transform: translateX(100%);
        transition: transform 0.4s ease-in-out;
        padding-top: 80px;
        /* Space from top */
        overflow-y: auto;
        /* Enable Scroll */
        /* Centered instead */
        z-index: 1000;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.7);
    }

    .nav-links li {
        width: 100%;
        text-align: center;
        opacity: 0;
        /* For animation later if needed, but keeping simple for now */
        animation: navLinkFade 0.5s ease forwards 0.3s;
    }

    .nav-links.nav-active {
        transform: translateX(0%);
    }

    /* Burger Animation */
    .toggle .line1 {
        transform: rotate(-45deg) translate(-5px, 6px);
    }

    .toggle .line2 {
        opacity: 0;
    }

    .toggle .line3 {
        transform: rotate(45deg) translate(-5px, -6px);
    }
}

@media (min-width: 769px) {
    .burger {
        display: none;
    }
}

@media (max-width: 600px) {
    .movie-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        align-items: start;
    }

    .movie-card {
        width: 100%;
        overflow: hidden;
    }

    .poster {
        aspect-ratio: 2/3;
        width: 100%;
        height: auto;
    }

    .poster-thumb {
        display: none;
    }

    .container {
        padding: 0 10px;
    }

    .section-title {
        font-size: 1rem;
        margin: 20px 0 10px;
    }

    /* Shrink card info text */
    .card-info {
        padding: 2px 0;
    }

    .card-info h3 {
        font-size: 0.7rem;
        margin-bottom: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }

    .rating-row {
        gap: 2px;
    }

    .star-icon {
        font-size: 0.65rem;
    }

    .rating-val {
        font-size: 0.65rem;
    }

    .meta {
        font-size: 0.6rem;
        gap: 3px;
    }

    /* Adjust Poster Label */
    .label {
        font-size: 0.45rem;
        padding: 1px 4px;
        top: 4px;
        right: 4px;
    }

    .quality {
        left: 4px;
        right: auto;
    }
}

/* --- SEARCH RESULTS --- */
.search-results {
    position: absolute;
    background: var(--card-bg);
    /* Was #fff */
    width: 100%;
    z-index: 2000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    /* Stronger shadow for dark mode */
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Subtle border */
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    top: 100%;
    left: 0;
}

.search-item {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text);
    /* Was #333 */
    cursor: pointer;
    transition: 0.2s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: rgba(255, 255, 255, 0.05);
    /* Subtle hover */
}

.search-item img {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

.search-item-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.search-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.search-item-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 768px) {
    /* ... previous nav toggling code ... */

    /* Search Box adjustment */
    .search-box input {
        width: 140px;
        /* Smaller width on tablets/mobile */
        font-size: 0.75rem;
        padding: 6px 12px;
    }

    /* Fix header alignment */
    .header-container {
        padding: 0 15px;
        gap: 10px;
        /* Enforce spacing */
    }

    /* Mobile Search Results: Centered Fixed */
    .search-results {
        position: fixed;
        width: 90vw;
        top: 70px;
        left: 50%;
        transform: translateX(-50%);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        border-radius: 8px;
    }
}

@media (max-width: 380px) {
    /* Kept 3 columns per user request */

    .search-box input {
        width: 110px;
        /* Even smaller for tiny screens */
    }

    .logo {
        font-size: 1.1rem;
    }
}

/* --- HORIZONTAL SCROLL FOR CATEGORY BLOCKS --- */
.horizontal-scroll {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.horizontal-scroll::-webkit-scrollbar {
    height: 6px;
}

.horizontal-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.horizontal-scroll::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.horizontal-scroll .movie-card {
    flex: 0 0 160px;
    width: 160px;
}

@media (max-width: 600px) {
    .horizontal-scroll .movie-card {
        flex: 0 0 120px;
        width: 120px;
    }

    .horizontal-scroll {
        gap: 8px;
    }
}

/* --- SOCIAL SHARE --- */
.share-section {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-share {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    transition: 0.2s;
    border: none;
    text-decoration: none;
}

.btn-share:hover {
    transform: translateY(-3px);
}

.share-fb {
    background: #1877f2;
}

.share-wa {
    background: #25d366;
}

.share-tw {
    background: #1da1f2;
}

.share-tg {
    background: #0088cc;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .episodes-list {
        padding: 10px;
        /* Reduced padding */
        border-radius: 8px;
    }

    .season-tabs {
        margin-bottom: 10px;
    }

    .btn-season {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    /* Episode item compact */
    .episode-item {
        padding: 10px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* --- DETAIL PAGE GRID --- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}