/* 
 * Frontend Styles for CentralBank YouTube Gallery 
 */

:root {
    /* Fallback vars, these are injected inline per gallery */
    --cbyg-cols: 3;
    --cbyg-rows: 1;
    --cbyg-gutter: 20px;
    --cbyg-width: 100%;
}

.cbyg-gallery-wrapper {
    width: var(--cbyg-width);
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
}

.cbyg-gallery-wrapper * {
    box-sizing: border-box;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */

.cbyg-header {
    position: relative;
    background: var(--cbyg-header-bg);
    overflow: hidden;
    border-radius: 10px 10px 0 0;
    margin-bottom: var(--cbyg-gutter);
}

.cbyg-header-banner {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
}

.cbyg-header-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cbyg-header-banner-overlay);
}

.cbyg-header-inner {
    position: relative;
    z-index: 2;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.cbyg-header-logo img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.cbyg-header-info {
    flex-grow: 1;
}

.cbyg-header-channel-title {
    margin: 0 0 5px 0 !important;
    font-size: 22px;
}

.cbyg-header-channel-title a {
    color: var(--cbyg-header-channel-name);
    text-decoration: none;
}
.cbyg-header-channel-title a:hover {
    color: var(--cbyg-header-channel-name-hover);
}

.cbyg-header-stats {
    font-size: 13px;
    color: var(--cbyg-header-counters);
    display: flex;
    gap: 15px;
    margin-bottom: 8px;
}

.cbyg-header-channel-desc {
    font-size: 14px;
    color: var(--cbyg-header-channel-description);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cbyg-header-channel-desc a {
    color: var(--cbyg-header-anchor);
}
.cbyg-header-channel-desc a:hover {
    color: var(--cbyg-header-anchor-hover);
}

.cbyg-btn-subscribe {
    display: inline-block;
    background: #f00;
    color: #fff !important;
    padding: 8px 16px;
    border-radius: 2px;
    text-decoration: none !important;
    font-weight: 500;
    font-size: 14px;
    text-transform: uppercase;
    transition: background 0.2s;
}
.cbyg-btn-subscribe:hover {
    background: #cc0000;
}

/* Header Layouts */
.cbyg-header-accent .cbyg-header-banner {
    filter: blur(8px);
    transform: scale(1.1);
}
.cbyg-header-accent .cbyg-header-inner {
    flex-direction: column;
    text-align: center;
}
.cbyg-header-accent .cbyg-header-logo {
    margin-bottom: 10px;
}

.cbyg-header-minimal .cbyg-header-banner {
    filter: blur(10px);
}
.cbyg-header-minimal .cbyg-header-overlay {
    background: rgba(0,0,0,0.6);
}
.cbyg-header-minimal .cbyg-header-channel-title a,
.cbyg-header-minimal .cbyg-header-stats,
.cbyg-header-minimal .cbyg-header-channel-desc {
    color: #fff;
}


/* ─── Tabs (Source Groups) ───────────────────────────────────────────────── */

.cbyg-tabs {
    background: var(--cbyg-groups-bg);
    margin-bottom: var(--cbyg-gutter);
    border-radius: 4px;
}

.cbyg-tabs-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 15px !important;
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
}
.cbyg-tabs-list::-webkit-scrollbar {
    display: none;
}

.cbyg-tab {
    margin: 0 !important;
    padding: 0 !important;
}

.cbyg-tab button {
    background: none;
    border: none;
    padding: 15px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--cbyg-groups-link);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.cbyg-tab button:hover {
    color: var(--cbyg-groups-link-hover);
}

.cbyg-tab.cbyg-tab-active button {
    color: var(--cbyg-groups-link-active);
}

.cbyg-tab.cbyg-tab-active button::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--cbyg-groups-highlight-active);
}

/* ─── Grid ───────────────────────────────────────────────────────────────── */

