/* YouTube Design System - Dark Theme */
:root {
    --yt-bg-main: #0f0f0f;
    --yt-bg-sidebar: #0f0f0f;
    --yt-bg-header: #0f0f0f;
    --yt-bg-hover: rgba(255, 255, 255, 0.1);
    --yt-bg-search: #121212;
    --yt-bg-chip: #272727;

    --yt-text-primary: #f1f1f1;
    --yt-text-secondary: #aaaaaa;
    --yt-text-disabled: #717171;

    --yt-brand-red: #ff0000;
    --yt-border: rgba(255, 255, 255, 0.1);
    --yt-search-border: #303030;

    --yt-header-height: 56px;
    --yt-sidebar-width: 240px;
    --yt-sidebar-collapsed-width: 72px;
}

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

body {
    background-color: var(--yt-bg-main);
    color: var(--yt-text-primary);
    font-family: "Roboto", Arial, sans-serif;
    overflow-x: hidden;
}

/* Header Styles */
.yt-header {
    height: var(--yt-header-height);
    background-color: var(--yt-bg-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.yt-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.yt-header-center {
    flex: 0 1 720px;
}

.yt-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon Buttons */
.yt-icon-btn {
    background: transparent;
    border: none;
    color: var(--yt-text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.yt-icon-btn:hover {
    background: var(--yt-bg-hover);
}

.yt-logo {
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--yt-text-primary);
    font-weight: bold;
    font-size: 18px;
    letter-spacing: -1px;
}

.yt-logo-text {
    font-family: "Roboto Condensed", sans-serif;
    font-weight: 700;
}

/* Search Bar */
.yt-search-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.yt-search-box {
    display: flex;
    flex: 1;
    background: var(--yt-bg-search);
    border: 1px solid var(--yt-search-border);
    border-radius: 40px;
    overflow: hidden;
    position: relative;
    margin-left: 32px;
}

.yt-search-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0 16px;
    height: 40px;
    color: var(--yt-text-primary);
    font-size: 16px;
}

.yt-search-input:focus {
    outline: none;
    border: 1px solid #1c62b9;
    border-radius: 40px 0 0 40px;
}

.yt-search-btn {
    background: #222;
    border: none;
    border-left: 1px solid var(--yt-search-border);
    width: 64px;
    color: var(--yt-text-primary);
    cursor: pointer;
}

.yt-search-btn:hover {
    background: #333;
}

.yt-mic-btn {
    background: #181818;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--yt-text-primary);
    cursor: pointer;
}

.yt-mic-btn:hover {
    background: #333;
}

/* Avatar/Sign In */
.yt-avatar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 36px;
    border: 1px solid var(--yt-border);
    border-radius: 18px;
    background: transparent;
    color: #3ea6ff;
    font-weight: 500;
    cursor: pointer;
}

.yt-avatar-btn:hover {
    background: rgba(62, 166, 255, 0.1);
}

/* Sidebar Navigation */
.yt-sidebar {
    width: var(--yt-sidebar-width);
    background: var(--yt-bg-sidebar);
    height: calc(100vh - var(--yt-header-height));
    position: fixed;
    top: var(--yt-header-height);
    left: 0;
    overflow-y: auto;
    transition: transform 0.2s, width 0.2s;
    z-index: 900;
}

.yt-sidebar.collapsed {
    width: var(--yt-sidebar-collapsed-width);
}

.yt-sidebar-inner {
    padding: 12px 0;
}

.yt-sidebar-section {
    padding: 0 12px;
}

.yt-sidebar-section-title {
    padding: 8px 12px;
    font-size: 16px;
    font-weight: 500;
}

.yt-sidebar-item {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 12px;
    height: 40px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--yt-text-primary);
    font-size: 14px;
    transition: background 0.2s;
}

.yt-sidebar-item:hover {
    background: var(--yt-bg-hover);
}

.yt-sidebar-item.active {
    background: var(--yt-bg-hover);
    font-weight: 500;
}

.yt-sidebar.collapsed .yt-sidebar-item {
    flex-direction: column;
    gap: 4px;
    height: 72px;
    justify-content: center;
    padding: 0;
    font-size: 10px;
}

.yt-sidebar.collapsed .yt-sidebar-section-title,
.yt-sidebar.collapsed .yt-sidebar-divider,
.yt-sidebar.collapsed .yt-sidebar-footer {
    display: none;
}

.yt-sidebar-divider {
    height: 1px;
    background: var(--yt-border);
    margin: 12px 0;
}

/* Main Content Area */
.yt-main-content {
    margin-top: var(--yt-header-height);
    margin-left: var(--yt-sidebar-width);
    min-height: calc(100vh - var(--yt-header-height));
    transition: margin-left 0.2s;
    padding: 24px;
}

.yt-main-content.sidebar-collapsed {
    margin-left: var(--yt-sidebar-collapsed-width);
}

/* Chips/Filter Bar */
.yt-chips-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    position: sticky;
    top: 56px;
    z-index: 800;
    background: var(--yt-bg-main);
    padding: 12px 0;
}

