/* ========================================================
   GLOBAL COMPONENT CONFIGURATIONS & THEME ENGINE (MD3)
   HIGH CONTRAST PREMIUM LIGHT & PURE BLACK THEME MATRIX
   ======================================================== */
:root {
    --bg-color: #FFFFFF; 
    --surface: #FFFFFF; 
    --primary: #FF2E55; 
    --primary-glow: rgba(255, 46, 85, 0.12);
    --text-main: #000000; 
    --text-muted: #555555; 
    --card-bg: #FFFFFF;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.08);
    --success: #00C853;
    --download: #007AFF;
    --border-color: #EEEEEE;
}

[data-theme="dark"] {
    --bg-color: #000000;
    --surface: #000000;
    --primary: #FF3B30;
    --primary-glow: rgba(255, 59, 48, 0.15);
    --text-main: #FFFFFF;
    --text-muted: #AAAAAA;
    --card-bg: #111111;
    --glass-bg: rgba(0, 0, 0, 0.95);
    --glass-border: rgba(255, 255, 255, 0.1);
    --border-color: #222222;
}

* { 
    box-sizing: border-box; 
    font-family: 'Plus Jakarta Sans', sans-serif; 
    -webkit-tap-highlight-color: transparent; 
    -webkit-touch-callout: none; 
    -webkit-user-select: none; 
    user-select: none; 
    -webkit-user-drag: none; 
}

input, textarea, select { 
    -webkit-user-select: auto; 
    user-select: auto; 
}

body { 
    margin: 0; 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    overflow-x: hidden; 
    padding-top: 82px; /* Positioned directly to match lowered header height */
    padding-bottom: 48px; 
    touch-action: pan-y; 
    transition: background-color 0.3s; 
}

body.auth-active { 
    overflow: hidden; 
    height: 100vh; 
}

::-webkit-scrollbar { 
    display: none; 
}

/* LOADING / SPLASH SCREEN */
#splash-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: radial-gradient(circle at center, #ffffff 0%, #f1f5f9 100%);
    display: flex; justify-content: center; align-items: center;
    z-index: 999999;
    transition: opacity 0.6s ease;
}

.ambient-light {
    position: absolute;
    width: 300px; height: 300px;
    background: rgba(191, 149, 63, 0.12);
    border-radius: 50%;
    filter: blur(80px);
    animation: pulse 4s infinite alternate;
}

.loading-container { 
    text-align: center; 
    z-index: 2; 
}

.logo-splash {
    font-family: 'Cinzel', serif;
    font-size: 3.5rem; letter-spacing: 2px;
    color: #1e293b; opacity: 0; margin: 0 0 20px 0;
    animation: fadeUp 1.5s ease-out forwards;
    text-shadow: 0px 5px 15px rgba(0, 0, 0, 0.05);
}

.logo-splash span { 
    background: linear-gradient(to right, #bf953f, #b38728, #aa771c); 
    -webkit-background-clip: text; 
    color: transparent; 
    font-weight: 800; 
}

.progress-container {
    width: 250px; height: 4px;
    background: rgba(0, 0, 0, 0.06);
    margin: 0 auto 15px auto; border-radius: 10px;
    overflow: hidden; opacity: 0;
    animation: fadeIn 1s ease-out 1s forwards;
    position: relative;
}

.progress-bar { 
    width: 0%; height: 100%; 
    background: linear-gradient(90deg, #bf953f, #b38728); 
    border-radius: 10px; 
    animation: loadProgress 3.5s cubic-bezier(0.4, 0, 0.2, 1) forwards; 
}

.loading-text { 
    color: #64748b; 
    font-size: 0.9rem; 
    letter-spacing: 3px; 
    text-transform: uppercase; 
    opacity: 0; 
    margin: 0; 
    animation: fadeIn 1s ease-out 1.5s forwards; 
}

@keyframes fadeUp { 
    0% { opacity: 0; transform: translateY(30px) scale(0.9); } 
    100% { opacity: 1; transform: translateY(0) scale(1); } 
}

@keyframes fadeIn { 
    0% { opacity: 0; } 
    100% { opacity: 1; } 
}

@keyframes loadProgress { 
    0% { width: 0%; } 
    40% { width: 45%; } 
    70% { width: 80%; } 
    100% { width: 100%; } 
}

@keyframes pulse { 
    0% { transform: scale(1); opacity: 0.5; } 
    100% { transform: scale(1.5); opacity: 1; } 
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    gap: 10px;
}
.toast {
    background: var(--surface);
    backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--primary);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    animation: slideDownIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    line-height: 1.3;
    pointer-events: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90vw;
}
.toast span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 75vw;
}
.toast.success { border-left-color: var(--success); }
@keyframes slideDownIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes slideOutUp {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-50px); opacity: 0; }
}

