/* ============================================
   Netflix-Style Dashboard CSS
   넷플릭스 스타일 대시보드 - Updated2
   ============================================ */

:root {
    /* Netflix Color Palette */
    --netflix-red: #E50914;
    --netflix-red-dark: #B20710;
    --netflix-bg: #141414;
    --netflix-card-bg: #181818;
    --netflix-hover-bg: #232323;

    /* Text Colors */
    --text-primary: #FFFFFF;
    --text-secondary: #B3B3B3;
    --text-muted: #808080;

    /* UI Colors */
    --border-color: #333333;
    --overlay-dark: rgba(0, 0, 0, 0.85);

    /* Layout */
    --sidebar-width: 220px;
    --header-height: 68px;
    --bottom-nav-height: 56px;
    --sidebar-bg: #000000;

    /* Animation */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-decoration: none;
    list-style: none;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Netflix Sans', 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--netflix-bg);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   Header - 넷플릭스 스타일 헤더
   ============================================ */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background-color: var(--sidebar-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    transition: background var(--transition-normal);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    /* Match sidebar border */
}

/* 스크롤 시 배경 변경 (더 이상 필요 없음 - 항상 고정) */
.top-header.scrolled {
    background-color: var(--sidebar-bg);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.logo svg {
    width: 36px;
    height: 36px;
    margin-left: -6px;
    margin-bottom: -8px;
    /* 아래로 이동 */
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.logo span {
    color: #ffffff;
    font-weight: 700;
    padding-top: 2px;
    /* 보정 */
}

.logo:hover svg {
    transform: scale(1.1) rotate(5deg);
}

.logo:hover {
    opacity: 0.9;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-actions span {
    color: var(--text-secondary);
    font-size: 14px;
}

.user-actions .logout-btn {
    color: var(--text-secondary);
    font-size: 1.3rem;
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
}

.user-actions .logout-btn:hover {
    color: var(--text-primary);
}

/* Search Bar Styles */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 20px;
    margin-left: auto;
    /* Push to right */
}

.search-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
}

.search-input-box {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 10px;
    width: 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    overflow: hidden;
    backdrop-filter: blur(4px);
    border-radius: 4px;
}

.search-input-box.active {
    width: 210px;
    opacity: 1;
    visibility: visible;
    padding-left: 36px;
    /* space for icon */
    background: rgba(0, 0, 0, 0.8);
    border-color: #fff;
}

.search-input-box:focus-within {
    background: #000;
    border-color: #fff;
}

.search-icon-inside {
    position: absolute;
    left: 10px;
    font-size: 14px;
    color: #fff;
    pointer-events: none;
}

.search-input-box input {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    outline: none;
    padding: 0;
}

.search-close {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0 0 0 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.search-close:hover {
    color: #fff;
}

/* ============================================
   Sidebar - 넷플릭스 스타일 사이드바
   ============================================ */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--sidebar-bg);
    padding: 20px 0;
    z-index: 900;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    gap: 16px;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item:hover {
    color: var(--text-primary);
    background: linear-gradient(to right, rgba(255, 255, 255, 0.08) 0%, transparent 100%);
}

.nav-item.active {
    color: var(--text-primary);
    background: linear-gradient(to right, rgba(229, 9, 20, 0.15) 0%, transparent 100%);
    border-left-color: var(--netflix-red);
    font-weight: 600;
}

/* ============================================
   Main Content Area
   ============================================ */
.main-view {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    background: var(--netflix-bg);
}

#content-area {
    padding: 0;
}

/* ============================================
   Content Loading
   ============================================ */
.content-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-muted);
}

.content-loading i {
    font-size: 2.5rem;
    animation: spin 0.8s linear infinite;
    color: var(--netflix-red);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Mobile Menu Button
   ============================================ */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
}

/* ============================================
   Mobile Responsive
   ============================================ */
/* Tablet Responsive (Below 780px) - Off-canvas Sidebar */
@media (max-width: 780px) {
    .sidebar {
        top: var(--header-height);
        left: 0;
        width: 250px;
        height: calc(100vh - var(--header-height));
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        background-color: #000;
        /* Solid background */
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.8);
        z-index: 2000;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 20px 0;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .mobile-menu-btn {
        display: block !important;
    }

    .main-view {
        margin-left: 0;
    }
}

