/*
==============================================
:VARIABLES & GLOBAL STYLES (YouTube Theme)
==============================================
*/
:root {
    --yt-bg: #0f0f0f;
    --yt-surface: #212121;
    --yt-surface-hover: #383838;
    --yt-border: #383838;
    --yt-text-primary: #f1f1f1;
    --yt-text-secondary: #aaaaaa;
    --yt-red: #FF0000;
    --patreon-red: #FF424D;
    --font-main: 'Roboto', sans-serif;
}

/* Heartbeat animation for favorite buttons */
@keyframes heartbeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

body {
    background-color: var(--yt-bg);
    color: var(--yt-text-primary);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/*
==============================================
:AGE GATE
==============================================
*/
#age-gate {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.95); backdrop-filter: blur(10px);
    display: flex; justify-content: center; align-items: center; z-index: 9999;
}
.gate-box {
    background-color: var(--yt-surface); padding: 2rem; border-radius: 12px;
    border: 1px solid var(--yt-border); text-align: center; max-width: 450px;
    margin: 1rem;
}
#confirm-age-btn {
    background-color: var(--yt-red); color: white; border: none; padding: 0.8rem 1.5rem;
    font-size: 1rem; font-weight: 500; border-radius: 20px; cursor: pointer;
    transition: background-color 0.2s;
}
#confirm-age-btn:hover { background-color: #cc0000; }

/*
==============================================
:MAIN LAYOUT (HEADER, SIDEBAR, CONTENT)
==============================================
*/
#main-header {
    background-color: var(--yt-bg);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    border-bottom: 1px solid var(--yt-border);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#sidebar-toggle-btn {
    background: none; border: none; color: var(--yt-text-primary);
    font-size: 1.2rem; cursor: pointer; padding: 0.5rem;
}

.logo {
    display: flex; align-items: center; gap: 0.5rem; text-decoration: none;
}
.logo-icon { height: 30px; }
.logo-text { color: var(--yt-text-primary); font-size: 1.5rem; font-weight: 700; }

.search-bar {
    display: flex;
    flex-grow: 1;
    justify-content: center;
}
#main-search-input {
    background-color: #121212; border: 1px solid var(--yt-border);
    color: var(--yt-text-primary); padding: 0.6rem 1rem;
    border-radius: 20px 0 0 20px; width: 100%; max-width: 500px;
}
#search-btn {
    background-color: var(--yt-surface); border: 1px solid var(--yt-border);
    border-left: none; color: var(--yt-text-secondary); padding: 0.6rem 1.2rem;
    border-radius: 0 20px 20px 0; cursor: pointer;
}

.header-right .patreon-btn {
    background-color: var(--patreon-red); color: white; padding: 0.5rem 1rem;
    text-decoration: none; border-radius: 18px; font-size: 0.9rem; font-weight: 500;
}
.header-right .patron-info span { color: var(--yt-text-secondary); }
.header-right .header-btn {
    background-color: var(--yt-surface); color: var(--yt-text-primary);
    padding: 0.5rem 1rem; text-decoration: none; border-radius: 18px;
    font-size: 0.9rem; font-weight: 500;
}

#main-sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0;
    width: 240px;
    background-color: var(--yt-bg);
    z-index: 99;
    padding-top: 1rem;
    transition: transform 0.2s ease;
    border-right: 1px solid var(--yt-border);
}
#main-sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-nav .nav-item {
    display: flex; align-items: center; gap: 1.5rem; padding: 0.8rem 1.5rem;
    color: var(--yt-text-primary); text-decoration: none; border-radius: 10px;
}
.sidebar-nav .nav-item:hover { background-color: var(--yt-surface-hover); }
.sidebar-nav .nav-item.active { background-color: var(--yt-surface); font-weight: 500; }
.sidebar-nav .nav-item i { font-size: 1.2rem; width: 24px; text-align: center;}
.sidebar-nav hr { border-color: var(--yt-border); margin: 1rem 1.5rem; }

#content-wrapper {
    padding-top: 56px;
    padding-left: 240px;
    transition: padding-left 0.2s ease;
}
#content-wrapper.sidebar-collapsed {
    padding-left: 0;
}

.content-section {
    padding: 1.5rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    cursor: pointer;
}
.thumbnail-container {
    position: relative;
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
}

