/* CSS Custom Properties for Theming */
:root {
    --bg-base: #121212;
    --bg-highlight: #1a1a1a;
    --bg-elevated: #282828;
    --text-base: #ffffff;
    --text-subdued: #a7a7a7;
    --accent: #1db954; /* Spotify-like Green */
    --accent-hover: #1ed760;
    --sidebar-width: 250px;
    --player-height: 90px;
    --font-family: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-base);
    color: var(--text-base);
    overflow: hidden; /* Prevent body scrolling, handle scrolling in main content */
    font-size: 14px;
}

/* App Layout */
#app {
    display: flex;
    height: calc(100vh - var(--player-height));
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: #000000;
    display: flex;
    flex-direction: column;
    padding: 24px 12px;
    height: 100%;
}

.sidebar-logo {
    padding: 0 12px;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links {
    list-style: none;
    margin-bottom: 20px;
}

.nav-links li {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-subdued);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-base);
}

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

.sidebar-divider {
    height: 1px;
    background-color: #282828;
    margin: 10px 12px;
}

.user-section {
    margin-top: auto;
    padding: 12px;
}

.avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Base Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 50px;
    font-family: var(--font-family);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background-color: var(--text-base);
    color: #000;
}

.btn-primary:hover {
    background-color: #f6f6f6;
    transform: scale(1.04);
}

.btn-block {
    width: 100%;
    margin-top: 15px;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    background: linear-gradient(180deg, #2b2b2b 0%, var(--bg-base) 100%);
    overflow-y: auto;
    padding: 24px 32px;
    position: relative;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.greeting {
    font-size: 32px;
    font-weight: 700;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
}

.content-section {
    margin-bottom: 40px;
}

/* Media Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
}

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

.media-card {
    background-color: var(--bg-highlight);
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.media-card:hover {
    background-color: var(--bg-elevated);
}

.card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    margin-bottom: 16px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.video-card .card-image-wrapper {
    aspect-ratio: 16 / 9;
}

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

.play-overlay {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 48px;
    height: 48px;
    background-color: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 20px;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 8px rgba(0,0,0,0.3);
}

.play-overlay i {
    margin-left: 4px; /* visually center play icon */
}

.media-card:hover .play-overlay,
.media-card:hover .edit-overlay {
    opacity: 1;
    transform: translateY(0);
}

.edit-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background-color: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
}

.edit-overlay:hover {
    background-color: var(--accent);
    color: #000;
}

.card-info h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-info p {
    font-size: 14px;
    color: var(--text-subdued);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Player Bar */
.player-bar {
    height: var(--player-height);
    background-color: #181818;
    border-top: 1px solid #282828;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 100;
}

.now-playing {
    display: flex;
    align-items: center;
    width: 30%;
    min-width: 180px;
}

.now-playing-cover {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    margin-right: 14px;
    object-fit: cover;
}

.now-playing-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-right: 14px;
}

.track-title {
    font-size: 14px;
    font-weight: 600;
}

.track-artist {
    font-size: 12px;
    color: var(--text-subdued);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-subdued);
    font-size: 16px;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text-base);
}

.pulse-hint {
    animation: pulse-play 1s infinite alternate;
    color: var(--accent) !important;
}

@keyframes pulse-play {
    from { transform: scale(1); opacity: 0.8; }
    to { transform: scale(1.15); opacity: 1; text-shadow: 0 0 10px var(--accent); }
}

.like-btn i { font-size: 16px; }
.like-btn.liked i { color: var(--accent); font-weight: 900; }

.player-controls-container {
    width: 40%;
    max-width: 722px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 8px;
}

.play-pause-btn {
    font-size: 32px;
    color: var(--text-base);
}

.play-pause-btn:hover {
    transform: scale(1.05);
}

.progress-container {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;
    font-size: 12px;
    color: var(--text-subdued);
}

.progress-bar-bg {
    flex-grow: 1;
    height: 4px;
    background-color: #5e5e5e;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--text-base);
    border-radius: 2px;
    width: 0%;
}

.progress-bar-bg:hover .progress-bar-fill {
    background-color: var(--accent);
}

.player-volume {
    width: 30%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.volume-slider-bg {
    width: 100px;
    height: 4px;
    background-color: #5e5e5e;
    border-radius: 2px;
    cursor: pointer;
}

.volume-slider-fill {
    height: 100%;
    background-color: var(--text-base);
    border-radius: 2px;
}

.volume-slider-bg:hover .volume-slider-fill {
    background-color: var(--accent);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-elevated);
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.close-modal, .close-btn {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-subdued);
    transition: color 0.2s;
}