/* Auth Screen */
#auth-screen { 
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh; overflow: hidden; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    background: linear-gradient(to top, rgba(255,255,255,1) 0%, rgba(255,255,255,0.7) 100%), url('https://assets.nflxext.com/ffe/siteui/vlv3/f841d4c7-10e1-40af-bcae-07a3f8dc141a/f6d7434e-d6de-4185-a6d4-c77a2d08737b/US-en-20220502-popsignuptwoweeks-perspective_alpha_website_small.jpg') center/cover; 
    padding: 16px; box-sizing: border-box;
}
.auth-box { 
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(30px); 
    border: 1px solid var(--glass-border); box-shadow: 0 20px 40px rgba(0,0,0,0.05); 
    padding: 35px 24px; border-radius: 32px; width: 100%; max-width: 420px; max-height: 90vh;
    overflow-y: auto; scrollbar-width: none; animation: scaleFadeIn 0.6s ease; 
}
.auth-box::-webkit-scrollbar { display: none; }
.auth-box h1 { color: var(--text-main); text-align: center; font-size: 2.2rem; margin: 0 0 5px 0; font-weight: 900; }
.auth-box h1 span { color: var(--primary); }
.auth-box h2 { text-align: center; margin: 0 0 25px 0; font-weight: 500; color: var(--text-muted); font-size: 1rem; }

.btn-google { width: 100%; padding: 18px; background: white; color: #000000; border: 1px solid rgba(0,0,0,0.08); border-radius: 18px; font-size: 1.05rem; font-weight: 800; cursor: pointer; transition: 0.3s; display: flex; align-items: center; justify-content: center; gap: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.03); }
.btn-google img { width: 22px; }
@keyframes scaleFadeIn { 0% { opacity: 0; transform: scale(0.95); } 100% { opacity: 1; transform: scale(1); } }

/* App Layout & Header Spacing */
#app-screen { display: none; position: relative; }
header { 
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; 
    height: 82px; /* Increased height to avoid status bar overlap */
    padding-top: 32px; /* Lowered header contents below status bar */
    background: var(--surface); 
    padding-left: 16px;
    padding-right: 16px;
    z-index: 100; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--border-color); 
}

.brand { color: var(--text-main); font-size: 1.3rem; font-weight: 900; margin: 0; display: flex; align-items: center; gap: 8px; }
.brand span { color: var(--primary); }
.header-avatar { width: 32px; height: 32px; background: linear-gradient(135deg, var(--primary), #FF7A00); color: white; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; cursor: pointer; overflow: hidden; border: 1px solid rgba(0,0,0,0.05); }
.header-avatar img { width: 100%; height: 100%; object-fit: cover;}

/* Account Switch Header Button */
.btn-switch-account-header {
    background: var(--surface); border: 1px solid var(--glass-border);
    padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; font-weight: 700;
    color: var(--text-main); cursor: pointer; display: flex; align-items: center; gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02); transition: all 0.2s ease;
}
.btn-switch-account-header:active { transform: scale(0.95); background: var(--border-color); }

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 48px; 
    background: #FFFFFF !important;
    border-top: 1px solid #EEEEEE;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: none !important;
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: border-box;
}

.nav-item {
    color: #666666;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent !important;
    transition: none !important; 
}

.nav-item:active, .nav-item:focus, .nav-create-circle:active, .nav-create-circle:focus {
    background-color: transparent !important;
    background: transparent !important;
    transform: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.nav-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px; 
    height: 26px;
    position: relative;
    transition: none !important;
}
.nav-item:active .nav-icon-container {
    transform: none !important;
}

.nav-icon-svg {
    width: 26px !important; 
    height: 26px !important;
    fill: none;
    color: #000000 !important; 
    opacity: 0.54; 
    transition: opacity 0.15s ease;
}

.nav-item.active .nav-icon-svg {
    opacity: 1 !important; 
}

.nav-label {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px; 
    font-weight: 700;
    color: #000000 !important; 
    opacity: 0.54; 
    margin-top: 2px;
    letter-spacing: -0.15px;
    transition: opacity 0.1s ease;
}

.nav-item.active .nav-label {
    opacity: 1 !important;
    font-weight: 800;
}

.nav-create-circle {
    background-color: #F1F5F9;
    color: #000000;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: none !important;
}

.nav-create-circle:active {
    transform: none !important;
    background-color: #F1F5F9 !important; 
}

.nav-create-circle svg {
    width: 20px;
    height: 20px;
    color: #000000;
}

