/**
 * Video Gallery Styles for UIkit Template
 * Shared across com_content category views (blog & default layouts)
 */

/* ========================================
   CSS Custom Properties
   ======================================== */
:root {
    --vg-gap: 24px;
    --vg-gap-mobile: 16px;
    --vg-card-radius: 12px;
    --vg-toolbar-padding: 12px 16px;
    --vg-toolbar-bg: #fff;
    --vg-toolbar-border: #e5e5e5;
    --vg-card-bg: #fff;
    --vg-card-hover-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    --vg-play-btn-bg: rgba(0, 0, 0, 0.7);
    --vg-play-btn-hover-bg: #f00;
    --vg-duration-bg: rgba(0, 0, 0, 0.8);
    --vg-channel-avatar-bg: #f0f0f0;
    --vg-subcat-hover-bg: #f8f8f8;
    --vg-nested-bg: #fafafa;
}

/* Dark mode variables */
.uk-dark,
[class*="uk-dark"] {
    --vg-toolbar-bg: rgba(33, 33, 33, 0.95);
    --vg-toolbar-border: #444;
    --vg-card-bg: #2a2a2a;
    --vg-card-hover-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --vg-channel-avatar-bg: #444;
    --vg-subcat-hover-bg: #333;
    --vg-nested-bg: #333;
}

/* ========================================
   Base Gallery Container
   ======================================== */
.video-gallery {
    padding: 20px 0;
}

/* ========================================
   Page Header
   ======================================== */
.page-header h1 {
    font-weight: 600;
}

/* ========================================
   Category Header
   ======================================== */
.category-header {
    padding: 16px;
    border-radius: var(--vg-card-radius);
    border: 1px solid var(--vg-toolbar-border);
    transition: background 0.2s, border-color 0.2s;
}

.category-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

/* ========================================
   Toolbar (Sort & Filter)
   ======================================== */
.video-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--vg-toolbar-bg);
    padding: var(--vg-toolbar-padding);
    border-radius: 8px;
    border: 1px solid var(--vg-toolbar-border);
    transition: background 0.2s, border-color 0.2s;
}

.video-toolbar[uk-sticky] {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.uk-dark .video-toolbar[uk-sticky],
[class*="uk-dark"] .video-toolbar[uk-sticky] {
    background: rgba(33, 33, 33, 0.95);
}

.video-count {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Sort dropdown active state */
.sort-dropdown .uk-nav li.uk-active > a {
    color: #1e87f0;
    font-weight: 600;
}

/* Layout toggle buttons */
.layout-toggle {
    display: inline-flex;
}

.layout-toggle button {
    position: relative;
}

.layout-toggle button.uk-active {
    background: #1e87f0;
    color: #fff;
    border-color: #1e87f0;
}

.uk-dark .layout-toggle button.uk-active,
[class*="uk-dark"] .layout-toggle button.uk-active {
    background: #1e87f0;
    border-color: #1e87f0;
}

/* ========================================
   Video Grid (Default / Grid View)
   ======================================== */
.video-grid {
    margin-left: 0;
}

/* ========================================
   Video Card (Grid View)
   ======================================== */
.video-card {
    border-radius: var(--vg-card-radius);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--vg-card-hover-shadow);
}

/* Thumbnail */
.video-thumbnail {
    aspect-ratio: 16 / 9;
    background: #000;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

/* Play overlay */
.play-overlay {
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-thumbnail:hover .play-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.play-button {
    width: 64px;
    height: 64px;
    background: var(--vg-play-btn-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
    opacity: 0;
    transform: scale(0.8);
}

.video-thumbnail:hover .play-button {
    opacity: 1;
    transform: scale(1);
    background: var(--vg-play-btn-hover-bg);
}

.play-button svg {
    margin-left: 4px;
}

/* Duration badge */
.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--vg-duration-bg);
    color: #fff;
    z-index: 2;
}

/* Card body */
.video-card .uk-card-body {
    padding: 12px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Channel avatar */
.channel-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--vg-channel-avatar-bg);
    overflow: hidden;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.channel-avatar .uk-icon-user {
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
}

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

/* Title */
.video-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    max-height: 2.8em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.video-title a {
    color: inherit;
    text-decoration: none;
}

.video-title a:hover {
    color: #1e87f0;
}

/* Meta */
.video-meta-bottom {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: auto;
    padding-top: 8px;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Description */
.video-description {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 8px;
}

/* Card footer (edit button) */
.video-card .uk-card-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--vg-toolbar-border);
}

/* ========================================
   List View Styles
   ======================================== */
.vg-list-view .video-grid {
    flex-direction: column;
    gap: 16px;
}

.vg-list-view .video-grid > * {
    flex: 0 0 100%;
    max-width: 100%;
}

.vg-list-view .video-card {
    flex-direction: row;
    align-items: stretch;
    height: auto;
}

.vg-list-view .video-thumbnail {
    aspect-ratio: 16 / 9;
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
}

.vg-list-view .video-card .uk-card-body {
    padding: 16px 20px;
    justify-content: center;
}

.vg-list-view .video-title {
    font-size: 16px;
    -webkit-line-clamp: 1;
    max-height: 1.4em;
}

.vg-list-view .video-description {
    -webkit-line-clamp: 2;
}

/* ========================================
   Subcategories
   ======================================== */
.subcategories-section {
    margin-bottom: 32px;
}

.section-title {
    display: flex;
    align-items: center;
    font-weight: 600;
    gap: 8px;
    margin-bottom: 16px;
}

.subcategories-grid {
    margin-left: 0;
}

/* UIkit grid handles layout */
.subcategories-grid.uk-grid > * {
    margin: 0;
    padding: 0;
}

.subcategory-card {
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid var(--vg-toolbar-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    display: block;
}

.subcategory-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    background: var(--vg-subcat-hover-bg);
}

.subcat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--vg-channel-avatar-bg);
    flex-shrink: 0;
    transition: background 0.2s ease;
}