.cbyg-content {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.cbyg-grid {
    display: grid;
    grid-template-columns: repeat(var(--cbyg-cols), 1fr);
    gap: var(--cbyg-gutter);
}

/* ─── Carousel (CSS Scroll Snap — Horizontal & Vertical) ────────────────── */

.cbyg-carousel {
    position: relative;
    overflow: hidden;
}

/* ── Horizontal (default) ── */
.cbyg-dir-horizontal .cbyg-carousel-track {
    display: flex;
    flex-direction: row;
    gap: var(--cbyg-gutter);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 5px 5px 10px 5px;
}
.cbyg-dir-horizontal .cbyg-carousel-track::-webkit-scrollbar {
    display: none;
}
.cbyg-dir-horizontal .cbyg-carousel-track .cbyg-card {
    flex: 0 0 calc((100% - (var(--cbyg-gutter) * (var(--cbyg-cols) - 1))) / var(--cbyg-cols));
    scroll-snap-align: start;
    min-width: 0; /* prevent flex blowout */
}

/* ── Vertical ── */
.cbyg-dir-vertical .cbyg-carousel-track {
    display: grid;
    grid-template-columns: repeat(var(--cbyg-cols), 1fr);
    gap: var(--cbyg-gutter);
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 5px;
    /* Height will be calculated by JS to perfectly fit the configured rows */
}
.cbyg-dir-vertical .cbyg-carousel-track::-webkit-scrollbar {
    display: none;
}
.cbyg-dir-vertical .cbyg-carousel-track .cbyg-card {
    scroll-snap-align: start;
    width: 100%;
}

/* ── Fallback (no direction class, treat as horizontal) ── */
.cbyg-carousel-track {
    display: flex;
    gap: var(--cbyg-gutter);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding-bottom: 10px;
}
.cbyg-carousel-track::-webkit-scrollbar {
    display: none;
}
.cbyg-carousel-track .cbyg-card {
    flex: 0 0 calc((100% - (var(--cbyg-gutter) * (var(--cbyg-cols) - 1))) / var(--cbyg-cols));
    scroll-snap-align: start;
}

/* ── Carousel Navigation Arrows ── */
.cbyg-nav-prev, .cbyg-nav-next {
    position: absolute;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--cbyg-content-arrows-bg);
    color: var(--cbyg-content-arrows);
    border: none;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: background 0.2s, color 0.2s, transform 0.15s;
    flex-shrink: 0;
}
.cbyg-nav-prev:hover, .cbyg-nav-next:hover {
    background: var(--cbyg-content-arrows-bg-hover);
    color: var(--cbyg-content-arrows-hover);
    transform: scale(1.1);
}

/* Horizontal arrow positions */
.cbyg-dir-horizontal .cbyg-nav-prev,
:not(.cbyg-dir-vertical) .cbyg-nav-prev {
    top: 50%;
    left: -19px;
    transform: translateY(-50%);
}
.cbyg-dir-horizontal .cbyg-nav-next,
:not(.cbyg-dir-vertical) .cbyg-nav-next {
    top: 50%;
    right: -19px;
    transform: translateY(-50%);
}
.cbyg-dir-horizontal .cbyg-nav-prev:hover,
:not(.cbyg-dir-vertical) .cbyg-nav-prev:hover {
    transform: translateY(-50%) scale(1.1);
}
.cbyg-dir-horizontal .cbyg-nav-next:hover,
:not(.cbyg-dir-vertical) .cbyg-nav-next:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Vertical arrow positions */
.cbyg-dir-vertical .cbyg-nav-prev {
    top: -19px;
    left: 50%;
    transform: translateX(-50%) rotate(90deg);
}
.cbyg-dir-vertical .cbyg-nav-next {
    bottom: -19px;
    left: 50%;
    transform: translateX(-50%) rotate(90deg);
}
.cbyg-dir-vertical .cbyg-nav-prev:hover {
    transform: translateX(-50%) rotate(90deg) scale(1.1);
}
.cbyg-dir-vertical .cbyg-nav-next:hover {
    transform: translateX(-50%) rotate(90deg) scale(1.1);
}

/* ── Pagination Numbers ── */
.cbyg-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 16px 0 5px;
}
.cbyg-pagination-dot {
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.cbyg-pagination-dot:hover {
    background: rgba(255,255,255,0.5);
    color: #fff;
}
.cbyg-pagination-dot.active {
    background: #fff;
    color: #1a4a8f;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

/* ── Custom Scrollbar ── */
.cbyg-scrollbar {
    height: 4px;
    background: var(--cbyg-content-scrollbar-bg, #e0e0e0);
    border-radius: 4px;
    margin-top: 10px;
    position: relative;
    overflow: hidden;
}
.cbyg-dir-vertical .cbyg-scrollbar {
    width: 4px;
    height: 200px;
    margin-top: 0;
    margin-left: 6px;
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
}
.cbyg-scrollbar-drag {
    height: 100%;
    background: var(--cbyg-content-scrollbar-slider, rgba(0,0,0,0.4));
    border-radius: 4px;
    position: absolute;
    left: 0;
    top: 0;
    transition: width 0.1s;
}

/* ── Widget Title Bar & Search ── */
.cbyg-widget-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}
.cbyg-widget-title {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}
.cbyg-search-wrap {
    position: relative;
    display: flex;
    max-width: 300px;
    width: 100%;
}
.cbyg-search-input {
    width: 100%;
    padding: 10px 45px 10px 16px;
    border: none;
    border-radius: 0;
    font-size: 15px;
    outline: none;
    background: #fff;
    color: #333;
}
.cbyg-search-btn {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 44px;
    background: #DCA722;
    border: none;
    cursor: pointer;
    color: #1a4a8f;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.cbyg-search-btn:hover {
    background: #eebd3a;
}

/* ─── Video Cards ────────────────────────────────────────────────────────── */

.cbyg-card {
    background: var(--cbyg-video-bg);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}
.cbyg-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.cbyg-card-link {
    text-decoration: none !important;
    display: block;
    height: 100%;
    color: inherit;
}

.cbyg-card-thumb-wrapper {
    position: relative;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
}

.cbyg-card-thumb {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
}

.cbyg-card-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.cbyg-play-icon {
    width: 46px;
    height: 46px;
    background: #1a59a7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s, background 0.2s;
}
.cbyg-play-icon svg {
    margin-left: 3px; /* visual center for play triangle */
}
.cbyg-card:hover .cbyg-play-icon {
    transform: scale(1.15);
    background: #256bcd;
}

.cbyg-card-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: var(--cbyg-video-duration-bg);
    color: var(--cbyg-video-duration);
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.cbyg-card-content {
    padding: 15px;
}

.cbyg-card-title {
    margin: 0 0 8px 0 !important;
    font-size: 16px;
    line-height: 1.3;
    color: var(--cbyg-video-title);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cbyg-card:hover .cbyg-card-title {
    color: var(--cbyg-video-title-hover);
}

.cbyg-card-date, .cbyg-card-meta {
    font-size: 12px;
    color: var(--cbyg-video-date);
}

.cbyg-card-desc {
    font-size: 13px;
    color: var(--cbyg-video-description);
    margin: 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cbyg-card-meta {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    color: var(--cbyg-video-counters);
}

.cbyg-card-meta .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    line-height: 1;
    vertical-align: middle;
}

/* Horizontal Layout */
.cbyg-layout-horizontal .cbyg-card-link {
    display: flex;
}
.cbyg-layout-horizontal .cbyg-card-thumb-wrapper {
    flex: 0 0 40%;
    padding-top: 22.5%; /* Keep aspect ratio logic, but relative */
}
.cbyg-layout-horizontal .cbyg-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Cinema Layout */
.cbyg-layout-cinema .cbyg-card-content {
    display: none;
}
.cbyg-layout-cinema .cbyg-card-overlay {
    flex-direction: column;
    padding: 20px;
    text-align: center;
    background: rgba(0,0,0,0.8);
}
.cbyg-layout-cinema .cbyg-card-overlay .cbyg-card-content {
    display: block;
    padding: 0;
    margin-bottom: auto;
}
.cbyg-layout-cinema .cbyg-card-title,
.cbyg-layout-cinema .cbyg-card-date,
.cbyg-layout-cinema .cbyg-card-meta {
    color: #fff;
}
.cbyg-layout-cinema .cbyg-play-icon {
    margin: auto;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.cbyg-load-more-wrapper {
    text-align: center;
    margin-top: 20px;
}
.cbyg-load-more {
    background: transparent;
    border: 2px solid var(--cbyg-groups-link);
    color: var(--cbyg-groups-link);
    padding: 10px 30px;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.cbyg-load-more:hover {
    border-color: var(--cbyg-groups-link-hover);
    color: var(--cbyg-groups-link-hover);
}

/* ─── Modal / Lightbox ───────────────────────────────────────────────────── */

.cbyg-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999999;
}
.cbyg-modal.cbyg-active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cbyg-modal-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cbyg-popup-overlay, rgba(0,0,0,0.8));
}

.cbyg-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    background: var(--cbyg-popup-bg, #fff);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cbyg-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 30px;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.cbyg-modal-inner {
    display: flex;
    flex-direction: row;
    height: 100%;
    max-height: 90vh;
}

.cbyg-modal-video-container {
    flex: 2;
    background: #000;
    display: flex;
    align-items: center;
}

.cbyg-modal-iframe-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
}

.cbyg-modal-iframe-wrapper iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

.cbyg-modal-sidebar {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    background: var(--cbyg-popup-bg);
    overflow-y: auto;
}
.cbyg-modal-sidebar-inner {
    padding: 24px;
}

.cbyg-modal-title {
    margin: 0 0 10px 0 !important;
    font-size: 18px;
    color: var(--cbyg-popup-title);
}

.cbyg-modal-stats {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: var(--cbyg-popup-views-counter);
    margin-bottom: 10px;
}

.cbyg-modal-likes-bar {
    height: 3px;
    background: var(--cbyg-popup-dislikes-ratio, #ccc);
    margin-bottom: 20px;
    border-radius: 2px;
}
.cbyg-modal-likes-fill {
    height: 100%;
    background: var(--cbyg-popup-likes-ratio, #2fa5ff);
    width: 0%; /* updated via JS */
}

.cbyg-modal-channel-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}
.cbyg-modal-channel-logo {
    width: 48px; height: 48px;
    border-radius: 50%;
}
.cbyg-modal-channel-name {
    margin: 0 0 5px 0 !important;
    font-size: 15px;
}
.cbyg-modal-channel-name a {
    color: var(--cbyg-popup-channel-name);
    text-decoration: none;
}

.cbyg-modal-desc {
    font-size: 14px;
    color: var(--cbyg-popup-description);
    margin-bottom: 20px;
    line-height: 1.5;
}
.cbyg-modal-desc-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cbyg-modal-desc.expanded .cbyg-modal-desc-text {
    display: block;
}
.cbyg-modal-desc-more {
    background: none;
    border: none;
    padding: 0;
    color: var(--cbyg-popup-description-more-btn);
    cursor: pointer;
    font-weight: 600;
    margin-top: 5px;
}

.cbyg-modal-share {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}
.cbyg-modal-share-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.cbyg-modal-share-btn {
    background: #f0f0f0;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.cbyg-comments-list {
    list-style: none;
    padding: 0; margin: 0;
}
.cbyg-comment {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}
.cbyg-comment-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
}
.cbyg-comment-author {
    font-weight: 600;
    font-size: 13px;
    color: var(--cbyg-popup-comments-username);
}
.cbyg-comment-time {
    font-size: 12px;
    color: var(--cbyg-popup-comments-time);
    margin-left: 8px;
}
.cbyg-comment-text {
    font-size: 14px;
    color: var(--cbyg-popup-comments-text);
    margin: 5px 0;
}

/* Spinner */
.cbyg-loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(0,0,0,0.1);
    border-radius: 50%;
    border-top-color: #333;
    animation: cbyg-spin 1s ease-in-out infinite;
    margin: 20px auto;
}
@keyframes cbyg-spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .cbyg-grid {
        grid-template-columns: 1fr !important;
    }
    
    .cbyg-modal-inner {
        flex-direction: column;
    }
    .cbyg-modal-video-container {
        flex: none;
    }
    .cbyg-modal-sidebar {
        flex: 1;
        max-width: 100%;
    }
    
    .cbyg-header-inner {
        flex-direction: column;
        text-align: center;
    }
    .cbyg-header-stats {
        justify-content: center;
    }
}