/* Mobile Responsive (Below 480px) - Bottom Navigation */
@media (max-width: 480px) {
    .sidebar {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 56px;
        /* Standard mobile nav height */
        transform: none;
        border-right: none;
        border-top: 1px solid #333;
        background-color: #000;
        /* Force black */
        padding: 0;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.5);
        z-index: 2000;
    }

    .sidebar.show {
        transform: none;
    }

    .mobile-menu-btn {
        display: none !important;
    }

    .main-view {
        margin-bottom: 60px;
        /* Space for bottom nav */
    }

    /* Common Styles for Bottom Nav Items */
    .nav-group,
    .nav-single {
        flex: 1;
        height: 100%;
        margin: 0;
        padding: 4px 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 3px;
        color: #888;
        background: transparent;
        transition: color 0.2s, background-color 0.2s;
        border: none;
    }

    /* Active State (Touch feedback) */
    .nav-group:active,
    .nav-single:active {
        background-color: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    /* Open/Active State */
    .nav-group.open,
    .nav-single.active {
        color: #fff;
    }

    .nav-group.open i,
    .nav-single.active i {
        color: var(--netflix-red);
    }

    /* Headers inside groups */
    .nav-group-header {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 3px;
        padding: 0;
        color: inherit;
        /* Inherit from .nav-group */
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.5px;
    }

    .nav-single {
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.5px;
    }

    /* Icons */
    .nav-group-header i,
    .nav-single i {
        font-size: 20px;
        margin: 0;
        width: auto;
        display: block;
        text-align: center;
    }

    /* Labels */
    .nav-group-header span,
    .nav-single span {
        display: block;
        line-height: 1.2;
    }

    /* Hide arrow in mobile */
    .nav-group-header .group-arrow {
        display: none;
    }

    /* Drop-up Menu */
    .nav-group-items {
        display: none;
        position: fixed;
        bottom: 56px;
        /* Match sidebar height */
        left: 0;
        width: 100%;
        max-height: 60vh;
        overflow-y: auto;
        background: rgba(20, 20, 20, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: 2px solid var(--netflix-red);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
        padding: 10px 0;
        z-index: 1000;
        /* Below sidebar */
    }

    .nav-group.open .nav-group-items {
        display: block;
        animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Sub-items in Drop-up */
    .nav-item.sub {
        padding: 14px 24px;
        font-size: 15px;
        color: #ddd;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        display: flex;
        justify-content: flex-start;
        /* Left align */
        align-items: center;
    }

    /* Nested Sub-items (Level 3) indent */
    .nav-subgroup-items .nav-item.sub {
        padding-left: 48px;
        /* Indent */
        background-color: rgba(0, 0, 0, 0.2);
        /* Slightly darker */
        font-size: 14px;
        /* Slightly smaller */
        color: #b0b0b0;
    }

    .nav-subgroup-items .nav-item.sub:active,
    .nav-subgroup-items .nav-item.sub.active {
        background-color: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    /* Level 2 Headers (Video, Movie, etc) */
    .nav-subgroup-header {
        background: transparent;
        /* Remove solid block, blend it */
        padding: 12px 24px;
        font-weight: 600;
        font-size: 14px;
        color: #fff;
        text-transform: none;
        /* Normal case */
        letter-spacing: normal;
        display: flex;
        align-items: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .nav-subgroup-header i {
        width: 24px;
        text-align: center;
        margin-right: 12px;
        color: var(--netflix-red);
        /* Icon color */
    }

    .nav-subgroup-header .subgroup-arrow {
        margin-right: 0;
        margin-left: auto;
        font-size: 12px;
        color: #666;
    }

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

    .nav-item.sub:active {
        background-color: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    /* Mobile Accordion Styles */
    .nav-subgroup-items {
        overflow: hidden;
        max-height: 500px;
        /* Adequate height for sub menus */
        transition: max-height 0.3s ease, opacity 0.3s ease;
        opacity: 1;
        background-color: rgba(0, 0, 0, 0.3);
        /* Slightly darker for nested */
    }

    .nav-subgroup.collapsed .nav-subgroup-items {
        max-height: 0;
        opacity: 0;
        margin: 0;
        padding: 0;
        border: none;
    }

    /* Arrow rotation for mobile */
    .nav-subgroup-header .subgroup-arrow {
        transition: transform 0.2s;
        display: block;
        /* Ensure it's visible if hidden elsewhere */
        font-size: 10px;
    }

    .nav-subgroup.collapsed .subgroup-arrow {
        transform: rotate(-90deg);
    }


    @keyframes slideUp {
        from {
            transform: translateY(20px);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

@media (max-width: 600px) {
    .top-header {
        padding: 0 16px;
    }

    .logo {
        font-size: 1.4rem;
    }

    .user-actions span {
        display: none;
    }
}

/* Profile Dropdown Styles in Header */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
    padding: 5px 10px;
    border-radius: 20px;
    transition: background-color 0.3s;
}

.user-profile:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.user-name {
    color: #fff;
    font-weight: 500;
    font-size: 14px;
}

.profile-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.profile-img-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
}

/* Dropdown Menu */
.profile-dropdown {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    width: 150px;
    z-index: 1000;
    overflow: hidden;
}

.profile-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.profile-dropdown a {
    display: block;
    padding: 12px 16px;
    color: #e0e0e0;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-dropdown a:hover {
    background-color: #3e3e3e;
    color: #fff;
}

.profile-dropdown a i {
    width: 16px;
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}