:root {
    --bg-color: #0b0e14;
    /* Deep Dark Background */
    --card-bg: #15181f;
    /* Slightly lighter for cards */
    --sidebar-bg: #111319;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --accent: #f43f5e;
    /* Pinkish Red like DramaBox */
    --accent-hover: #e11d48;
    --border: rgba(255, 255, 255, 0.1);
    --gradient-overlay: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
}

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

body {
    font-family: 'Outfit', 'Inter', sans-serif;
    /* Modern Font */
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Header */
header {
    background: rgba(11, 14, 20, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 0;
}

.container {
    max-width: 1400px;
    /* Wider container for cinematic feel */
    margin: 0 auto;
    padding: 0 1.5rem;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(45deg, #f43f5e, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.search-form {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.search-input {
    padding: 0.6rem 1rem;
    background: transparent;
    border: none;
    color: white;
    outline: none;
    width: 250px;
}

.search-btn {
    padding: 0 1.2rem;
    border: none;
    background: var(--card-bg);
    /* Subtle button */
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
    border-left: 1px solid var(--border);
}

.search-btn:hover {
    color: var(--accent);
}

/* --- SOURCE SELECTOR --- */
.source-selector {
    margin: 1.5rem 0 1rem;
}

.source-pills-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-bottom: 0.5rem;
}

.source-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.65rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
    cursor: pointer;
}

.source-pill:hover {
    border-color: var(--accent);
    color: white;
    background: rgba(244, 63, 94, 0.1);
}

.source-pill.active {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border-color: transparent;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(244, 63, 94, 0.3);
}

.source-hidden {
    display: none;
}

.source-toggle {
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    font-family: inherit;
}

.source-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(244, 63, 94, 0.06);
}

.source-icon {
    font-size: 0.85rem;
}

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    letter-spacing: 0.02em;
}

/* --- CATEGORY TABS --- */
.category-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    padding: 0.6rem 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}

.category-tab:hover {
    border-color: var(--accent);
    color: white;
}

.category-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

/* --- MOCKUP CARD STYLE (Image 1) --- */
.drama-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    padding-bottom: 3rem;
}

.drama-card {
    background: transparent;
    /* Image handles bg */
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    text-decoration: none;
    transition: transform 0.2s;
    aspect-ratio: 2/3;
    border: 1px solid var(--border);
}

.drama-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
}

.card-image-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gradient Overlay at bottom */
.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), transparent);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
}

/* Episode Badge (Top Right) */
.ep-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-title {
    color: white;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- WATCH PAGE (Image 3) --- */
.watch-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    /* Sidebar width fixed */
    gap: 2rem;
    padding-top: 2rem;
}

/* Left Sidebar */
.watch-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-card {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.sidebar-poster {
    width: 100%;
    border-radius: 8px;
    aspect-ratio: 2/3;
    object-fit: cover;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.info-value {
    font-weight: 600;
    color: white;
    margin-bottom: 1rem;
}

.genre-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.genre-tag {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
}

/* Main Content (Right) */
.watch-main {
    width: 100%;
}

.player-wrapper {
    background: black;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/9;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

.player-wrapper video {
    width: 100%;
    height: 100%;
}

.player-nav {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.nav-btn {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.2s;
    font-size: 0.95rem;
}

.nav-btn.prev {
    background: var(--card-bg);
    color: white;
    border: 1px solid var(--border);
}

.nav-btn.next {
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
}

.nav-btn.next:hover {
    background: var(--accent-hover);
}

/* Episode Grid Box (Image 3 Bottom) */
.episode-grid-container {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.ep-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.ep-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.5rem;
}

.ep-box {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.ep-box:hover {
    border-color: var(--accent);
    color: white;
}

.ep-box.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.4);
}

/* Section Header */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2rem 0 1.5rem;
    position: relative;
    padding-left: 1rem;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: var(--accent);
    border-radius: 2px;
}


/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin: 2rem 0;
}

.pagination a,
.pagination span {
    padding: 0.7rem 1.25rem;
    font-size: 0.9rem;
}

/* Detail Page */
.detail-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2.5rem;
}

.detail-poster img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    display: block;
}

.detail-poster-wrap {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.detail-status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.8rem;
}

.detail-watch-btn {
    width: 100%;
    text-align: center;
    margin-top: 1rem;
    background: var(--accent);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    border: none;
    display: block;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.detail-watch-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
}

.detail-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.detail-meta {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    flex-wrap: wrap;
}

.detail-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .watch-container {
        grid-template-columns: 1fr;
    }

    .watch-sidebar {
        display: grid;
        grid-template-columns: 150px 1fr;
        gap: 1.5rem;
    }

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

    .detail-grid {
        grid-template-columns: 200px 1fr;
        gap: 1.5rem;
    }

    .detail-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 768px) {

    /* Header & Nav */
    nav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    .search-form {
        width: 100%;
    }

    .search-input {
        width: 100%;
        flex: 1;
    }

    /* Container */
    .container {
        padding: 0 1rem;
    }

    /* Watch */
    .watch-sidebar {
        display: flex;
        flex-direction: column;
    }

    .watch-container {
        padding-top: 1rem;
    }

    /* Detail Page */
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .detail-poster {
        max-width: 200px;
        margin: 0 auto;
    }

    .detail-title {
        font-size: 1.5rem;
        text-align: center;
    }

    .detail-meta {
        justify-content: center;
        font-size: 0.85rem;
        gap: 1rem;
    }

    .genre-tags {
        justify-content: center;
    }

    /* Drama Grid */
    .drama-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.75rem;
    }

    /* Section Title */
    .section-title {
        font-size: 1.2rem;
    }

    /* Category Tabs */
    .category-tabs {
        margin-bottom: 1.25rem;
    }

    .category-tab {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    /* Episode Grid */
    .ep-grid {
        grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
        gap: 0.35rem;
    }

    .ep-box {
        font-size: 0.8rem;
    }

    /* Pagination */
    .pagination a,
    .pagination span {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    /* Player */
    .player-nav {
        gap: 0.5rem;
    }

    .nav-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .drama-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 0.5rem;
    }

    .card-title {
        font-size: 0.85rem;
    }

    .ep-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    header {
        padding: 0.75rem 0;
    }

    .detail-poster {
        max-width: 160px;
    }
}