/* ── Parallax Design System ─────────────────────────────────────────────── */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #14141f;
    --bg-hover: #1a1a2e;
    --border: #1e1e30;
    --text-primary: #e8e8ed;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #7c5cfc;
    --accent-hover: #6a4fe0;
    --danger: #ef4444;
    --warning: #f59e0b;
    --green: #4ade80;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; }

/* ── Navbar ──────────────────────────────────────────────────────────────── */

.navbar {
    position: sticky; top: 0; z-index: 100;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    height: 56px;
}
.nav-inner {
    max-width: 100%; height: 100%;
    display: flex; align-items: center; gap: 16px;
    padding: 0 16px;
}

.nav-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.logo-icon { color: var(--accent); font-size: 24px; }
.logo-text { color: var(--text-primary); }
.logo-text-only {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: 16px; font-weight: 600; letter-spacing: 6px;
    color: var(--accent);
    text-transform: uppercase;
}
.logo-text-only:hover { color: #a78bfa; }
.sidebar-toggle { background: none; border: none; color: var(--text-primary); padding: 4px; border-radius: 50%; display: flex; }
.sidebar-toggle:hover { background: var(--bg-hover); }

.nav-center { flex: 1; max-width: 640px; margin: 0 auto; }
.search-form { display: flex; width: 100%; }
.search-form input {
    flex: 1; padding: 8px 16px;
    background: var(--bg-secondary); border: 1px solid var(--border); border-right: none;
    border-radius: 20px 0 0 20px; color: var(--text-primary); outline: none; font-size: 14px;
}
.search-form input:focus { border-color: var(--accent); }
.search-form button {
    padding: 8px 16px; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 0 20px 20px 0; color: var(--text-secondary); display: flex; align-items: center;
}
.search-form button:hover { background: var(--bg-hover); }

.nav-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-upload {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px; background: var(--accent); color: #fff;
    border-radius: 20px; font-size: 14px; font-weight: 600;
    transition: background 0.15s;
}
.btn-upload:hover { background: var(--accent-hover); }
.btn-upload svg { width: 18px; height: 18px; }

.btn-signin {
    padding: 8px 16px; border: 1px solid var(--border); border-radius: 20px;
    font-size: 14px; font-weight: 500; color: var(--text-primary);
    transition: background 0.15s;
}
.btn-signin:hover { background: var(--bg-hover); }

.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: 1px solid var(--border); border-radius: 20px;
    padding: 4px 12px 4px 4px; color: var(--text-primary); font-size: 14px;
}
.user-btn:hover { background: var(--bg-hover); }
.avatar-sm {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.username-nav { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-dropdown {
    position: absolute; top: 100%; right: 0; margin-top: 8px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px; min-width: 200px;
    box-shadow: var(--shadow); z-index: 200;
}
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.user-dropdown a { display: block; padding: 6px 8px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text-secondary); }
.user-dropdown a:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-label { font-size: 13px; color: var(--text-muted); }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.app-layout { display: flex; min-height: calc(100vh - 56px - 60px); }
.main-content { flex: 1; padding: 24px; max-width: 1800px; }
.footer { border-top: 1px solid var(--border); padding: 20px 24px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; max-width: 1800px; margin: 0 auto; }
.footer-links { display: flex; gap: 16px; }
.footer-links a { font-size: 13px; color: var(--text-muted); }
.footer-links a:hover { color: var(--text-secondary); }
.footer-copy { font-size: 13px; color: var(--text-muted); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
    width: 220px; flex-shrink: 0;
    padding: 12px 8px; background: var(--bg-primary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}
.sidebar-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    font-size: 14px; color: var(--text-secondary);
    transition: background 0.1s;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active { background: var(--bg-hover); color: var(--text-primary); font-weight: 600; }

/* ── Video Grid ──────────────────────────────────────────────────────────── */

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

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.video-grid.horizontal-scroll { grid-template-columns: repeat(4, 1fr); }
.video-grid.tight { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.video-card { display: block; border-radius: var(--radius); overflow: hidden; transition: transform 0.15s; }
.video-card:hover { transform: translateY(-2px); }
.video-card.wide { grid-column: span 1; }

.thumb {
    position: relative; width: 100%; padding-top: 56.25%; /* 16:9 */
    border-radius: var(--radius); overflow: hidden;
    background-size: cover !important;
    background-position: center !important;
}
.related-thumb {
    background-size: cover !important;
    background-position: center !important;
}
.thumb-play {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.15s;
    font-size: 40px; color: #fff;
}
.video-card:hover .thumb-play { opacity: 1; }

.thumb-duration {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,0.85); color: #fff;
    padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 600;
}
.thumb-views {
    position: absolute; bottom: 6px; left: 6px;
    background: rgba(0,0,0,0.85); color: #ccc;
    padding: 2px 6px; border-radius: 4px; font-size: 11px;
}
.thumb-duration-sm {
    position: absolute; bottom: 2px; right: 2px;
    background: rgba(0,0,0,0.85); color: #fff;
    padding: 1px 4px; border-radius: 3px; font-size: 10px; font-weight: 600;
}

.card-info { padding: 10px 4px; }
.card-title {
    font-size: 14px; font-weight: 600; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 4px;
}
.card-meta { font-size: 13px; color: var(--text-muted); }
.card-desc { font-size: 13px; color: var(--text-muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Watch Page ──────────────────────────────────────────────────────────── */

.watch-layout { display: flex; gap: 24px; max-width: 1400px; }
.watch-main { flex: 1; min-width: 0; }
.watch-sidebar { width: 380px; flex-shrink: 0; }

.player-container { margin-bottom: 16px; border-radius: var(--radius); overflow: hidden; }
.player-placeholder {
    width: 100%; padding-top: 56.25%; position: relative;
}
.player-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.play-btn-big {
    width: 100px; height: 100px; border-radius: 50%;
    background: rgba(124,92,252,0.85); border: none;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s, background 0.15s;
}
.play-btn-big:hover { transform: scale(1.1); background: var(--accent); }

.video-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.video-stats { display: flex; gap: 12px; font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }

.video-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.action-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 20px; color: var(--text-secondary); font-size: 13px;
}
.action-btn:hover { background: var(--bg-hover); }

.video-description { background: var(--bg-tertiary); border-radius: var(--radius); padding: 16px; font-size: 14px; margin-bottom: 24px; }
.video-description p { white-space: pre-line; }
.uploaded-by { margin-top: 8px; font-size: 13px; color: var(--text-muted); }

/* ── Comments ────────────────────────────────────────────────────────────── */

.comments-section { margin-bottom: 32px; }
.comments-heading { font-size: 18px; margin-bottom: 16px; }

.comment-form { display: flex; gap: 10px; align-items: center; margin-bottom: 24px; }
.comment-form input {
    flex: 1; padding: 10px 14px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: 20px; color: var(--text-primary); outline: none;
}
.comment-form input:focus { border-color: var(--accent); }
.comment-form button {
    padding: 10px 20px; background: var(--accent); color: #fff;
    border: none; border-radius: 20px; font-weight: 600; font-size: 14px;
}
.comment-form button:hover { background: var(--accent-hover); }

.comment { display: flex; gap: 12px; margin-bottom: 16px; }
.comment-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.comment-body { flex: 1; }
.comment-author { font-size: 13px; font-weight: 600; }
.comment-time { font-size: 12px; color: var(--text-muted); margin-left: 8px; }
.comment-body p { font-size: 14px; margin-top: 4px; white-space: pre-line; }

/* ── Related video cards ─────────────────────────────────────────────────── */

.sidebar-heading { font-size: 18px; font-weight: 700; margin-bottom: 12px; }

.related-card { display: flex; gap: 10px; margin-bottom: 10px; padding: 4px; border-radius: var(--radius); }
.related-card:hover { background: var(--bg-hover); }
.related-thumb {
    width: 160px; flex-shrink: 0; border-radius: var(--radius-sm); overflow: hidden;
    position: relative; padding-top: 0; height: 90px; background-size: cover;
}
.related-info { flex: 1; min-width: 0; }
.related-info h4 {
    font-size: 13px; font-weight: 600; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 2px;
}
.related-info p { font-size: 12px; color: var(--text-muted); }

/* ── Browse / Search ─────────────────────────────────────────────────────── */

.browse-header { margin-bottom: 24px; }
.browse-header h1 { font-size: 28px; margin-bottom: 16px; }
.category-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
    padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border);
    font-size: 13px; color: var(--text-secondary); background: var(--bg-secondary);
    transition: all 0.15s;
}
.pill:hover { border-color: var(--accent); color: var(--text-primary); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.search-page h1 { font-size: 24px; margin-bottom: 24px; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 32px; }
.page-btn { padding: 10px 20px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 20px; font-size: 14px; color: var(--text-secondary); }
.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-info { font-size: 14px; color: var(--text-muted); }

/* ── Upload Page ─────────────────────────────────────────────────────────── */

.upload-page { max-width: 700px; }
.upload-page h1 { font-size: 28px; margin-bottom: 4px; }
.upload-subtitle { color: var(--text-muted); margin-bottom: 24px; }

.upload-zone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 48px; text-align: center; cursor: pointer; margin-bottom: 24px;
    transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--bg-secondary); }
