:root {
    --bg-main: #0f1115;
    --bg-surface: #1a1d24;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #2a313a;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-area-bottom: env(safe-area-inset-bottom);
}

[data-theme="light"] {
    --bg-main: #f9fafb;
    --bg-surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #e5e7eb;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    font-family: 'Outfit', sans-serif;
    overflow-x: hidden;
    padding-bottom: calc(80px + var(--safe-area-bottom));
    transition: var(--transition);
}

.hidden { display: none !important; }

/* --- HEADER & NAVIGATION --- */
header {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.logo {
    font-size: 1.4rem;
    font-weight: 900;
    cursor: pointer;
}
.logo .highlight { color: var(--accent); }

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: rgba(26, 29, 36, 0.95);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 calc(10px + var(--safe-area-bottom));
    z-index: 998;
    backdrop-filter: blur(15px);
}

.mobile-bottom-nav button {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    cursor: pointer;
}
.mobile-bottom-nav button i { font-size: 1.2rem; }
.mobile-bottom-nav button span { font-size: 0.7rem; font-weight: 600; }
.mobile-bottom-nav button.active { color: var(--accent); }

/* --- HOME & SEARCH --- */
.search-container-sticky {
    padding: 15px 20px;
    position: sticky;
    background: var(--bg-main);
    top: 70px;
    z-index: 80;
}

.search-bar {
    position: relative;
    max-width: 100%;
}
.search-bar input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 12px 12px 12px 45px;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
}
.search-bar i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* --- VIDEO GRID --- */
.video-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 15px;
}

@media (max-width: 360px) {
    .video-grid { grid-template-columns: repeat(2, 1fr); }
}

.movie-card {
    width: 100%;
    cursor: pointer;
    background: var(--bg-surface);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.poster-container {
    position: relative;
    aspect-ratio: 2/3;
    background: #2a313a;
}

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

.locked-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    padding: 3px 6px;
    border-radius: 5px;
    font-size: 0.65rem;
    font-weight: 700;
}

.movie-info { 
    padding: 8px;
    flex: 1;
}

.movie-title-card {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* --- FILE BROWSER --- */
#files-view { animation: fadeIn 0.3s ease; }
.files-header {
    padding: 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
#files-breadcrumbs { margin: 0; font-size: 1.1rem; font-weight: 700; }
.files-list { padding: 10px; }
.file-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-surface);
    margin-bottom: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
}
.file-info { flex: 1; overflow: hidden; }
.file-name { font-weight: 500; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 0.75rem; color: var(--text-secondary); }

/* --- PROFILE VIEW --- */
.profile-container { padding: 20px; max-width: 500px; margin: 0 auto; }
.profile-main-card {
    background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-main) 100%);
    border-radius: 24px;
    padding: 30px 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 25px;
}
.profile-avatar {
    width: 100px; height: 100px; border-radius: 50%;
    background: var(--bg-surface); margin-bottom: 15px;
    border: 3px solid var(--accent); overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem; color: var(--accent);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-header-content h2 { font-size: 1.5rem; margin: 0 0 5px 0; }
.profile-header-content p { color: var(--accent); font-weight: 600; font-size: 0.9rem; margin: 0; }
.profile-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; margin-top: 25px; }
.profile-stat-box {
    background: var(--bg-surface); padding: 15px; border-radius: 16px;
    border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center;
}
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); }
.stat-label { font-size: 0.7rem; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 1px; margin-top: 4px; }