.nav-avatar-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-item.active .nav-avatar-circle {
    border-color: #000000;
}

.nav-item .icon-selected { display: none !important; }
.nav-item .icon-unselected { display: block !important; }
.nav-item.active .icon-selected { display: block !important; }
.nav-item.active .icon-unselected { display: none !important; }

.nav-avatar-wrap { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; border: 2px solid transparent; transition: border-color 0.1s ease; display: flex; align-items: center; justify-content: center; }
.nav-item.active .nav-avatar-wrap { border-color: #000000; }
.nav-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }

/* Category Chips Styling */
.category-chips-container {
    position: fixed;
    top: 82px; /* Placed exactly below lower header */
    left: 0;
    width: 100%;
    height: 44px;
    background: var(--surface);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    overflow: hidden;
    z-index: 99;
    border-bottom: 1px solid var(--border-color);
}

.chip-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    background: #F1F5F9;
    color: #000000;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    text-align: center;
    width: 100%;
}
[data-theme="dark"] .chip-item {
    background: #222222;
    color: #FFFFFF;
}
.chip-item.active {
    background: #000000 !important;
    color: #FFFFFF !important;
}
[data-theme="dark"] .chip-item.active {
    background: #FFFFFF !important;
    color: #000000 !important;
}

/* Tabs & Rows */
.tab-content { display: none; padding: 0 16px; animation: fadeTab 0.4s ease; }
.tab-content.active { display: block; }
@keyframes fadeTab { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.section-title { font-size: 1.1rem; font-weight: 850; margin: 16px 0 12px; display: flex; align-items: center; gap: 8px; color: var(--text-main); }
.movie-row { display: flex; overflow-x: auto; gap: 14px; padding-bottom: 15px; scroll-behavior: smooth; margin-right: -16px; padding-right: 16px; scroll-snap-type: x mandatory;}

.movie-card { flex: 0 0 130px; scroll-snap-align: start; border-radius: 16px; overflow: hidden; cursor: pointer; transition: 0.3s; position: relative; background: var(--card-bg); aspect-ratio: 2/3; box-shadow: 0 10px 20px rgba(0,0,0,0.04); transform: translate3d(0,0,0); will-change: transform; }
.movie-card:active { transform: scale3d(0.92, 0.92, 1); } 
.movie-card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: 0.5s; }
.movie-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; }

/* Search UI */
.search-container { position: relative; margin-bottom: 15px; }
.search-bar { width: 100%; padding: 16px 50px 16px 18px; background: var(--surface); border: 1px solid var(--glass-border); border-radius: 16px; color: var(--text-main); font-size: 1.05rem; outline:none; transition: 0.3s; box-shadow: 0 5px 15px rgba(0,0,0,0.02); }
.search-bar:focus { border-color: var(--primary); background: #ffffff; box-shadow: 0 0 0 4px rgba(255, 46, 85, 0.08); }
.mic-btn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }

.filters { display: flex; gap: 10px; overflow-x: auto; margin-bottom: 20px; padding-bottom: 10px; margin-right: -20px; padding-right: 20px;}
.filter-chip { padding: 8px 18px; background: var(--surface); border-radius: 20px; cursor: pointer; white-space: nowrap; font-size: 0.9rem; font-weight: 700; transition: 0.3s; border: 1px solid var(--glass-border); color: var(--text-muted); }
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Full Screen Movie Page */
#full-movie-page { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; background: var(--bg-color); z-index: 2000; display: none; overflow-y: auto; animation: slideUpFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes slideUpFade { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.back-btn { position: absolute; top: 20px; left: 20px; background: rgba(255,255,255,0.8); backdrop-filter: blur(10px); border: 1px solid var(--glass-border); color: #000000; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; z-index: 2010; transition: 0.3s; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.back-btn:active { transform: scale(0.85); background: var(--primary); border-color: var(--primary); color: white; }