.yt-chips-wrapper {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

.yt-chips-wrapper::-webkit-scrollbar {
    display: none;
}

.yt-chip {
    background: var(--yt-bg-chip);
    border: none;
    color: var(--yt-text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s;
}

.yt-chip:hover {
    background: #3f3f3f;
}

.yt-chip.active {
    background: #fff;
    color: #000;
}

/* Video Grid Layout */
.yt-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    row-gap: 40px;
}

/* Video Card */
.yt-video-card {
    cursor: pointer;
}

.yt-video-card-link {
    text-decoration: none;
    color: inherit;
}

.yt-thumbnail-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    background: #222;
}

.yt-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.yt-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}

.yt-video-card-info {
    display: flex;
    margin-top: 12px;
    gap: 12px;
    position: relative;
}

.yt-channel-icon-small {
    width: 36px;
    height: 36px;
    background: #2ecc71;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: bold;
    overflow: hidden;
}

.yt-channel-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.yt-video-card-text {
    flex: 1;
}

.yt-video-card-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.yt-video-card-channel {
    color: var(--yt-text-secondary);
    font-size: 14px;
    margin-bottom: 2px;
}

.yt-video-card-meta {
    color: var(--yt-text-secondary);
    font-size: 14px;
}

/* Search Result List */
.yt-results-list {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.yt-result-card {
    cursor: pointer;
}

.yt-result-card-link {
    display: flex;
    gap: 16px;
    text-decoration: none;
    color: inherit;
}

.yt-result-thumbnail-wrapper {
    width: 360px;
    flex-shrink: 0;
    position: relative;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    background: #222;
}

.yt-result-info {
    flex: 1;
    padding-top: 4px;
}

.yt-result-title {
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 4px;
}

.yt-result-meta {
    font-size: 12px;
    color: var(--yt-text-secondary);
    margin-bottom: 12px;
}

.yt-result-channel {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--yt-text-secondary);
}

.yt-result-channel-icon {
    width: 24px;
    height: 24px;
    background: #e67e22;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.yt-result-description {
    font-size: 12px;
    color: var(--yt-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Watch Page */
.yt-watch-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 24px;
    max-width: 1300px;
    margin: 0 auto;
}

.yt-player-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.yt-player {
    width: 100%;
    height: 100%;
    border: none;
}

.yt-watch-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
}

.yt-watch-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.yt-watch-channel {
    display: flex;
    align-items: center;
    gap: 12px;
}

.yt-watch-channel-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: #34495e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.yt-watch-channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.yt-watch-channel-name {
    font-weight: 500;
}

.yt-subscribe-btn {
    background: #fff;
    color: #000;
    border: none;
    padding: 0 16px;
    height: 36px;
    border-radius: 18px;
    font-weight: 500;
    cursor: pointer;
    margin-left: 12px;
}

.yt-subscribe-btn.subscribed {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.yt-watch-actions {
    display: flex;
    gap: 8px;
}

.yt-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--yt-bg-chip);
    border: none;
    color: var(--yt-text-primary);
    padding: 0 16px;
    height: 36px;
    border-radius: 18px;
    font-weight: 500;
    cursor: pointer;
}

.yt-action-btn:hover {
    background: #3f3f3f;
}

.yt-like-dislike-group {
    display: flex;
    background: var(--yt-bg-chip);
    border-radius: 18px;
}

.yt-like-dislike-group .yt-action-btn {
    border-radius: 0;
}

.yt-like-btn {
    border-radius: 18px 0 0 18px !important;
}

.yt-like-divider {
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
    height: 24px;
    align-self: center;
}

/* Description Box */
.yt-description-box {
    background: var(--yt-bg-chip);
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
}

.yt-description-meta {
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
}

.yt-description-text {
    white-space: pre-wrap;
    line-height: 1.5;
    max-height: 60px;
    overflow: hidden;
}

.yt-description-text.expanded {
    max-height: none;
}

.yt-desc-expand-btn {
    background: transparent;
    border: none;
    color: var(--yt-text-primary);
    font-weight: 700;
    margin-top: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* Comments Section */
.yt-comments-section {
    margin-top: 24px;
}

.yt-comments-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}

.yt-comments-count {
    font-size: 20px;
    font-weight: 700;
}

.yt-add-comment {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.yt-add-comment-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--yt-border);
    padding: 8px 0;
    color: var(--yt-text-primary);
    font-size: 14px;
}

.yt-add-comment-input:focus {
    outline: none;
    border-bottom: 2px solid var(--yt-text-primary);
}

.yt-comment {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.yt-comment-author {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.yt-comment-text {
    font-size: 14px;
    line-height: 1.4;
}

/* Responsiveness */
@media (max-width: 1024px) {
    .yt-watch-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .yt-sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .yt-sidebar {
        transform: translateX(0);
        width: 240px;
    }

    .yt-main-content {
        margin-left: 0 !important;
    }

    .yt-header-center {
        display: none;
    }
}

/* ──────────────────────────────────────────────────────────
   Playlist Page
   ────────────────────────────────────────────────────────── */
.pl-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    max-width: 1300px;
    margin: 0 auto;
    align-items: start;
}

/* ── Sticky sidebar card ── */
.pl-sidebar {
    position: sticky;
    top: calc(var(--yt-header-height) + 24px);
}

.pl-header-card {
    background: linear-gradient(160deg, #1c1c1c 0%, #111 100%);
    border-radius: 16px;
    overflow: hidden;
}

.pl-thumbnail-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    overflow: hidden;
}

.pl-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: brightness(0.85);
    transition: filter 0.3s;
}

