/* =========================================
 *  StreamFlow Layout
 *  ========================================= */

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

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

/* --- Header --- */
header {
    height: 70px; /* Will use var(--nav-height) once added to variables.css */
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    text-decoration: none;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.search-container {
    position: relative;
    flex-grow: 1;
    max-width: 500px;
}

.search-input {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: var(--font-size-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

.search-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.2);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background-color: var(--bg-color);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* --- Grids --- */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

/* --- Watch Page Layout --- */
.watch-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

.video-section {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.video-player {
    width: 100%;
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #2d3436, #636e72);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.video-player video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* FIXED: Removed border-bottom — the #videoDivider element handles this */
.video-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1rem;
    /* NO border-bottom here — watch.js toggles #videoDivider instead */
}

.poster-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.poster-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    flex-shrink: 0;
}

.poster-details {
    display: flex;
    flex-direction: column;
}

.poster-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.poster-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.video-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* FIXED: Reaction buttons (Like/Dislike) always stay side-by-side */
.reaction-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.video-date, .video-stats {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/*
 *  FIXED: Scoped description hiding to ONLY the Watch Page (.video-section).
 *  This prevents the textarea from being hidden on edit.html.
 */
.video-section #videoDescription {
    display: none;
    padding: 0.5rem 0;
    color: var(--text-main);
    line-height: 1.6;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

/* --- Sidebar --- */
.sidebar {
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* Desktop Layout: 2/3 Left, 1/3 Right */
@media (min-width: 992px) {
    .watch-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .video-section {
        width: 66.66%;
        flex: 0 0 66.66%;
        padding-right: 2rem;
    }

    .sidebar {
        width: 33.33%;
        flex: 0 0 33.33%;
        padding-left: 0;
        /* RESTORED: Sticky sidebar from old global.css */
        position: sticky;
        top: calc(70px + 2rem); /* nav-height + padding */
        max-height: calc(100vh - 70px - 4rem);
        overflow-y: auto;
    }
}

/* Tablet/Mobile adjustments */
@media (max-width: 991px) {
    .watch-layout {
        flex-direction: column;
    }

    .video-section, .sidebar {
        width: 100%;
        padding: 0;
    }
}

@media (max-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1.5rem;
    }

    .watch-layout {
        gap: 1.5rem;
    }

    header {
        padding: 0 1rem;
    }

    .search-container {
        display: none;
    }

    .nav-controls {
        gap: 0.8rem;
    }

    .video-meta-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .video-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    /* FIXED: Like/Dislike stay side-by-side on mobile */
    .reaction-buttons {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
    }

    .reaction-buttons .action-btn {
        flex: 1;
        justify-content: center;
    }

    /* FIXED: Follow button sits on its own line, full width */
    .action-btn.follow {
        width: 100%;
        justify-content: center;
        margin-top: 0.25rem;
    }
}

/* --- Profile Layout --- */
.profile-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.content-area {
    margin-top: 2rem;
}

.section-title {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    font-weight: 700;
}

/* --- Empty States --- */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}