.full-page-banner { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border-bottom: 1px solid var(--glass-border); }
.video-container { width: 100%; aspect-ratio: 16 / 9; background: #000; display: none; position: relative; border-bottom: 1px solid var(--glass-border); }
.video-container iframe, .video-container video { width: 100%; height: 100%; border: none; }

.full-page-content { padding: 16px; }
.play-btn { flex:1; background:var(--primary); color:white; border:none; border-radius:18px; padding:16px; font-size:1.1rem; font-weight:800; display:flex; align-items:center; justify-content:center; gap:10px; box-shadow:0 10px 25px rgba(255, 46, 85, 0.15); transition:0.2s; cursor: pointer;}
.play-btn:active { transform: scale(0.95); }

/* YouTube Actions Bar */
.yt-actions-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--glass-border); }
.yt-actions-bar::-webkit-scrollbar { display: none; }
.yt-action-btn { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--glass-border); color: var(--text-main); padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: 0.2s; }
.yt-action-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Material Design 3 Modals and Sheets */
.upcoming-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(15px); z-index: 999999; display: none; justify-content: center; align-items: center; }
.upcoming-content {
    background: var(--surface) !important;
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 28px !important;
    padding: 32px 24px !important;
    width: 90%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12) !important;
    animation: md3ScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes md3ScaleIn {
    from { transform: scale(0.9) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}
.upcoming-icon { width: 70px; height: 70px; background: rgba(255, 46, 85, 0.08); border-radius: 50%; color: var(--primary); font-size: 2rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; animation: rotateGlow 3s infinite alternate; }
.upcoming-content h2 { font-size: 1.4rem; font-weight: 800; margin: 0 0 10px; color: var(--text-main); }
.upcoming-content p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; margin: 0 0 25px; }
.upcoming-close-btn { background: var(--primary); color: white; border: none; padding: 12px 30px; border-radius: 14px; font-weight: 800; font-size: 0.95rem; cursor: pointer; transition: 0.2s; box-shadow: 0 5px 15px rgba(255, 46, 85, 0.15); }
.upcoming-close-btn:active { transform: scale(0.95); }

@keyframes rotateGlow { 0% { transform: rotate(0deg) scale(1); box-shadow: 0 0 0 rgba(255, 46, 85, 0); } 100% { transform: rotate(15deg) scale(1.1); box-shadow: 0 0 15px rgba(255, 46, 85, 0.15); } }

/* Premium Bottom Sheets */
.premium-download-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(15px); z-index: 3000; display: none; align-items: flex-end; animation: fadeIn 0.3s ease; }
.premium-download-content { background: var(--surface); width: 100%; max-height: 85vh; border-radius: 32px 32px 0 0; padding: 24px; display: flex; flex-direction: column; box-shadow: 0 -15px 40px rgba(0, 0, 0, 0.12); animation: slideUpModal 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15); }
@keyframes slideUpModal { from { transform: translateY(100%); } to { transform: translateY(0); } }
.drag-handle-line { width: 45px; height: 5px; background: var(--border-color); border-radius: 10px; margin: 0 auto 18px; }
.download-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.download-modal-header h3 { font-size: 1.25rem; font-weight: 800; color: var(--text-main); margin: 0; }
.close-download-modal { background: var(--bg-color); border: none; color: var(--text-muted); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.download-modal-scrollable { overflow-y: auto; flex-grow: 1; padding-right: 4px; margin-bottom: 20px; }
.download-modal-scrollable::-webkit-scrollbar { width: 4px; }
.download-modal-scrollable::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

.format-section-title { font-size: 0.85rem; font-weight: 700; color: #94A3B8; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.format-option-row { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-radius: 16px; background: var(--bg-color); margin-bottom: 10px; cursor: pointer; transition: 0.2s; border: 1.5px solid transparent; position: relative; }
.format-option-row input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.format-left { display: flex; align-items: center; gap: 14px; }
.format-icon { color: var(--text-muted); font-size: 1.1rem; width: 24px; text-align: center; }
.format-name { font-size: 0.95rem; font-weight: 700; color: var(--text-main); transition: 0.2s; }
.format-size { font-size: 0.85rem; font-weight: 600; color: #94A3B8; margin-right: 32px; }

.custom-radio-check { width: 22px; height: 22px; border: 2px solid #CBD5E1; border-radius: 50%; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); transition: 0.2s; display: flex; align-items: center; justify-content: center; background: var(--surface); }
.custom-radio-check::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 0.75rem; color: #000000; opacity: 0; transition: 0.2s; }
.format-option-row input[type="radio"]:checked ~ .custom-radio-check { border-color: #FFC107; background: #FFC107; }
.format-option-row input[type="radio"]:checked ~ .custom-radio-check::after { opacity: 1; }
.format-option-row input[type="radio"]:checked ~ .format-left .format-name { color: #000000; }
.format-option-row input[type="radio"]:checked { border-color: rgba(255, 193, 7, 0.4); background: rgba(255, 193, 7, 0.03); }

.watch-ad-download-btn { background: var(--primary); color: white; border: none; border-radius: 20px; padding: 18px; font-size: 1.05rem; font-weight: 800; width: 100%; cursor: pointer; box-shadow: 0 8px 24px var(--primary-glow); transition: 0.2s; text-align: center; }
.watch-ad-download-btn:active { transform: scale(0.97); }
