@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
    --yt-bg-primary: #0f0f0f;
    --yt-bg-secondary: #0f0f0f;
    --yt-bg-tertiary: #272727;
    --yt-bg-elevated: #212121;
    --yt-bg-hover: #3d3d3d;
    --yt-bg-active: #3d3d3d;
    --yt-red: #ff0000;
    --yt-red-hover: #cc0000;
    --yt-blue: #3ea6ff;
    --yt-green: #2ba640;
    --yt-text-primary: #f1f1f1;
    --yt-text-secondary: #aaaaaa;
    --yt-text-muted: #717171;
    --yt-border: rgba(255, 255, 255, 0.1);
    --yt-border-light: rgba(255, 255, 255, 0.2);
    --header-height: 56px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 72px;
    --radius-sm: 2px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 12px;
    --radius-full: 9999px;
    --transition-fast: 0.1s ease;
    --transition-normal: 0.2s ease;
}

[data-theme="light"] {
    --yt-bg-primary: #ffffff;
    --yt-bg-secondary: #f9f9f9;
    --yt-bg-tertiary: #f2f2f2;
    --yt-bg-elevated: #ffffff;
    --yt-bg-hover: #e5e5e5;
    --yt-bg-active: #e5e5e5;
    --yt-text-primary: #0f0f0f;
    --yt-text-secondary: #606060;
    --yt-text-muted: #909090;
    --yt-border: rgba(0, 0, 0, 0.1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: 'Roboto', 'Arial', sans-serif; background: var(--yt-bg-primary); color: var(--yt-text-primary); line-height: 1.4; overflow-x: hidden; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }
ul, ol { list-style: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--yt-bg-tertiary); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--yt-text-muted); }

.header { position: fixed; top: 0; left: 0; right: 0; height: var(--header-height); background: var(--yt-bg-primary); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; z-index: 1000; }
.header-start { display: flex; align-items: center; gap: 16px; min-width: 200px; }
.menu-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); transition: background var(--transition-fast); }
.menu-btn:hover { background: var(--yt-bg-hover); }
.menu-btn svg { width: 24px; height: 24px; }
.logo { display: flex; align-items: center; gap: 1px; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.5px; }
.logo-icon { width: 30px; height: 20px; background: var(--yt-red); border-radius: 4px; display: flex; align-items: center; justify-content: center; color: white; margin-right: 3px; }
.logo-icon svg { width: 12px; height: 12px; }