.thumbnail-overlay {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.gallery-item:hover .thumbnail-overlay,
body.is-mobile .gallery-item .thumbnail-overlay {
    opacity: 1;
}
.overlay-btn {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.overlay-btn.favorited {
    color: var(--patreon-red);
}
.overlay-btn.favorited.animate-heart,
#modal-favorite-btn.animate-heart .fa-heart {
    animation: heartbeat 0.5s ease-in-out;
}

.gallery-item img {
    width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
    display: block; transition: transform 0.2s;
}
.gallery-item:hover img {
    transform: scale(1.05);
}
.item-info {
    display: flex; gap: 0.8rem; padding-top: 0.8rem;
}
.item-info .author-pfp {
    width: 36px; height: 36px; border-radius: 50%;
    background-color: var(--yt-surface);
    object-fit: cover;
    flex-shrink: 0;
}
.item-title {
    font-weight: 500; color: var(--yt-text-primary);
}
.item-meta {
    font-size: 0.9rem; color: var(--yt-text-secondary);
}

/*
==============================================
:MODAL "WATCH PAGE"
==============================================
*/
#modal-viewer {
    position: fixed;
    top: 56px; 
    left: 240px;
    right: 0;
    bottom: 0;
    background-color: var(--yt-bg);
    z-index: 500;
    overflow-y: auto;
    transition: left 0.2s ease, top 0.2s ease;
}

#content-wrapper.sidebar-collapsed ~ #modal-viewer {
    left: 0;
}

#watch-page-container {
    max-width: 1780px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
}
.watch-page-main {
    flex: 1; min-width: 0;
}
#modal-media-container {
    width: 100%; aspect-ratio: 16 / 9; background-color: #000;
    border-radius: 12px; overflow: hidden;
    position: relative;
}
#modal-media-container video, #modal-media-container img {
    width: 100%; height: 100%; object-fit: contain;
}
#modal-title {
    font-size: 1.5rem; margin-top: 1rem;
}
.video-actions {
    display: flex; justify-content: space-between; align-items: center; margin-top: 0.8rem;
    flex-wrap: wrap; gap: 1rem;
}
#author-info {
    display: flex; align-items: center; gap: 0.8rem;
}
#author-pfp {
    width: 40px; height: 40px; border-radius: 50%;
    background-color: var(--yt-surface);
    object-fit: cover;
    flex-shrink: 0;
}
#author-name { font-weight: 500; }

.action-buttons { display: flex; gap: 0.5rem; }
.action-buttons button {
    background-color: var(--yt-surface); border: none;
    color: var(--yt-text-primary); padding: 0.6rem 1rem;
    border-radius: 18px; cursor: pointer; display: flex;
    align-items: center; gap: 0.5rem; font-size: 0.9rem;
}
.action-buttons button:hover { background-color: var(--yt-surface-hover); }
#modal-favorite-btn.favorited {
    background-color: var(--yt-surface-hover);
    color: var(--patreon-red);
}

#description-box {
    background-color: var(--yt-surface);
    padding: 1rem;
    border-radius: 12px;
    margin-top: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.watch-page-sidebar {
    width: 400px;
}
.watch-page-sidebar h3 {
    margin: 0 0 1rem 0; font-size: 1.2rem;
}
#up-next-container .gallery-item {
    display: flex; gap: 0.8rem;
    align-items: flex-start;
}
#up-next-container .thumbnail-container {
    flex-shrink: 0;
}
#up-next-container .gallery-item img {
    width: 168px; height: 94px;
}
#up-next-container .item-info {
    padding-top: 0;
}
#up-next-container .item-title { font-size: 1rem; }
#up-next-container .item-meta { font-size: 0.8rem; }
#up-next-container .author-pfp { display: none; }
#up-next-container .thumbnail-overlay { display: none; }

/*
==============================================
:CUSTOM VIDEO PLAYER CONTROLS
==============================================
*/
#modal-media-container video::-webkit-media-controls {
    display: none !important;
}
.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}
#modal-media-container:hover .video-controls,
#modal-media-container.controls-visible .video-controls {
    opacity: 1;
}
.control-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}
.seek-bar-container {
    flex-grow: 1;
    cursor: pointer;
    height: 14px;
    display: flex;
    align-items: center;
}
.seek-bar {
    width: 100%;
    height: 4px;
    background-color: rgba(255,255,255,0.4);
    position: relative;
    transition: height 0.2s ease;
}
.seek-bar-container:hover .seek-bar {
    height: 6px;
}
.seek-bar-fill {
    height: 100%;
    width: 0;
    background-color: var(--yt-red);
}
.seek-bar-handle {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background-color: var(--yt-red);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.seek-bar-container:hover .seek-bar-handle {
    opacity: 1;
}
.volume-container {
    display: flex;
    align-items: center;
}
.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 0;
    height: 4px;
    background: rgba(255,255,255,0.4);
    outline: none;
    transition: width 0.2s ease;
    border-radius: 2px;
}
.volume-container:hover .volume-slider {
    width: 80px;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
}
.time-display {
    color: white;
    font-size: 0.9rem;
    user-select: none;
}

/*
==============================================
:BLOG & COMMENTS
==============================================
*/
.blog-post-summary {
    background-color: var(--yt-surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--yt-border);
    margin-bottom: 1.5rem;
}
.blog-post-summary h3 {
    margin-top: 0;
    font-size: 1.8rem;
    color: var(--yt-text-primary);
}
.post-meta {
    font-size: 0.9rem;
    color: var(--yt-text-secondary);
    margin-bottom: 1rem;
}
.read-more-btn {
    background-color: var(--yt-surface-hover);
    color: var(--yt-text-primary);
    border: 1px solid var(--yt-border);
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 1rem;
    font-weight: 500;
}
#comments-section {
    margin-top: 1.5rem;
}
#comments-section h3 {
    font-size: 1.2rem;
    color: var(--yt-text-primary);
    margin-bottom: 1rem;
}
#comments-list .comment {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}
#comment-form {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}
#comment-input {
    flex-grow: 1;
    background-color: #121212;
    border: 1px solid var(--yt-border);
    color: var(--yt-text-primary);
    padding: 0.8rem 1rem;
    border-radius: 20px;
    resize: vertical;
}
#comment-form button {
    background-color: var(--yt-surface-hover);
    color: var(--yt-text-primary);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
}

/*
==============================================
:QUEUE PANEL & OTHER UI
==============================================
*/
#queue-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    max-height: 400px;
    background-color: var(--yt-surface);
    border: 1px solid var(--yt-border);
    border-radius: 12px;
    z-index: 950;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    transform: translateY(20px);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
#queue-panel:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}
#queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--yt-border);
}
#queue-header h3 { margin: 0; }
#queue-close-btn { background: none; border: none; color: var(--yt-text-secondary); font-size: 1.5rem; cursor: pointer; }
#queue-list { list-style: none; padding: 0.5rem; margin: 0; overflow-y: auto; flex-grow: 1; }
#queue-list li { padding: 0.5rem; font-size: 0.9rem; border-radius: 4px; }
#queue-list li:hover { background-color: var(--yt-surface-hover); }
#queue-controls { padding: 0.75rem; border-top: 1px solid var(--yt-border); }
#queue-play-btn {
    width: 100%;
    background-color: var(--yt-red);
    color: white;
    border: none;
    padding: 0.8rem;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
}
.filter-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.sort-dropdown {
    background-color: var(--yt-surface);
    color: var(--yt-text-primary);
    border: 1px solid var(--yt-border);
    padding: 0.6rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--yt-border);
    text-align: center;
}
.footer-link {
    color: var(--yt-text-secondary);
    font-size: 0.9rem;
    text-decoration: none;
    transition: color 0.2s;
}
.footer-link:hover {
    color: var(--yt-text-primary);
}
.home-banner {
    width: 100%; margin-bottom: 1.5rem; border-radius: 12px; overflow: hidden;
}
.home-banner img {
    width: 100%; aspect-ratio: 4 / 1; object-fit: cover; display: block;
}
.welcome-message {
    background-color: var(--yt-surface); text-align: center; padding: 2rem;
    border-radius: 12px; margin-bottom: 2.5rem;
}
.welcome-message h2 { margin: 0; font-size: 2rem; color: var(--yt-text-primary); }
.welcome-message p { margin: 0.5rem 0 0 0; font-size: 1.1rem; color: var(--yt-text-secondary); }
.welcome-message span { color: var(--yt-red); font-weight: bold; }

.home-section {
    margin-bottom: 2.5rem;
}
.home-section h3 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--yt-text-primary);
    border-bottom: 1px solid var(--yt-border);
    padding-bottom: 0.8rem;
    margin-bottom: 1.5rem;
}

/* NEW: Horizontal Scroll for Homepage Galleries */
.horizontal-scroll {
    display: flex;
    overflow-x: auto;
    padding-bottom: 1rem; /* Space for the scrollbar */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
}
.horizontal-scroll .gallery-item {
    flex-shrink: 0; /* Prevent items from shrinking */
    width: 320px; /* Set a fixed width for each item */
}

/* Make scrollbars dark and less obtrusive */
.horizontal-scroll::-webkit-scrollbar {
    height: 8px;
}
.horizontal-scroll::-webkit-scrollbar-track {
    background: var(--yt-surface);
}
.horizontal-scroll::-webkit-scrollbar-thumb {
    background: var(--yt-surface-hover);
    border-radius: 4px;
}
.blog-list-homepage .blog-post-summary { background-color: transparent; border: none; padding: 0; margin-bottom: 1rem; }
.blog-list-homepage .blog-post-summary h3 { font-size: 1.2rem; }

/*
==============================================
:RESPONSIVE DESIGN (MOBILE & TABLET)
==============================================
*/
/* --- Tablet View --- */
@media (max-width: 1024px) {
    #main-sidebar {
        width: 72px;
    }
    #main-sidebar.collapsed {
        transform: translateX(-100%);
    }
    #content-wrapper {
        padding-left: 72px;
    }
    #content-wrapper.sidebar-collapsed {
        padding-left: 0;
    }
    #modal-viewer {
        left: 72px;
    }
    #content-wrapper.sidebar-collapsed ~ #modal-viewer {
        left: 0;
    }
    
    .sidebar-nav .nav-item span { display: none; }
    .sidebar-nav .nav-item { flex-direction: column; gap: 0.4rem; padding: 1rem 0; }
    .sidebar-nav .nav-item i { margin: 0; }
    .logo-text { display: none; }
    .search-bar { display: none; }
    #watch-page-container {
        flex-direction: column;
    }
    .watch-page-sidebar {
        width: 100%;
    }
}

/* --- Mobile View --- */
@media (max-width: 768px) {
    #main-header {
        padding: 0 0.5rem;
    }
    .header-center {
        display: none;
    }
    
    /* Hide desktop sidebar, show mobile bottom bar */
    #main-sidebar {
        bottom: 0;
        top: auto;
        left: 0;
        width: 100%;
        height: 60px;
        flex-direction: row;
        padding-top: 0;
        border-top: 1px solid var(--yt-border);
        border-right: none;
    }
    #main-sidebar .sidebar-nav {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        padding: 0;
    }
    .sidebar-nav .nav-item {
        flex: 1;
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.5rem 0;
        margin: 0;
        height: 100%;
        justify-content: center;
    }
    .sidebar-nav .nav-item span { display: block; font-size: 0.7rem; }
    .sidebar-nav .nav-item i { margin: 0; font-size: 1.2rem; }
    .sidebar-nav hr { display: none; }
    
    #content-wrapper {
        padding-left: 0;
        padding-top: 56px;
        padding-bottom: 60px; /* Space for bottom nav */
    }
    
    /* CORRECTED: Modal viewer positioning for mobile */
    #modal-viewer,
    #content-wrapper.sidebar-collapsed ~ #modal-viewer {
        top: 56px; /* Start below the top header */
        left: 0;
        bottom: 60px; /* End above the bottom nav */
        padding-bottom: 0;
    }

    #watch-page-container {
        padding: 0.5rem;
        gap: 1rem;
    }
    #modal-title { font-size: 1.2rem; }
    .action-buttons button { padding: 0.5rem 0.8rem; font-size: 0.8rem; }
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .header-right .patron-info { display: none; }
    #sidebar-toggle-btn { display: none; } /* Hide hamburger on mobile */
}

/* Advanced Search Dropdown */
.header-center {
    position: relative;
}
#search-category-btn { /* Style the button to be part of the search bar */
    background-color: var(--yt-surface);
    border: 1px solid var(--yt-border);
    border-right: none;
    color: var(--yt-text-secondary);
    padding: 0.6rem 1rem;
    border-radius: 20px 0 0 20px;
    cursor: pointer;
}
#main-search-input { /* Remove left border radius */
    border-radius: 0;
}
#search-category-dropdown {
    position: absolute;
    top: 50px;
    left: 0;
    background-color: var(--yt-surface);
    border: 1px solid var(--yt-border);
    border-radius: 12px;
    z-index: 110;
    display: none;
    padding: 0.5rem;
}
#search-category-dropdown.active {
    display: block;
}
#search-category-dropdown a {
    display: block;
    color: var(--yt-text-primary);
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: 8px;
}
#search-category-dropdown a:hover {
    background-color: var(--yt-surface-hover);
}

/* Clickable Tags in Modal */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.tag-link {
    background-color: var(--yt-surface-hover);
    color: var(--yt-text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}
.tag-link:hover {
    background-color: var(--yt-red);
    color: white;
}

.header-center {
    position: relative;
    flex-grow: 1;
    display: flex;
    justify-content: center;
}
.search-bar {
    position: relative; /* For dropdown positioning */
    max-width: 600px;
    width: 100%;
    display: flex;
}
#main-search-input {
    border-radius: 20px 0 0 20px;
    width: 100%;
}
#search-category-dropdown {
    position: absolute;
    top: 50px; /* Position below the search bar */
    left: 0;
    right: 0;
    background-color: var(--yt-surface);
    border: 1px solid var(--yt-border);
    border-radius: 12px;
    z-index: 110;
    display: none;
    padding: 0.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
#search-category-dropdown.active {
    display: block;
}
#search-category-dropdown a {
    display: block;
    color: var(--yt-text-primary);
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: 8px;
}
#search-category-dropdown a:hover {
    background-color: var(--yt-surface-hover);
}


/* Clickable Tags in Modal */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--yt-border);
    padding-bottom: 1rem;
}
.tag-link {
    background-color: var(--yt-surface-hover);
    color: var(--yt-text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}
.tag-link:hover {
    background-color: var(--yt-red);
    color: white;
}