/*
 * -------------------------------------------------------------------
 *  1. Основной макет страницы и Заголовок
 * -------------------------------------------------------------------
 */

 .category-page-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

.yt-category-header {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px; 
    padding: 50px 30px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #fff;
    min-height: 220px; 
}

.yt-category-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--bg-image, url('/images/categories/default-bg.jpg'));
    background-size: cover;
    background-position: center;
    background-color: rgba(0, 0, 0, 0.6);
    background-blend-mode: multiply;
    z-index: 1;
    transition: transform 0.4s ease;
}

.yt-category-header:hover::before {
    transform: scale(1.05);
}

.yt-category-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.yt-category-eyebrow {
    display: none;
}

.yt-category-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.yt-category-title {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: -1px;
    margin: 0 0 8px 0;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
    border-bottom: none;
    padding-bottom: 0;
}

.yt-category-description {
    font-size: 16px;
    font-weight: 400;
    max-width: 600px;
    margin: 0;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

/*
 * -------------------------------------------------------------------
 *  2. Сетка и карточки видео
 * -------------------------------------------------------------------
 */

.video-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)); 
    gap: 32px 16px; 
}

.video-card {
    display: flex;
    flex-direction: column;
    padding-bottom: 8px;
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background-color: #272727;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px; 
}

.video-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-card:hover .video-thumbnail {
    transform: scale(1.05);
}

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

.video-info-container {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.video-text-content {
    flex-grow: 1;
    min-width: 0;
}

.video-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    display: block;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.video-title a {
    display: block;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    text-decoration: none;
}

.channel-details {
    display: flex;
    align-items: center;
    gap: 8px; 
}

.channel-avatar-small {
    width: 32px; 
    height: 32px; 
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.meta-stack {
    display: flex;
    flex-direction: column;
    min-width: 0;
    transform: none;
}

.channel-name-link {
    font-size: 14px;
    transform: translateY(-2px);
    display: block;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-name-link:hover {
    color: var(--text-primary);
}

.video-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 4px 6px;
    flex-wrap: wrap;
    white-space: normal;
    overflow-wrap: anywhere;
    transform: translateY(-2px); 
}

.context-menu-container {
    position: relative;
    flex-shrink: 0;
    margin-top: -8px; 
}

.context-menu-button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    width: 40px; 
    height: 40px; 
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.context-menu-button:hover {
    background-color: #3f3f3f;
}

.context-menu-container:has(.context-menu-dropdown.active) .context-menu-button {
    pointer-events: none;
}

.context-menu-button img {
    width: 24px; 
    height: 24px;
    filter: invert(1);
}

.context-menu-dropdown {
    display: none;
    position: absolute;
    top: 40px; 
    right: 0;
    background-color: #282828;
    border-radius: 12px;
    padding: 8px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10;
    min-width: 250px;
}

.context-menu-dropdown.opens-upward {
    top: auto;
    bottom: 40px;
}

.context-menu-dropdown.is-viewport-positioned,
.context-menu-dropdown.is-viewport-positioned.opens-upward {
    bottom: auto !important;
    right: auto !important;
}

.context-menu-dropdown.active {
    display: block;
}

.page-category .video-card {
    overflow: visible;
    position: relative;
}

.page-category .video-info-container {
    overflow: visible;
}

.context-menu-dropdown a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    color: #f1f1f1;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}

.context-menu-dropdown a:hover {
    background-color: #3f3f3f;
}

.context-menu-dropdown a img {
    width: 24px;
    height: 24px;
    filter: invert(1);
}

/* Infinite scroll loader (YouTube-like) */
.infinite-loader {
    display: none;
    margin: 18px 0 6px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.infinite-loader.is-active {
    display: flex;
}

.infinite-spinner {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-top-color: rgba(255, 255, 255, 0.75);
    animation: infinite-spin 0.85s linear infinite;
}

@keyframes infinite-spin {
    to { transform: rotate(360deg); }
}

.infinite-sentinel {
    height: 1px;
}


/*
 * -------------------------------------------------------------------
 *  4. Адаптивность (По состоянию сайдбара)
 * -------------------------------------------------------------------
 */
@media (min-width: 993px) {
    .page-container.sidebar-collapsed .video-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1701px) {
    .page-container.sidebar-collapsed .video-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)); 
    }

    .yt-category-header {
        padding: 40px 20px;
        min-height: 200px;
    }

    .yt-category-title {
        font-size: 36px;
    }

    .yt-category-description {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .video-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .yt-category-title {
        font-size: 28px;
    }

    .yt-category-icon {
        width: 50px;
        height: 50px;
    }
}