/* ========================================
   Channel / Playlist Cards (default_children)
   ======================================== */
.channel-card {
    text-decoration: none;
    border-radius: var(--vg-card-radius);
    border: 1px solid var(--vg-toolbar-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    display: block;
    margin-bottom: 16px;
}

.channel-card:hover {
    transform: translateX(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.channel-card:hover .channel-icon {
    background: #333 !important;
}

.channel-card:hover .uk-icon-chevron-right {
    transform: translateX(4px);
}

.channel-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: #1e87f0;
    color: #fff;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.channel-title {
    font-weight: 600;
    line-height: 1.3;
}

.channel-desc {
    max-width: 400px;
}

.channel-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #999;
}

.channel-stats .stat-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.uk-icon-chevron-right {
    transition: transform 0.2s ease;
}

/* Nested children */
.nested-children {
    margin-left: 24px;
    margin-bottom: 16px;
}

.nested-children .channel-card {
    background: var(--vg-nested-bg);
}

.nested-children .channel-icon {
    width: 44px;
    height: 44px;
    background: #666 !important;
}

/* ========================================
   Pagination
   ======================================== */
.pagination-wrapper {
    margin-top: 32px;
}

.pagination-counter {
    margin: 0;
}

/* ========================================
   Empty State
   ======================================== */
.vg-empty-state {
    padding: 48px 24px;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

/* Tablet (641px - 960px) */
@media (max-width: 960px) {
    /* List view thumbnail shrinks on tablet */
    .vg-list-view .video-thumbnail {
        width: 240px;
        min-width: 240px;
    }
}

/* Mobile (<= 640px) */
@media (max-width: 640px) {
    .video-gallery {
        padding: 12px 0;
    }

    .video-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .toolbar-actions {
        justify-content: space-between;
    }

    /* List view becomes stacked on mobile */
    .vg-list-view .video-card {
        flex-direction: column;
    }

    .vg-list-view .video-thumbnail {
        width: 100%;
        min-width: auto;
        aspect-ratio: 16 / 9;
    }

    .vg-list-view .video-title {
        font-size: 14px;
    }

    .channel-card:hover {
        transform: translateY(-2px);
    }

    .nested-children {
        margin-left: 12px;
    }
}

/* Small mobile (<= 480px) */
@media (max-width: 480px) {
    .category-header {
        padding: 12px;
    }

    .category-icon {
        width: 40px;
        height: 40px;
    }

    .video-card .uk-card-body {
        padding: 10px 12px;
    }

    .play-button {
        width: 48px;
        height: 48px;
    }

    .play-button svg {
        width: 20px;
        height: 20px;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .video-card,
    .video-card:hover,
    .video-thumbnail img,
    .play-overlay,
    .play-button,
    .subcategory-card,
    .channel-card,
    .uk-icon-chevron-right {
        transition: none !important;
        transform: none !important;
    }

    .video-card:hover {
        box-shadow: var(--vg-card-hover-shadow);
    }
}