.header-center { flex: 1; max-width: 640px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.search-container { flex: 1; display: flex; align-items: center; max-width: 600px; }
.search-form { flex: 1; display: flex; align-items: center; border: 1px solid var(--yt-border-light); border-radius: 40px; overflow: hidden; margin-left: 32px; }
.search-form:focus-within { border-color: #1c62b9; }
.search-input { flex: 1; height: 40px; padding: 0 16px; background: var(--yt-bg-primary); border: none; outline: none; font-size: 1rem; color: var(--yt-text-primary); }
.search-input::placeholder { color: var(--yt-text-muted); }
.search-btn { width: 64px; height: 40px; background: var(--yt-bg-tertiary); border-left: 1px solid var(--yt-border-light); display: flex; align-items: center; justify-content: center; transition: background var(--transition-fast); }
.search-btn:hover { background: var(--yt-bg-hover); }
.search-btn svg { width: 24px; height: 24px; color: var(--yt-text-primary); }
.voice-search-btn { width: 40px; height: 40px; background: var(--yt-bg-tertiary); border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; transition: background var(--transition-fast); }
.voice-search-btn:hover { background: var(--yt-bg-hover); }
.voice-search-btn svg { width: 20px; height: 20px; }

.header-end { display: flex; align-items: center; gap: 8px; min-width: 200px; justify-content: flex-end; }
.icon-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); transition: background var(--transition-fast); position: relative; }
.icon-btn:hover { background: var(--yt-bg-hover); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn .badge { position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px; background: var(--yt-red); color: white; font-size: 0.7rem; font-weight: 500; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; }
.user-avatar { width: 32px; height: 32px; border-radius: var(--radius-full); background: #7c4dff; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 0.9rem; cursor: pointer; overflow: hidden; margin-left: 8px; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidebar { position: fixed; top: var(--header-height); left: 0; width: var(--sidebar-width); height: calc(100vh - var(--header-height)); background: var(--yt-bg-primary); overflow-y: auto; overflow-x: hidden; z-index: 900; transition: width var(--transition-normal), transform var(--transition-normal); padding: 12px 0; }
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-text, .sidebar.collapsed .nav-section-title, .sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .nav-item { flex-direction: column; padding: 16px 0; gap: 6px; font-size: 0.7rem; }
.sidebar.collapsed .nav-icon { margin: 0; }
.nav-section { padding: 12px 0; border-bottom: 1px solid var(--yt-border); }
.nav-section:last-child { border-bottom: none; }
.nav-section-title { padding: 6px 24px 6px 24px; font-size: 1rem; font-weight: 500; color: var(--yt-text-primary); }
.nav-item { display: flex; align-items: center; gap: 24px; padding: 10px 12px 10px 24px; color: var(--yt-text-primary); transition: background var(--transition-fast); cursor: pointer; border-radius: 10px; margin: 0 12px; }
.nav-item:hover { background: var(--yt-bg-hover); }
.nav-item.active { background: var(--yt-bg-hover); font-weight: 500; }
.nav-icon { width: 24px; height: 24px; flex-shrink: 0; }
.nav-icon svg { width: 24px; height: 24px; }
.nav-text { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer { padding: 16px 24px; font-size: 0.75rem; color: var(--yt-text-muted); border-top: 1px solid var(--yt-border); margin-top: 12px; }

.main-content { margin-left: var(--sidebar-width); margin-top: var(--header-height); padding: 16px 24px; min-height: calc(100vh - var(--header-height)); transition: margin-left var(--transition-normal); }
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

.category-pills { display: flex; gap: 12px; padding: 12px 0; overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; position: sticky; top: var(--header-height); background: var(--yt-bg-primary); z-index: 100; }
.category-pills::-webkit-scrollbar { display: none; }
.pill { padding: 8px 12px; background: var(--yt-bg-tertiary); border-radius: 8px; font-size: 0.95rem; font-weight: 500; white-space: nowrap; cursor: pointer; transition: all var(--transition-fast); }
.pill:hover { background: var(--yt-bg-hover); }
.pill.active { background: var(--yt-text-primary); color: var(--yt-bg-primary); }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px 16px; }
.video-card { cursor: pointer; }
.video-card:hover .video-title { color: var(--yt-text-primary); }
.video-thumbnail { position: relative; aspect-ratio: 16 / 9; background: var(--yt-bg-tertiary); border-radius: 12px; overflow: hidden; }
.video-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.video-thumbnail-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--yt-bg-tertiary); color: var(--yt-text-muted); }
.video-thumbnail-placeholder svg { width: 48px; height: 48px; opacity: 0.5; }
.thumbnail-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity var(--transition-fast); }
.video-card:hover .thumbnail-overlay { opacity: 1; }
.play-icon { width: 60px; height: 60px; background: rgba(0, 0, 0, 0.8); border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: white; }
.play-icon svg { width: 28px; height: 28px; margin-left: 4px; }
.video-duration { position: absolute; bottom: 4px; right: 4px; padding: 3px 4px; background: rgba(0, 0, 0, 0.8); color: white; font-size: 0.85rem; font-weight: 500; border-radius: 4px; }
.video-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: rgba(255, 255, 255, 0.3); }
.video-progress-bar { height: 100%; background: var(--yt-red); }
.video-info { display: flex; gap: 12px; padding: 12px 0 24px 0; }
.channel-avatar { width: 36px; height: 36px; border-radius: var(--radius-full); background: #7c4dff; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 0.85rem; overflow: hidden; color: white; }
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; }
.channel-avatar svg { width: 20px; height: 20px; }
.video-details { flex: 1; min-width: 0; }
.video-title { font-size: 1rem; font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 6px; color: var(--yt-text-primary); }
.video-channel { font-size: 0.9rem; color: var(--yt-text-secondary); display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.video-channel:hover { color: var(--yt-text-primary); }
.video-meta { font-size: 0.9rem; color: var(--yt-text-secondary); display: flex; align-items: center; gap: 4px; }
.video-meta span::after { content: "•"; margin-left: 4px; }
.video-meta span:last-child::after { content: none; }

.player-page { display: flex; gap: 24px; max-width: 1800px; margin: 0 auto; }
.player-main { flex: 1; min-width: 0; }
.player-sidebar { width: 402px; flex-shrink: 0; }
.video-player-container { position: relative; background: black; border-radius: 12px; overflow: hidden; }
.video-player-container.theater { position: fixed; top: var(--header-height); left: 0; right: 0; z-index: 100; border-radius: 0; max-height: calc(100vh - var(--header-height) - 150px); }
.video-player-container.fullscreen { position: fixed; inset: 0; z-index: 9999; border-radius: 0; }
.video-element { width: 100%; aspect-ratio: 16 / 9; background: black; }
.player-controls { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0, 0, 0, 0.9)); padding: 60px 12px 8px; opacity: 0; transition: opacity var(--transition-fast); }
.video-player-container:hover .player-controls { opacity: 1; }
.progress-bar-container { height: 3px; background: rgba(255, 255, 255, 0.3); cursor: pointer; margin-bottom: 8px; transition: height var(--transition-fast); }
.progress-bar-container:hover { height: 5px; }
.progress-bar { height: 100%; background: var(--yt-red); position: relative; }
.progress-bar::after { content: ''; position: absolute; right: -6px; top: 50%; transform: translateY(-50%) scale(0); width: 13px; height: 13px; background: var(--yt-red); border-radius: var(--radius-full); transition: transform var(--transition-fast); }
.progress-bar-container:hover .progress-bar::after { transform: translateY(-50%) scale(1); }
.buffer-bar { position: absolute; top: 0; left: 0; height: 100%; background: rgba(255, 255, 255, 0.4); }
.controls-row { display: flex; align-items: center; justify-content: space-between; }
.controls-left, .controls-right { display: flex; align-items: center; gap: 4px; }
.control-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: white; border-radius: var(--radius-full); transition: background var(--transition-fast); }
.control-btn:hover { background: rgba(255, 255, 255, 0.2); }
.control-btn svg { width: 24px; height: 24px; }
.volume-container { display: flex; align-items: center; }
.volume-slider { width: 0; overflow: hidden; transition: width var(--transition-fast); }
.volume-container:hover .volume-slider { width: 52px; }
.volume-slider input { width: 52px; height: 3px; -webkit-appearance: none; appearance: none; background: rgba(255, 255, 255, 0.3); border-radius: var(--radius-full); cursor: pointer; }
.volume-slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; background: white; border-radius: var(--radius-full); }
.time-display { color: white; font-size: 0.9rem; margin-left: 8px; }