.upload-cta { font-size: 16px; font-weight: 600; margin-top: 12px; }
.upload-limit { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.upload-filename { font-size: 14px; color: var(--accent); margin-top: 8px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 10px 14px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary); outline: none;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; }
.form-group select { appearance: none; cursor: pointer; }

.btn-submit {
    padding: 12px 28px; background: var(--accent); color: #fff;
    border: none; border-radius: 20px; font-size: 15px; font-weight: 600;
    transition: background 0.15s;
}
.btn-submit:hover { background: var(--accent-hover); }
.btn-submit.full { width: 100%; }

/* ── Auth Pages ──────────────────────────────────────────────────────────── */

.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 70vh; padding: 24px;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 32px;
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h1 { font-size: 22px; margin-top: 8px; }
.logo-icon.large { font-size: 48px; }

.auth-error { background: #3b1219; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.auth-message { background: #1a3d2d; color: var(--green); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }

.auth-form { margin-bottom: 16px; }
.auth-footer { text-align: center; font-size: 14px; color: var(--text-muted); }
.auth-footer a { color: var(--accent); }
.auth-footer a:hover { text-decoration: underline; }

/* ── Error Pages ─────────────────────────────────────────────────────────── */

.error-page { text-align: center; padding: 80px 24px; }
.error-icon { font-size: 64px; color: var(--accent); display: block; margin-bottom: 16px; }
.error-page h1 { font-size: 64px; font-weight: 800; margin-bottom: 8px; }
.error-page p { font-size: 18px; color: var(--text-secondary); }
.error-hint { font-size: 14px !important; margin-top: 16px; }
.error-hint a { color: var(--accent); }

/* ── Flash messages ──────────────────────────────────────────────────────── */

.flash-msg { padding: 10px 16px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state { text-align: center; color: var(--text-muted); padding: 48px; font-size: 16px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .watch-layout { flex-direction: column; }
    .watch-sidebar { width: 100%; }
    .video-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .video-grid.horizontal-scroll { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -280px; top: 56px; bottom: 0; z-index: 150; width: 260px; transition: left 0.2s; box-shadow: var(--shadow); }
    .sidebar.open { left: 0; }
    .overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 140; }
    .nav-center { flex: 1; }
    .username-nav, .btn-upload span { display: none; }
    .btn-upload { padding: 8px 12px; }
    .video-grid.horizontal-scroll { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
    .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
    .video-grid { grid-template-columns: 1fr; }
    .watch-sidebar { width: 100%; }
    .related-thumb { width: 120px; height: 68px; }
}

/* ── Video player ────────────────────────────────────────────────────────── */

.video-player { max-width: 100%; max-height: 65vh; display: block; margin: 0 auto; border-radius: var(--radius); background: #000; }
.video-player:focus { outline: none; }
.player-container { max-width: 1100px; margin: 0 auto; }

/* ── Upload progress ─────────────────────────────────────────────────────── */

.upload-progress { text-align: center; padding: 20px; }
.spinner {
    width: 40px; height: 40px; margin: 0 auto 12px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
