:root {
    --bg-dark: #09080d;
    --bg-card: #13111a;
    --bg-card-hover: #1c1a26;
    --primary: #8b5cf6;
    --primary-hover: #a78bfa;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border: rgba(255, 255, 255, 0.08);
    --danger: #ef4444;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* App Top Header Bar (Fixed on Desktop & Mobile) */
.app-header {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    height: 60px;
    background: #0c0b10;
    border-bottom: 1px solid var(--border);
    z-index: 99;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    transition: left 0.3s ease;
}

body.sidebar-collapsed .app-header {
    left: 0;
}

.menu-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 8px;
    gap: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.menu-toggle-btn:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.header-brand {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Sidebar Navigation */
aside {
    width: 240px;
    background-color: #0c0b10;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

body.sidebar-collapsed aside {
    transform: translateX(-100%);
}

.brand {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 24px;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    color: var(--text-main);
    background-color: var(--bg-card);
}

.nav-item.active {
    border-left: 4px solid var(--primary);
    border-radius: 4px 10px 10px 4px;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

/* Main Content Container */
main {
    margin-left: 240px;
    flex: 1;
    padding: 80px 40px 40px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

body.sidebar-collapsed main {
    margin-left: 0;
}

/* Search Section */
.search-container {
    display: flex;
    gap: 12px;
    margin-bottom: 40px;
    max-width: 600px;
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper input {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 20px 14px 46px;
    color: var(--text-main);
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.search-input-wrapper svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Movie Sections & Grid */
.section-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 20px;
    margin-bottom: 50px;
}

.movie-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.movie-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 10px 20px rgba(139, 92, 246, 0.15);
}

.card-img-wrapper {
    aspect-ratio: 2/3;
    width: 100%;
    position: relative;
    overflow: hidden;
    background-color: #1a1824;
}

.card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.movie-card:hover .card-img-wrapper img {
    transform: scale(1.05);
}

.card-rating {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.card-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.card-year {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Movie Details View */
.detail-view {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.back-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 18px;
    border-radius: 8px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: var(--bg-card);
    border-color: var(--text-muted);
}

.detail-header {
    display: flex;
    gap: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 30px;
    position: relative;
    overflow: hidden;
}

.detail-poster {
    width: 220px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.detail-info {
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 2;
}

.detail-title {
    font-size: 2rem;
    font-weight: 800;
}

.detail-meta {
    display: flex;
    gap: 14px;
    font-size: 0.85rem;
    color: var(--text-muted);
    align-items: center;
    flex-wrap: wrap;
}

.detail-overview {
    line-height: 1.6;
    color: #d1d5db;
    font-size: 0.95rem;
}

/* Episode Selector */
.tv-selector {
    margin-top: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}

.selector-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.episode-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.episode-card:hover,
.episode-card.active {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.03);
}

/* Player Section */
.player-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.player-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.player-frame-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.player-frame-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.save-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-btn:hover {
    background: var(--primary-hover);
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Loader */
.loader {
    display: none;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin: 40px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Media Queries for Mobile & Tablet Optimization */
@media (max-width: 900px) {
    .app-header {
        left: 0 !important;
    }

    aside {
        transform: translateX(-100%);
        width: 260px;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.8);
    }

    aside.mobile-open {
        transform: translateX(0) !important;
    }

    main {
        margin-left: 0 !important;
        padding: 76px 14px 40px 14px;
    }

    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
        gap: 12px;
    }

    .detail-header {
        flex-direction: column;
        gap: 20px;
        padding: 20px;
        border-radius: 16px;
    }

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

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

    .detail-meta {
        justify-content: center;
    }

    .search-container {
        flex-direction: column;
    }

    .search-btn {
        width: 100%;
    }
}