.video-info-section { padding: 12px 0; }
.video-title-large { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.video-stats { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.video-views-date { color: var(--yt-text-secondary); font-size: 0.95rem; }
.video-actions { display: flex; align-items: center; gap: 8px; }
.action-btn { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--yt-bg-tertiary); border-radius: var(--radius-full); font-size: 0.95rem; font-weight: 500; transition: background var(--transition-fast); }
.action-btn:hover { background: var(--yt-bg-hover); }
.action-btn svg { width: 24px; height: 24px; }
.like-dislike { display: flex; background: var(--yt-bg-tertiary); border-radius: var(--radius-full); overflow: hidden; }
.like-dislike .action-btn { border-radius: 0; background: transparent; }
.like-dislike .action-btn:first-child { border-right: 1px solid var(--yt-border); padding-right: 12px; }
.like-dislike .action-btn:last-child { padding-left: 12px; }
.like-dislike .action-btn.active { color: var(--yt-blue); }

.channel-info { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--yt-border); }
.channel-info-left { display: flex; align-items: center; gap: 12px; }
.channel-avatar-large { width: 40px; height: 40px; border-radius: var(--radius-full); background: #7c4dff; display: flex; align-items: center; justify-content: center; font-weight: 500; overflow: hidden; }
.channel-avatar-large svg { width: 24px; height: 24px; }
.channel-name { font-weight: 500; font-size: 1rem; display: flex; align-items: center; gap: 4px; }
.channel-subs { font-size: 0.85rem; color: var(--yt-text-secondary); }
.subscribe-btn { padding: 10px 16px; background: var(--yt-red); color: white; border-radius: var(--radius-full); font-weight: 500; font-size: 0.95rem; transition: all var(--transition-fast); }
.subscribe-btn:hover { background: var(--yt-red-hover); }
.subscribe-btn.subscribed { background: var(--yt-bg-tertiary); color: var(--yt-text-primary); }

.video-description { background: var(--yt-bg-tertiary); border-radius: 12px; padding: 12px; margin: 16px 0; cursor: pointer; transition: background var(--transition-fast); }
.video-description:hover { background: var(--yt-bg-hover); }
.description-stats { font-weight: 500; font-size: 0.95rem; margin-bottom: 8px; }
.description-text { color: var(--yt-text-primary); font-size: 0.95rem; white-space: pre-line; line-height: 1.5; }
.description-text.collapsed { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.show-more-btn { font-weight: 500; margin-top: 8px; }

.suggested-videos { display: flex; flex-direction: column; gap: 8px; }
.suggested-header { font-weight: 500; padding-bottom: 16px; font-size: 1rem; }
.suggested-card { display: flex; gap: 8px; cursor: pointer; padding: 8px; margin: 0 -8px; border-radius: 12px; }
.suggested-card:hover { background: var(--yt-bg-hover); }
.suggested-thumbnail { width: 168px; flex-shrink: 0; position: relative; aspect-ratio: 16 / 9; background: var(--yt-bg-tertiary); border-radius: 8px; overflow: hidden; }
.suggested-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.suggested-info { flex: 1; min-width: 0; padding-top: 4px; }
.suggested-title { font-size: 0.95rem; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 4px; line-height: 1.3; }
.suggested-channel { font-size: 0.85rem; color: var(--yt-text-secondary); margin-bottom: 2px; }
.suggested-meta { font-size: 0.85rem; color: var(--yt-text-secondary); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; z-index: 2000; opacity: 0; visibility: hidden; transition: all var(--transition-fast); }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal { background: var(--yt-bg-tertiary); border-radius: 12px; width: 100%; max-width: 500px; max-height: 90vh; overflow: hidden; transform: scale(0.95); transition: transform var(--transition-fast); }
.modal-overlay.active .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--yt-border); }
.modal-title { font-size: 1.2rem; font-weight: 500; }
.modal-close { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); transition: background var(--transition-fast); }
.modal-close:hover { background: var(--yt-bg-hover); }
.modal-close svg { width: 24px; height: 24px; }
.modal-body { padding: 24px; overflow-y: auto; max-height: 60vh; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--yt-border); }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 8px; color: var(--yt-text-secondary); }
.form-input { width: 100%; padding: 10px 12px; background: var(--yt-bg-primary); border: 1px solid var(--yt-border); border-radius: 8px; font-size: 0.95rem; color: var(--yt-text-primary); transition: all var(--transition-fast); }
.form-input:focus { outline: none; border-color: var(--yt-blue); }
.form-hint { font-size: 0.8rem; color: var(--yt-text-muted); margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-full); font-size: 0.95rem; font-weight: 500; transition: all var(--transition-fast); cursor: pointer; }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--yt-blue); color: var(--yt-bg-primary); }
.btn-primary:hover { background: #5bb8ff; }
.btn-secondary { background: var(--yt-bg-tertiary); color: var(--yt-text-primary); }
.btn-secondary:hover { background: var(--yt-bg-hover); }
.btn-danger { background: var(--yt-red); color: white; }
.btn-ghost { background: transparent; color: var(--yt-blue); }
.btn-ghost:hover { background: rgba(62, 166, 255, 0.1); }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

.toast-container { position: fixed; bottom: 24px; left: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #323232; color: white; border-radius: 4px; font-size: 0.95rem; animation: slideUp 0.3s ease; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.success .toast-message::before { content: '✓ '; }
.toast.error { background: var(--yt-red); }
.toast.info { background: #323232; }
.toast-message { flex: 1; }
.toast-close { padding: 4px; opacity: 0.7; color: white; }
.toast-close:hover { opacity: 1; }
.toast-close svg { width: 18px; height: 18px; }

.skeleton { background: linear-gradient(90deg, var(--yt-bg-tertiary) 25%, var(--yt-bg-hover) 50%, var(--yt-bg-tertiary) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-md); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.loading-spinner { width: 32px; height: 32px; border: 3px solid var(--yt-bg-tertiary); border-top-color: var(--yt-red); border-radius: var(--radius-full); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.section-title { font-size: 1.1rem; font-weight: 500; margin-bottom: 16px; }
.empty-state { text-align: center; padding: 64px 20px; }
.empty-state svg { width: 120px; height: 120px; color: var(--yt-text-muted); margin-bottom: 16px; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1200px) { .player-sidebar { width: 360px; } .suggested-thumbnail { width: 140px; } }
@media (max-width: 1024px) { .sidebar { transform: translateX(-100%); } .sidebar.open { transform: translateX(0); } .main-content { margin-left: 0; } .player-page { flex-direction: column; } .player-sidebar { width: 100%; } }
@media (max-width: 768px) { .header-center { position: absolute; left: 0; right: 0; top: var(--header-height); background: var(--yt-bg-primary); padding: 8px 16px; display: none; } .header-center.show { display: flex; } .video-grid { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .header { padding: 0 8px; } .main-content { padding: 8px; } .video-actions { flex-wrap: wrap; } .action-btn span { display: none; } }