/* --- MOVIE DETAILS MODAL --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.9);
    display: flex; align-items: flex-end; z-index: 1000;
    backdrop-filter: blur(10px);
}
.modal-content {
    background: var(--bg-main); width: 100%; max-height: 90vh;
    border-radius: 24px 24px 0 0; overflow-y: auto; position: relative;
}
.close-modal-btn {
    position: absolute; top: 15px; right: 15px; background: rgba(0,0,0,0.5);
    border: none; color: white; width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; z-index: 100;
}

.details-backdrop { height: 220px; background-size: cover; background-position: center; position: relative; }
.details-backdrop::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(to top, var(--bg-main) 0%, rgba(15, 17, 21, 0.4) 50%, rgba(15, 17, 21, 0.8) 100%);
}
.details-poster-wrapper {
    position: absolute; bottom: -60px; left: 20px; width: 110px; aspect-ratio: 2/3;
    border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 10; border: 2px solid var(--border);
}
.details-poster { width: 100%; height: 100%; object-fit: cover; }
.details-info-container { padding: 70px 20px 30px; text-align: left; }
.details-title { font-size: 1.5rem; font-weight: 900; margin-bottom: 12px; line-height: 1.2; }
.details-meta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.meta-tag {
    display: flex; align-items: center; gap: 6px; background: var(--bg-surface);
    padding: 6px 12px; border-radius: 8px; font-size: 0.75rem; font-weight: 700; border: 1px solid var(--border);
}
.meta-tag.rating { color: #f59e0b; }
.meta-tag.year { color: var(--accent); }
.details-plot { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; margin-bottom: 25px; }

/* --- CAST LIST --- */
.cast-list { display: flex; overflow-x: auto; gap: 12px; padding: 10px 0; scrollbar-width: none; }
.cast-list::-webkit-scrollbar { display: none; }
.cast-item { min-width: 80px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.cast-avatar {
    width: 60px; height: 60px; border-radius: 50%; background: var(--bg-surface);
    display: flex; align-items: center; justify-content: center; margin-bottom: 8px; border: 1px solid var(--border);
}
.cast-name { font-size: 0.75rem; font-weight: 600; line-height: 1.2; }
.cast-role { font-size: 0.65rem; color: var(--text-secondary); }

/* --- CUSTOM VIDEO PLAYER --- */
#player-modal {
    background: #000;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-wrapper {
    width: 100%;
    height: 100%;
    background: #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#video-player {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    object-fit: contain;
}

.player-controls-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.8) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.player-wrapper:hover .player-controls-overlay,
.player-wrapper.active .player-controls-overlay {
    opacity: 1;
}

.player-top-bar {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-title-text {
    flex: 1;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-middle {
    flex: 1;
    display: flex;
    width: 100%;
}

.seek-tap-area {
    flex: 1;
    height: 100%;
    cursor: pointer;
}

.player-bottom-bar {
    padding: 10px 20px 30px;
    width: 100%;
}

.progress-container {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 5px;
}

.progress-bar-bg {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    position: relative;
    transition: height 0.2s;
}

.progress-container:hover .progress-bar-bg { height: 6px; }

.progress-buffer {
    position: absolute;
    top: 0; left: 0; height: 100%;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    width: 0%;
}

.progress-current {
    position: absolute;
    top: 0; left: 0; height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
}

.progress-knob {
    position: absolute;
    right: -6px; top: 50%;
    transform: translateY(-50%);
    width: 12px; height: 12px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-container:hover .progress-knob { opacity: 1; }

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 10px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-btn.main-play { font-size: 1.8rem; }

.time-text {
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 10px;
    font-family: monospace;
}

.big-play-btn {
    position: absolute;
    z-index: 30;
    width: 80px; height: 80px;
    background: rgba(59, 130, 246, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    pointer-events: none;
    transition: transform 0.2s, opacity 0.2s;
}

.player-loader {
    position: absolute;
    z-index: 40;
    font-size: 3rem;
    color: var(--accent);
}

/* Rotation Hint */
.rotation-hint {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 100;
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    animation: fadeInOut 5s forwards;
}

.rotation-hint i {
    font-size: 2.5rem;
    animation: rotateDevice 2s infinite;
    color: var(--accent);
}

@keyframes rotateDevice {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
    100% { transform: rotate(0deg); }
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { opacity: 0; }
}

@media (orientation: landscape) {
    .rotation-hint { display: none !important; }
}

/* --- UTILITIES --- */
.btn-primary { background: var(--accent); color: white; padding: 14px; border-radius: 12px; font-weight: 700; width: 100%; border: none; cursor: pointer; }
.load-more-wide { margin: 20px; background: transparent; border: 1px dashed var(--accent); color: var(--accent); padding: 15px; border-radius: 12px; font-weight: 700; width: calc(100% - 40px); cursor: pointer; }
.empty-state, .loading-state { padding: 40px; text-align: center; color: var(--text-secondary); }

/* --- SHIELD --- */
.shield-overlay { position: fixed; inset: 0; background: #0f1115; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.shield-content { width: 90%; max-width: 400px; text-align: center; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }