:root {
    --bg-dark: #0f0f0f;
    --bg-card: #1e1e1e;
    --bg-header: #202020;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --accent: #3ea6ff; /* Blue */
    --accent-hover: #2680c2;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', Arial, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* --- HEADER --- */
header {
    background-color: var(--bg-header);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.logo { font-size: 1.5rem; font-weight: bold; }
.logo .highlight { color: var(--accent); }

.search-bar {
    display: flex;
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
}

.search-bar input {
    width: 100%;
    padding: 8px 15px;
    background: #121212;
    border: 1px solid #333;
    color: white;
    outline: none;
}

.search-bar button {
    padding: 0 20px;
    background: #333;
    border: 1px solid #333;
    color: var(--text-muted);
    cursor: pointer;
}

.search-bar button:hover { color: white; }

/* --- HOME LAYOUT --- */
.container {
    display: flex;
    flex: 1;
    padding: 20px;
    gap: 20px;
}

/* Sidebar (Home) */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    display: none; /* Hidden on small mobile by default */
}
@media(min-width: 900px) { .sidebar { display: block; } }

.filter-section select {
    width: 100%;
    padding: 8px;
    background: var(--bg-card);
    color: white;
    border: 1px solid #333;
    margin-bottom: 20px;
}

.trending-section h3 { margin-bottom: 15px; font-size: 1rem; color: var(--text-muted); }

/* --- VIDEO GRID (PC DEFAULT) --- */
.content-area {
    flex-grow: 1;
}

.video-grid {
    display: grid;
    /* PC: Fits as many as possible (usually 4-5) */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

/* Video Card Style */
.video-card {
    background: var(--bg-card);
    cursor: pointer;
    transition: transform 0.2s;
}

.video-card:hover { transform: scale(1.02); z-index: 2; }

.thumb {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 */
    background: #000;
}

.thumb img {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
}

.duration {
    position: absolute;
    bottom: 5px; right: 5px;
    background: rgba(0,0,0,0.8);
    padding: 2px 4px;
    font-size: 11px;
    border-radius: 2px;
}

.card-info { padding: 10px; }
.card-title {
    font-size: 0.95rem;
    margin-bottom: 5px;
    line-height: 1.3;
    max-height: 2.6rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.card-meta { font-size: 0.8rem; color: var(--text-muted); }

/* --- WATCH PAGE LAYOUT --- */
.watch-container {
    display: flex;
    flex-wrap: wrap;
    padding: 20px;
    gap: 24px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.player-section {
    flex: 1;
    min-width: 600px; 
}

.video-frame-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; 
    background: #000;
}

.video-frame-wrapper iframe {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
}

.video-details { margin-top: 15px; }
.video-details h1 { font-size: 1.4rem; margin-bottom: 10px; }
.video-stats { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 10px; }
.video-desc { margin-top: 15px; line-height: 1.5; white-space: pre-wrap; }
.tags-cloud { margin-top: 15px; }
.tag { display: inline-block; background: #333; padding: 5px 10px; margin-right: 5px; border-radius: 15px; font-size: 0.8rem; color: var(--accent); }

.related-section {
    width: 350px;
    flex-shrink: 0;
}

/* Sidebar List Items */
.list-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
}
.list-item img { width: 160px; height: 90px; object-fit: cover; }
.list-item-info h4 { font-size: 0.9rem; margin-bottom: 4px; line-height: 1.2; }
.list-item-info span { font-size: 0.8rem; color: var(--text-muted); }

/* --- FOOTER --- */
footer {
    margin-top: auto;
    background: var(--bg-header);
    padding: 20px;
    text-align: center;
    border-top: 1px solid #333;
}

.footer-links a { margin: 0 10px; color: var(--accent); }

.pagination { display: flex; justify-content: center; padding: 20px; gap: 10px; }
.pagination button { padding: 8px 16px; background: #333; color: white; border: none; cursor: pointer; }
.pagination button:disabled { opacity: 0.5; cursor: default; }

/* =========================================
   MOBILE OPTIMIZATION (2 Columns)
   ========================================= */
@media (max-width: 768px) {
    /* Header Adjustments */
    header { padding: 0 10px; }
    .logo { font-size: 1.2rem; }
    .search-bar { margin: 0 10px; }
    .search-bar button { padding: 0 10px; }
    
    /* Layout Adjustments */
    .container { padding: 10px; }
    .sidebar { display: none !important; } /* Hide sidebar on mobile */

    /* FORCE 2 COLUMNS ON MOBILE */
    .video-grid {
        grid-template-columns: repeat(2, 1fr); /* Exactly 2 columns */
        gap: 10px; /* Smaller gap */
    }

    /* Smaller text for mobile cards */
    .card-title { font-size: 0.85rem; }
    .card-meta { font-size: 0.75rem; }
    .card-info { padding: 8px; }

    /* Watch Page Mobile */
    .watch-container { padding: 10px; }
    .player-section { min-width: 100%; }
    .related-section { width: 100%; }
    .video-details h1 { font-size: 1.1rem; }
}