.close-modal:hover, .close-btn:hover {
    color: var(--text-base);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.share-social-grid a {
    transition: transform 0.2s, filter 0.2s;
}

.share-social-grid a:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.close-modal:hover { color: var(--text-base); }

.auth-tabs {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.auth-tab {
    background: transparent;
    border: none;
    color: var(--text-subdued);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.auth-tab.active {
    color: var(--text-base);
    border-bottom: 2px solid var(--accent);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #444;
    background-color: #333;
    color: white;
    font-family: var(--font-family);
}

.form-group input:focus {
    outline: none;
    border-color: var(--text-base);
    background-color: #444;
}

.error-msg {
    color: #e22134;
    font-size: 13px;
    margin-bottom: 15px;
}

/* Loaders */
#loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(18, 18, 18, 0.5);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Form Styles for Upload Page */
.upload-area {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}
.upload-area:hover { border-color: var(--accent); }

/* --- Mobile Responsiveness --- */

.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background-color: var(--bg-highlight);
    border-bottom: 1px solid #333;
    z-index: 200;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
}

.mobile-topbar .sidebar-logo {
    margin: 0;
    font-size: 20px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}
.sidebar-header .sidebar-logo {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    #app {
        flex-direction: column;
        padding-top: 60px; /* space for topbar */
    }

    .mobile-topbar {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: var(--player-height);
        z-index: 300;
        transition: left 0.3s ease;
        background-color: rgba(0,0,0,0.95);
        backdrop-filter: blur(10px);
        width: 250px;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 10px 0 30px rgba(0,0,0,0.8);
    }

    #sidebar-close-btn {
        display: block !important;
        font-size: 24px;
        color: white;
    }

    .main-content {
        padding: 16px;
    }

    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 16px;
    }
    
    .videos-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    /* Player Adjustments */
    .player-controls-container {
        width: 60%;
    }

    .player-volume {
        display: none;
    }

    .now-playing-info {
        max-width: 100px;
    }
    
    .now-playing {
        width: 40%;
    }
    
    .player-bar {
        padding: 0 8px;
    }
}

@media (max-width: 480px) {
    .now-playing-cover {
        display: none;
    }
    .player-controls {
        gap: 12px;
    }
    .play-pause-btn {
        font-size: 26px;
    }
}

/* --- Theater Mode Overlay --- */

.theater-overlay {
    position: fixed;
    top: 100vh; /* Hidden below screen initially */
    left: 0;
    width: 100%;
    height: calc(100vh - var(--player-height));
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(20px);
    z-index: 150;
    transition: top 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}
.theater-overlay.active {
    top: 0;
}

.theater-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 30px;
    z-index: 160;
}

.theater-container {
    display: flex;
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 60px 40px;
    gap: 40px;
    height: 100%;
    overflow: hidden;
}

.theater-visuals {
    flex: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    position: relative;
}

.theater-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s;
}

.theater-video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.theater-lyrics-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.theater-lyrics-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 24px;
    color: var(--text-base);
}

.theater-lyrics {
    flex: 1;
    overflow-y: auto;
    font-size: 22px;
    line-height: 1.6;
    color: var(--text-base);
    font-weight: 500;
    padding-right: 15px;
    scroll-behavior: smooth;
    position: relative;
}

.lyric-line {
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.3s ease, font-size 0.3s ease, font-weight 0.3s ease;
    margin: 8px 0;
    transform-origin: left center;
}

.lyric-line.active-lyric {
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255,255,255,0.2);
}
.theater-lyrics::-webkit-scrollbar {
    width: 6px;
}
.theater-lyrics::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

@media (max-width: 900px) {
    .theater-container {
        flex-direction: column;
        padding: 40px 20px;
        overflow-y: auto;
    }
    .theater-visuals {
        flex: none;
        width: 100%;
        aspect-ratio: 16/9;
        max-height: 40vh;
    }
    .theater-lyrics-container {
        flex: none;
        min-height: 50vh;
    }
}

/* Safari / iOS Specific Optimizations */
@supports (-webkit-touch-callout: none) {
    body {
        overscroll-behavior-y: none;
    }

    .mobile-topbar {
        padding-top: env(safe-area-inset-top);
        height: calc(60px + env(safe-area-inset-top));
    }

    .player-bar {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--player-height) + env(safe-area-inset-bottom));
    }
    
    .sidebar {
        padding-top: calc(24px + env(safe-area-inset-top));
    }
    
    @media (max-width: 768px) {
        #app {
            padding-top: calc(60px + env(safe-area-inset-top));
        }
    }
}

a, button, .media-card {
    -webkit-tap-highlight-color: transparent;
}

input, select, textarea, button {
    -webkit-appearance: none;
    appearance: none;
}

.main-content, .sidebar, #comments-list {
    -webkit-overflow-scrolling: touch;
}