.pl-thumbnail-placeholder {
    width: 100%;
    height: 100%;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pl-play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.pl-thumbnail-wrap:hover .pl-thumbnail {
    filter: brightness(0.65);
}

.pl-thumbnail-wrap:hover .pl-play-overlay {
    opacity: 1;
}

.pl-play-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.92);
    color: #000;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 24px;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
}

.pl-play-all-btn:hover {
    background: #fff;
    transform: scale(1.04);
}

/* ── Metadata under thumbnail ── */
.pl-meta {
    padding: 16px;
}

.pl-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 8px;
    color: var(--yt-text-primary);
}

.pl-channel-row {
    margin-bottom: 6px;
}

.pl-channel-link {
    color: var(--yt-text-primary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
}

.pl-channel-link:hover {
    color: #aaa;
}

.pl-stats-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.pl-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--yt-text-secondary);
}

/* ── Description ── */
.pl-description {
    margin-bottom: 12px;
}

.pl-desc-text {
    font-size: 13px;
    color: var(--yt-text-secondary);
    line-height: 1.5;
    max-height: 52px;
    overflow: hidden;
    white-space: pre-wrap;
    transition: max-height 0.3s ease;
}

.pl-desc-text.expanded {
    max-height: 600px;
}

.pl-desc-toggle {
    background: transparent;
    border: none;
    color: var(--yt-text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0 0;
}

/* ── Action row (Play all / Shuffle) ── */
.pl-action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
}

.pl-btn:hover {
    transform: scale(1.03);
}

.pl-btn-primary {
    background: var(--yt-text-primary);
    color: var(--yt-bg-main);
}

.pl-btn-primary:hover {
    background: #ccc;
}

.pl-btn-secondary {
    background: var(--yt-bg-chip);
    color: var(--yt-text-primary);
}

.pl-btn-secondary:hover {
    background: #3a3a3a;
}

/* ── Video list (right column) ── */
.pl-video-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.pl-video-row {
    display: grid;
    grid-template-columns: 28px 160px 1fr;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.pl-video-row:hover {
    background: var(--yt-bg-hover);
}

.pl-video-index {
    font-size: 14px;
    color: var(--yt-text-secondary);
    text-align: center;
    user-select: none;
    min-width: 24px;
}

.pl-video-thumb-wrap {
    position: relative;
    width: 160px;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    background: #222;
    flex-shrink: 0;
}

.pl-video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pl-video-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 5px;
    border-radius: 3px;
}

.pl-video-info {
    overflow: hidden;
}

.pl-video-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pl-video-channel {
    font-size: 12px;
    color: var(--yt-text-secondary);
    margin-bottom: 2px;
}

.pl-video-meta {
    font-size: 12px;
    color: var(--yt-text-disabled);
}

/* ── Empty state ── */
.pl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    color: var(--yt-text-secondary);
    text-align: center;
    gap: 12px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .pl-layout {
        grid-template-columns: 1fr;
    }

    .pl-sidebar {
        position: static;
    }

    .pl-header-card {
        display: grid;
        grid-template-columns: 200px 1fr;
        border-radius: 12px;
    }

    .pl-thumbnail-wrap {
        aspect-ratio: unset;
        height: 100%;
        min-height: 130px;
    }
}

@media (max-width: 560px) {
    .pl-header-card {
        grid-template-columns: 1fr;
    }

    .pl-video-row {
        grid-template-columns: 24px 120px 1fr;
    }

    .pl-video-thumb-wrap {
        width: 120px;
    }
}

/* ──────────────────────────────────────────────────────────
   Playlist Layout Components (Search/Home)
   ────────────────────────────────────────────────────────── */

/* Playlist Badge */
.yt-pl-badge {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

/* Playlist horizontal search result overlay */
.yt-pl-overlay {
    position: absolute;
    top: 0;
    right: 0;
    width: 40%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    z-index: 2;
}

.yt-pl-overlay svg {
    margin-bottom: 6px;
    opacity: 0.9;
}

/* Sub-video preview list in search results */
.yt-pl-preview-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.yt-pl-preview-item {
    font-size: 12px;
    color: var(--yt-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.yt-pl-view-all {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--yt-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Home Grid Playlist Adjustments */
.yt-video-card.is-playlist .yt-thumbnail-wrapper {
    position: relative;
    /* Stack effect for grid */
}

.yt-video-card.is-playlist .yt-thumbnail-wrapper::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 8px;
    right: 8px;
    height: 4px;
    background: #333;
    border-radius: 8px 8px 0 0;
}

.yt-video-card.is-playlist .yt-thumbnail-wrapper::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 16px;
    right: 16px;
    height: 4px;
    background: #222;
    border-radius: 8px 8px 0 0;
}