/* --- CORE CSS (Mobile optimized CSS remains the same) --- */
:root {
    --primary: #3ea6ff; 
    --primary-dark: #065fd4;
    --secondary: #eef4ff;
    --accent-red: #ff4e45;
    --accent-green: #00c851;
    --accent-purple: #a855f7;
    --accent-yellow: #ffbb33;
    --accent-orange: #ff8800;
    --white: #ffffff; 
    --black: #0f0f0f; 
    --text-main: #222222;
    --text-light: #606060;
    --border: #e0e0e0;
    --sidebar-w: 250px; 
    --header-h: 64px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.1);
    --bg-body: #f9f9f9;
    --bg-nav: rgba(255,255,255,0.95);
    --bg-studio: #f4f6f8;
    --card-gradient: linear-gradient(135deg, #ffffff, #fff176);
    --card-border-hover: rgba(255, 235, 59, 0.5);
}

/* --- DARK THEME VARIABLES --- */
body.dark-mode {
    --primary: #3ea6ff;
    --primary-dark: #6ab5ff; 
    --secondary: #262626;
    --white: #1f1f1f;
    --black: #ffffff;
    --text-main: #f1f1f1;
    --text-light: #aaaaaa;
    --border: #333333;
    --bg-body: #0f0f0f;
    --bg-nav: rgba(20,20,20,0.95);
    --bg-studio: #121212;
    --card-gradient: linear-gradient(135deg, #1e1e1e, #4a3b00); 
    --card-border-hover: rgba(255, 215, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; }
body { background: var(--bg-body); color: var(--text-main); overflow-x: hidden; transition: background 0.3s, color 0.3s; }
button { cursor: pointer; border: none; background: none; font-family: inherit; transition: 0.25s ease; }
a { text-decoration: none; color: inherit; cursor: pointer; }
img { object-fit: cover; display: block; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--primary-dark); }

/* --- NAVBAR --- */
nav {
    position: fixed; top: 0; left: 0; width: 100%; height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; background: var(--bg-nav); 
    backdrop-filter: blur(8px);
    z-index: 1000; box-shadow: var(--shadow-sm);
    border-bottom: 1px solid transparent;
}
body.dark-mode nav { border-bottom: 1px solid var(--border); }

.nav-left { display: flex; align-items: center; gap: 16px; }
.logo { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 22px; letter-spacing: -0.5px; color: var(--black); }
.logo span.material-symbols-rounded { font-size: 34px; background: linear-gradient(45deg, var(--primary-dark), var(--primary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.nav-middle { flex: 1; max-width: 650px; margin: 0 20px; display: flex; justify-content: center; }
.search-container { display: flex; width: 100%; max-width: 600px; height: 44px; border-radius: 50px; border: 1px solid var(--border); overflow: hidden; background: var(--white); box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); transition: 0.3s; }
.search-container:focus-within { box-shadow: 0 2px 8px rgba(62, 166, 255, 0.2); border-color: var(--primary); }
.search-container input { flex: 1; padding: 0 20px; border: none; outline: none; font-size: 15px; color: var(--text-main); background: transparent; }

.search-btn { 
    width: 64px; background: var(--primary); border-left: 1px solid var(--primary); 
    display: flex; align-items: center; justify-content: center; color: #ffffff; 
}
.search-btn:hover { background: var(--primary-dark); color: #ffffff; }

.nav-right { display: flex; align-items: center; gap: 12px; }
.icon-btn { width: 40px; height: 40px; display:flex; align-items:center; justify-content:center; border-radius: 50%; color: var(--text-main); transition: 0.2s; position: relative; }
.icon-btn:hover { background: var(--secondary); color: var(--primary-dark); }
.icon-btn .material-symbols-rounded { font-size: 26px; }

.notif-badge { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; background: var(--accent-red); border-radius: 50%; display: none; border: 2px solid white; }

/* Notification Dropdown */
.notif-dropdown {
    position: absolute; top: 60px; right: 70px; width: 340px; background: var(--white);
    border-radius: 16px; box-shadow: var(--shadow-md);
    display: none; flex-direction: column; max-height: 400px; overflow-y: auto; z-index: 2000;
    animation: fadeIn 0.2s ease; border: 1px solid var(--border);
}
.notif-item { display: flex; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: 0.2s; }
.notif-item:hover { background: var(--secondary); }
.notif-item img { width: 64px; height: 36px; border-radius: 6px; object-fit: cover; }

.auth-btn { padding: 8px 18px; border: 1px solid var(--border); border-radius: 30px; color: var(--primary-dark); font-weight: 600; display: flex; align-items: center; gap: 8px; font-size: 14px; background: var(--white); transition: 0.2s; }
.auth-btn:hover { background: var(--secondary); border-color: var(--primary); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; display: flex; justify-content: center; align-items: center; font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }

/* --- SIDEBAR --- */
.sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0;
    width: var(--sidebar-w); background: var(--white);
    overflow-y: auto; z-index: 1050; 
    padding: 16px 12px;
    transform: translateX(0); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid transparent;
}
.sidebar.closed { transform: translateX(-100%); }

.menu-item { display: flex; align-items: center; gap: 20px; padding: 12px 16px; border-radius: 12px; cursor: pointer; margin-bottom: 4px; color: var(--text-main); font-weight: 500; font-size: 15px; }
.menu-item:hover { background: var(--secondary); }
.menu-item.active { background: var(--secondary); color: var(--primary-dark); font-weight: 600; }

.menu-item .material-symbols-rounded { font-size: 26px; transition: 0.2s; }
.menu-item:hover .material-symbols-rounded { transform: scale(1.1); }

/* Sidebar Colors */
.icon-home { color: var(--accent-red); }
.icon-studio { color: var(--accent-yellow); }
.icon-history { color: var(--accent-purple); }
.icon-liked { color: var(--primary); }
.icon-logout { color: var(--text-light); }

.sub-header { margin: 24px 16px 12px; font-size: 15px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }

.sub-list-item { display: flex; align-items: center; gap: 14px; padding: 10px 16px; cursor: pointer; border-radius: 12px; transition: 0.2s; }
.sub-list-item:hover { background: var(--secondary); }
.sub-list-item img { width: 28px; height: 28px; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* --- MAIN CONTENT & CATEGORIES --- */
.main-container {
    margin-top: var(--header-h); margin-left: var(--sidebar-w);
    padding: 30px; transition: margin-left 0.3s ease; min-height: 100vh;
}
.main-container.full { margin-left: 0; }

/* CATEGORY BUBBLES */
.category-bar {
    display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 24px;
    scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }

.cat-pill {
    white-space: nowrap; padding: 8px 20px; border-radius: 20px; 
    font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.3s;
    color: white; border: none; flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.cat-pill:hover { transform: translateY(-2px); opacity: 0.9; }
.cat-pill.active { transform: scale(1.05); box-shadow: 0 6px 15px rgba(0,0,0,0.2); border: 2px solid white; }

.page-title { margin-bottom: 24px; font-size: 24px; font-weight: 700; display: none; color: var(--black); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; row-gap: 40px; }

/* CARD */
.card { 
    cursor: pointer; display: flex; flex-direction: column; gap: 12px; 
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: var(--card-gradient);
    padding: 10px; border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03); border: 1px solid transparent;
}
.card:hover { 
    transform: translateY(-8px); 
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
    border-color: var(--card-border-hover);
}
.thumb-box { 
    position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 12px; 
    overflow: hidden; background: #eee; 
}
.thumb-box img { width: 100%; height: 100%; transition: 0.5s; }
.card:hover .thumb-box img { transform: scale(1.05); }
.dur-badge { 
    position: absolute; bottom: 8px; right: 8px; 
    background: linear-gradient(135deg, rgba(0,0,0,0.8), rgba(0,0,0,0.6)); 
    backdrop-filter: blur(4px); color: white; padding: 4px 8px; 
    border-radius: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
}

.meta-flex { display: flex; gap: 14px; align-items: flex-start; padding: 4px; }
.chn-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.15); border: 2px solid white; }
.meta-text h3 { font-size: 16px; font-weight: 600; line-height: 1.4; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text-main); }
.meta-text p { font-size: 13px; color: var(--text-light); margin-bottom: 2px; font-weight: 500; }

/* --- WATCH PAGE --- */
.overlay-screen {
    position: fixed; top: var(--header-h); left: 0; width: 100%; height: calc(100vh - var(--header-h));
    background: var(--bg-body); z-index: 1100; overflow-y: auto; display: none;
}
.watch-content { max-width: 1100px; margin: 0 auto; padding: 30px; }
.player-wrapper { width: 100%; aspect-ratio: 16/9; background: black; border-radius: 20px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
iframe { width: 100%; height: 100%; }

.vid-info h1 { font-size: 22px; margin: 16px 0 10px; font-weight: 700; color: var(--black); }
.actions-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.chn-actions { display: flex; align-items: center; gap: 14px; }

.sub-btn { background: var(--black); color: var(--bg-body); padding: 0 24px; height: 44px; border-radius: 30px; font-weight: 600; font-size: 14px; transition: 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.sub-btn:hover { opacity: 0.9; transform: scale(1.03); }
.sub-btn.subscribed { background: var(--secondary); color: var(--primary-dark); box-shadow: none; border: 1px solid rgba(0,0,0,0.05); }

.btn-pill { display: flex; align-items: center; gap: 8px; background: var(--secondary); height: 44px; padding: 0 20px; border-radius: 22px; font-size: 14px; font-weight: 600; transition: 0.2s; color: var(--text-main); }
.btn-pill:hover { background: var(--border); }
.btn-pill .material-symbols-rounded { font-size: 22px; }

.btn-like .material-symbols-rounded { color: var(--primary); }
.btn-dislike .material-symbols-rounded { color: var(--accent-red); }
.btn-share .material-symbols-rounded { color: var(--accent-orange); }
.btn-pill.active { background: linear-gradient(135deg, var(--secondary), #d0e0ff); color: var(--primary-dark); border: 1px solid rgba(62,166,255,0.2); }

.desc-box { background: var(--secondary); padding: 20px; border-radius: 16px; margin-top: 24px; font-size: 14px; white-space: pre-wrap; cursor:pointer; color: var(--text-main); border: 1px solid var(--border); }

/* Comments */
.comments-section { margin-top: 30px; max-width: 1100px; }
.comment-input-area { display: flex; gap: 16px; margin-bottom: 30px; align-items: flex-start; }
.comment-input-area input { flex: 1; border: none; border-bottom: 1px solid #ddd; outline: none; padding: 8px 0; font-size: 15px; transition: 0.3s; background: transparent; color: var(--text-main); }
.comment-input-area input:focus { border-bottom: 2px solid var(--primary); }
.comment-item { display: flex; gap: 16px; margin-bottom: 24px; }
.comment-meta { display: flex; gap: 8px; font-size: 13px; margin-bottom: 4px; align-items: center; }
.comment-author { font-weight: 600; font-size: 14px; color: var(--black); }
.comment-text { font-size: 14px; line-height: 1.5; color: var(--text-main); }

/* --- STUDIO & ANALYTICS --- */
.studio-layout { display: flex; height: 100%; background: var(--bg-studio); }
.studio-nav { width: 250px; border-right: 1px solid var(--border); padding: 24px; display: flex; flex-direction: column; gap: 12px; background: var(--white); }
.studio-main { flex: 1; padding: 40px; overflow-y: auto; }

.st-card { background: var(--white); border: none; border-radius: 16px; padding: 28px; margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.st-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-bottom: 30px; }

.stat-box { 
    padding: 24px; border-radius: 16px; text-align: center; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); transition: 0.2s; border: none; color: white; 
}
.stat-box:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0,0,0,0.15); }
.stat-box h2 { color: white; font-size: 36px; font-weight: 700; margin-bottom: 5px; }
.stat-box p { color: rgba(255,255,255,0.9); font-weight: 500; }

.stat-box:nth-child(1) { background: linear-gradient(135deg, #3ea6ff, #065fd4); }
.stat-box:nth-child(2) { background: linear-gradient(135deg, #ff8800, #ff4e45); }
.stat-box:nth-child(3) { background: linear-gradient(135deg, #00c851, #007e33); }

.video-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; margin-top: 10px; }
.video-table th { text-align: left; color: var(--text-light); font-size: 12px; font-weight: 600; padding: 10px 15px; text-transform: uppercase; letter-spacing: 0.5px; }
.video-table td { padding: 14px 15px; background: var(--secondary); vertical-align: middle; font-size: 14px; border-top: 1px solid var(--bg-studio); border-bottom: 1px solid var(--bg-studio); color: var(--text-main); }
.video-table tr td:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; border-left: 1px solid var(--bg-studio); }
.video-table tr td:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; border-right: 1px solid var(--bg-studio); }
.video-table tr:hover td { background: var(--bg-studio); }

.action-icon { padding: 8px; border-radius: 50%; transition: 0.2s; background: var(--white); margin-right: 4px; }
.action-icon:hover { transform: scale(1.1); }
.action-icon.view { color: var(--accent-green); }
.action-icon.view:hover { background: #e8f5e9; }
.action-icon.edit { color: var(--accent-purple); }
.action-icon.edit:hover { background: #f3e5f5; }
.action-icon.delete { color: var(--accent-red); }
.action-icon.delete:hover { background: #ffebee; }

/* Modal */
.modal-wrap { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 2000; display: none; align-items: center; justify-content: center; }
.modal-box { background: var(--white); width: 90%; max-width: 500px; padding: 32px; border-radius: 20px; position: relative; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.2); animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes scaleUp { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.inp-group { margin-bottom: 18px; }
.inp-group label { display: block; font-size: 13px; color: var(--text-light); margin-bottom: 6px; font-weight: 600; }
.inp-group input, .inp-group textarea, .inp-group select { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; outline: none; font-size: 14px; background: var(--secondary); color: var(--text-main); transition: 0.2s; }
.inp-group input:focus, .inp-group textarea:focus, .inp-group select:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(62, 166, 255, 0.15); }

.btn-primary { width: 100%; background: linear-gradient(90deg, var(--primary-dark), var(--primary)); color: white; padding: 12px; border-radius: 8px; font-weight: 600; text-transform: uppercase; font-size: 14px; letter-spacing: 0.5px; box-shadow: 0 4px 12px rgba(6, 95, 212, 0.3); transition: 0.3s; }
.btn-primary:hover { box-shadow: 0 6px 16px rgba(6, 95, 212, 0.4); transform: translateY(-1px); }

/* Analytics Charts */
.chart-wrapper { position: relative; height: 280px; width: 100%; margin-bottom: 30px; padding: 15px; background: var(--white); border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.green-bar-chart { border-bottom: none; }

@keyframes fadeIn { from{opacity:0; transform:translateY(-10px);} to{opacity:1; transform:translateY(0);} }

/* MOBILE RESPONSIVE OPTIMIZATIONS */
@media (max-width: 768px) {
    /* Navbar */
    nav { padding: 0 10px; }
    .nav-left { gap: 8px; }
    .logo { font-size: 18px; }
    .logo span.material-symbols-rounded { font-size: 30px; }
    .nav-middle { display: none; }
    .nav-middle.show-search { 
        display: flex; 
        position: absolute; 
        top: 0; left: 0; 
        width: 100%; 
        height: var(--header-h); 
        background: var(--white); 
        z-index: 1001; 
        padding: 0 10px; 
    }
    .search-container { max-width: 100%; }
    .nav-right { gap: 5px; } 
    .icon-btn { width: 36px; height: 36px; }
    .auth-btn { padding: 6px 14px; font-size: 13px; }
    
    /* Sidebar */
    .sidebar { 
        transform: translateX(-100%); 
        width: 260px; 
        box-shadow: 2px 0 20px rgba(0,0,0,0.3);
        z-index: 1050; 
    }
    .sidebar.mobile-open { transform: translateX(0); }
    
    /* Main Content & Grid */
    .main-container { margin-left: 0; padding: 16px; }
    .main-container.full { margin-left: 0; }
    .grid { grid-template-columns: 1fr; gap: 16px; row-gap: 30px; }

    /* Watch View */
    .watch-content { padding: 15px; }
    .player-wrapper { border-radius: 12px; }
    .vid-info h1 { font-size: 20px; }
    .actions-bar { flex-direction: column; align-items: flex-start; }
    .chn-actions { width: 100%; justify-content: space-between; gap: 0; }
    .chn-actions > div { flex: 1; margin-right: 10px; }
    .desc-box { padding: 15px; }
    
    /* Studio */
    .studio-layout { flex-direction: column; }
    .studio-nav { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 15px; }
    .studio-main { padding: 15px; }
    .st-card { padding: 20px; }

    /* Table Scroll for Studio */
    .video-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .video-table { min-width: 600px; } 
}
.mobile-search-trigger { display: none; }
@media(max-width: 768px) { 
    .mobile-search-trigger { display: flex; } 
    .notif-dropdown { right: 10px; }
}
