/**
 * Channel Grid Styles
 *
 * Provides styling for all 6 channel display skins:
 * grid, list, carousel, overlay, overlay-carousel, minimal.
 *
 * Uses CSS custom properties for easy theming via shortcode
 * attributes, Elementor controls, and Gutenberg block settings.
 *
 * @package Tvstartup_OTT_Platform
 * @since   1.5.0
 */

/* ==========================================================================
   CSS Custom Properties (Defaults)
   ========================================================================== */

.ts-ott-channels {
    --ts-ott-font-family: inherit;
    --ts-ott-title-color: #1a1a2e;
    --ts-ott-desc-color: #6b7280;
    --ts-ott-bg-color: #ffffff;
    --ts-ott-accent-color: #6366f1;
    --ts-ott-border-radius: 12px;
    --ts-ott-card-padding: 1rem;
    --ts-ott-card-spacing: 1.25rem;
    --ts-ott-columns: 3;
    --ts-ott-transition: 0.25s ease;

    font-family: var(--ts-ott-font-family);
    box-sizing: border-box;
    width: 100%;
}

.ts-ott-channels *,
.ts-ott-channels *::before,
.ts-ott-channels *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.ts-ott-channels--empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ts-ott-desc-color);
    font-size: 1rem;
}

/* ==========================================================================
   Channel Card Link Wrapper
   ========================================================================== */

.ts-ott-channel-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.ts-ott-channel-card-link:hover,
.ts-ott-channel-card-link:focus,
.ts-ott-channel-card-link:active {
    text-decoration: none;
    color: inherit;
}

/* ==========================================================================
   Channel Card (Base Styles)
   ========================================================================== */

.ts-ott-channel-card {
    background-color: var(--ts-ott-bg-color);
    border-radius: var(--ts-ott-border-radius);
    overflow: hidden;
    transition: transform var(--ts-ott-transition),
                box-shadow var(--ts-ott-transition);
    position: relative;
}

.ts-ott-channel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* --- Thumbnail --- */

.ts-ott-channel-card__thumbnail {
    position: relative;
    overflow: hidden;
    background-color: #f3f4f6;
    aspect-ratio: 16 / 9;
}

.ts-ott-channel-card__thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--ts-ott-transition);
}

.ts-ott-channel-card:hover .ts-ott-channel-card__thumbnail img {
    transform: scale(1.05);
}

.ts-ott-channel-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    background-color: #f3f4f6;
    color: #d1d5db;
}

/* --- Content --- */

.ts-ott-channel-card__content {
    padding: var(--ts-ott-card-padding);
}

.ts-ott-channel-card__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ts-ott-title-color);
    margin: 0 0 0.375rem 0;
    line-height: 1.3;
    font-family: var(--ts-ott-font-family);
}

.ts-ott-channel-card__desc {
    font-size: 0.875rem;
    color: var(--ts-ott-desc-color);
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

/* --- Status Badge --- */

.ts-ott-channel-card__status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.5rem;
}

.ts-ott-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ts-ott-status--online {
    color: #22c55e;
}

.ts-ott-status--online .ts-ott-status-dot {
    background-color: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
    animation: ts-ott-pulse 2s infinite;
}

.ts-ott-status--offline {
    color: #9ca3af;
}

.ts-ott-status--offline .ts-ott-status-dot {
    background-color: #9ca3af;
}

@keyframes ts-ott-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* --- Genre Tags --- */

.ts-ott-channel-card__genres {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.ts-ott-genre-tag {
    display: inline-block;
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--ts-ott-accent-color);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.1875rem 0.5rem;
    border-radius: 9999px;
    line-height: 1.4;
}

/* ==========================================================================
   Skin: Grid
   ========================================================================== */

.ts-ott-channels--grid {
    display: grid;
    grid-template-columns: repeat(var(--ts-ott-columns), 1fr);
    gap: var(--ts-ott-card-spacing);
}

.ts-ott-channels--grid .ts-ott-channel-card__thumbnail {
    aspect-ratio: 16 / 9;
}

.ts-ott-channels--grid .ts-ott-channel-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   Skin: List
   ========================================================================== */

.ts-ott-channels--list {
    display: flex;
    flex-direction: column;
    gap: var(--ts-ott-card-spacing);
}

.ts-ott-channels--list .ts-ott-channel-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.ts-ott-channels--list .ts-ott-channel-card__thumbnail {
    width: 240px;
    min-width: 240px;
    flex-shrink: 0;
}

.ts-ott-channels--list .ts-ott-channel-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-ott-channels--list .ts-ott-channel-card__content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

/* ==========================================================================
   Skin: Carousel
   ========================================================================== */

.ts-ott-channels--carousel {
    position: relative;
    overflow: hidden;
}

.ts-ott-channels__track {
    display: flex;
    gap: var(--ts-ott-card-spacing);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    padding-bottom: 0.5rem;
}

.ts-ott-channels__track::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.ts-ott-channels--carousel .ts-ott-channel-card {
    flex: 0 0 calc(33.333% - var(--ts-ott-card-spacing) * 2 / 3);
    scroll-snap-align: start;
    min-width: 280px;
}

.ts-ott-channels--carousel .ts-ott-channel-card__thumbnail {
    aspect-ratio: 16 / 9;
}

.ts-ott-channels--carousel .ts-ott-channel-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Carousel Buttons */

.ts-ott-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background-color: var(--ts-ott-bg-color);
    color: var(--ts-ott-title-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--ts-ott-transition),
                box-shadow var(--ts-ott-transition),
                opacity var(--ts-ott-transition);
    opacity: 0;
    padding: 0;
}

.ts-ott-channels--carousel:hover .ts-ott-carousel-btn {
    opacity: 1;
}

.ts-ott-carousel-btn:hover {
    background-color: var(--ts-ott-accent-color);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.ts-ott-carousel-btn--prev {
    left: 12px;
}

.ts-ott-carousel-btn--next {
    right: 12px;
}

.ts-ott-carousel-btn svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Skin: Overlay
   ========================================================================== */

.ts-ott-channels--overlay {
    display: grid;
    grid-template-columns: repeat(var(--ts-ott-columns), 1fr);
    gap: var(--ts-ott-card-spacing);
}

.ts-ott-channels--overlay .ts-ott-channel-card {
    cursor: pointer;
}

.ts-ott-channels--overlay .ts-ott-channel-card__thumbnail {
    aspect-ratio: 16 / 9;
}

.ts-ott-channels--overlay .ts-ott-channel-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-ott-channel-card__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--ts-ott-card-padding);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
    color: #ffffff;
    transform: translateY(100%);
    transition: transform var(--ts-ott-transition);
}

.ts-ott-channels--overlay .ts-ott-channel-card:hover .ts-ott-channel-card__overlay {
    transform: translateY(0);
}

.ts-ott-channel-card__overlay .ts-ott-channel-card__title {
    color: #ffffff;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ts-ott-channel-card__overlay .ts-ott-channel-card__desc {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8125rem;
    margin-bottom: 0;
}

/* Status badge on overlay thumbnail */
.ts-ott-channels--overlay .ts-ott-channel-card__status {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    backdrop-filter: blur(4px);
    z-index: 5;
    margin-bottom: 0;
}

.ts-ott-channels--overlay .ts-ott-status--online {
    color: #4ade80;
}

.ts-ott-channels--overlay .ts-ott-status--offline {
    color: #d1d5db;
}

/* ==========================================================================
   Skin: Overlay Carousel
   ========================================================================== */

.ts-ott-channels--overlay-carousel {
    position: relative;
    overflow: hidden;
}

.ts-ott-channels--overlay-carousel .ts-ott-channels__track {
    display: flex;
    gap: var(--ts-ott-card-spacing);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.5rem;
}

.ts-ott-channels--overlay-carousel .ts-ott-channels__track::-webkit-scrollbar {
    display: none;
}

.ts-ott-channels--overlay-carousel .ts-ott-channel-card {
    flex: 0 0 calc(33.333% - var(--ts-ott-card-spacing) * 2 / 3);
    scroll-snap-align: start;
    min-width: 280px;
    cursor: pointer;
}

.ts-ott-channels--overlay-carousel .ts-ott-channel-card__thumbnail {
    aspect-ratio: 16 / 9;
}

.ts-ott-channels--overlay-carousel .ts-ott-channel-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Overlay text on hover */
.ts-ott-channels--overlay-carousel .ts-ott-channel-card__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--ts-ott-card-padding);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
    color: #ffffff;
    transform: translateY(100%);
    transition: transform var(--ts-ott-transition);
}

.ts-ott-channels--overlay-carousel .ts-ott-channel-card:hover .ts-ott-channel-card__overlay {
    transform: translateY(0);
}

.ts-ott-channels--overlay-carousel .ts-ott-channel-card__overlay .ts-ott-channel-card__title {
    color: #ffffff;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ts-ott-channels--overlay-carousel .ts-ott-channel-card__overlay .ts-ott-channel-card__desc {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8125rem;
    margin-bottom: 0;
}

/* Status badge on overlay-carousel thumbnail */
.ts-ott-channels--overlay-carousel .ts-ott-channel-card__status {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    backdrop-filter: blur(4px);
    z-index: 5;
    margin-bottom: 0;
}

.ts-ott-channels--overlay-carousel .ts-ott-status--online {
    color: #4ade80;
}

.ts-ott-channels--overlay-carousel .ts-ott-status--offline {
    color: #d1d5db;
}

/* Reuse carousel nav buttons */
.ts-ott-channels--overlay-carousel .ts-ott-carousel-btn {
    /* Buttons are already styled in the base carousel section */
}

.ts-ott-channels--overlay-carousel:hover .ts-ott-carousel-btn {
    opacity: 1;
}

/* ==========================================================================
   Skin: Minimal
   ========================================================================== */

.ts-ott-channels--minimal {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ts-ott-channels--minimal .ts-ott-channel-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 0;
    border-radius: 0;
    border-bottom: 1px solid #f3f4f6;
    background: transparent;
}

.ts-ott-channels--minimal .ts-ott-channel-card:last-child {
    border-bottom: none;
}

.ts-ott-channels--minimal .ts-ott-channel-card:hover {
    transform: none;
    box-shadow: none;
    background-color: #fafafa;
}

.ts-ott-channels--minimal .ts-ott-channel-card__thumbnail {
    width: 64px;
    min-width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 1rem;
}

.ts-ott-channels--minimal .ts-ott-channel-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-ott-channels--minimal .ts-ott-channel-card__placeholder {
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
}

.ts-ott-channels--minimal .ts-ott-channel-card__placeholder svg {
    width: 24px;
    height: 24px;
}

.ts-ott-channels--minimal .ts-ott-channel-card__content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0;
    flex: 1;
    min-width: 0;
}

.ts-ott-channels--minimal .ts-ott-channel-card__title {
    font-size: 0.9375rem;
    margin-bottom: 0.125rem;
}

.ts-ott-channels--minimal .ts-ott-channel-card__desc {
    font-size: 0.8125rem;
    margin-bottom: 0;
}

.ts-ott-channels--minimal .ts-ott-channel-card__status {
    margin-bottom: 0.25rem;
    font-size: 0.6875rem;
}

/* ==========================================================================
   Responsive: Tablet (max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {
    /* Grid: reduce to 2 columns */
    .ts-ott-channels--grid {
        --ts-ott-columns: 2;
    }

    /* Overlay: reduce to 2 columns */
    .ts-ott-channels--overlay {
        --ts-ott-columns: 2;
    }

    /* List: stack vertically */
    .ts-ott-channels--list .ts-ott-channel-card__thumbnail {
        width: 180px;
        min-width: 180px;
    }

    /* Carousel: show fewer items */
    .ts-ott-channels--carousel .ts-ott-channel-card {
        flex: 0 0 calc(50% - var(--ts-ott-card-spacing) / 2);
        min-width: 240px;
    }

    /* Overlay Carousel: show fewer items */
    .ts-ott-channels--overlay-carousel .ts-ott-channel-card {
        flex: 0 0 calc(50% - var(--ts-ott-card-spacing) / 2);
        min-width: 240px;
    }

    /* Show carousel buttons on touch devices */
    .ts-ott-carousel-btn {
        opacity: 1;
    }
}

/* ==========================================================================
   Responsive: Mobile (max-width: 480px)
   ========================================================================== */

@media (max-width: 480px) {
    /* Grid: single column */
    .ts-ott-channels--grid {
        --ts-ott-columns: 1;
    }

    /* Overlay: single column */
    .ts-ott-channels--overlay {
        --ts-ott-columns: 1;
    }

    /* List: full-width stack */
    .ts-ott-channels--list .ts-ott-channel-card {
        flex-direction: column;
    }

    .ts-ott-channels--list .ts-ott-channel-card__thumbnail {
        width: 100%;
        min-width: 100%;
        aspect-ratio: 16 / 9;
    }

    /* Carousel: single item */
    .ts-ott-channels--carousel .ts-ott-channel-card {
        flex: 0 0 100%;
        min-width: 100%;
    }

    /* Overlay Carousel: single item */
    .ts-ott-channels--overlay-carousel .ts-ott-channel-card {
        flex: 0 0 100%;
        min-width: 100%;
    }

    /* Card spacing reduction */
    .ts-ott-channels {
        --ts-ott-card-spacing: 0.75rem;
    }

    .ts-ott-channel-card__title {
        font-size: 1rem;
    }

    .ts-ott-channel-card__desc {
        font-size: 0.8125rem;
    }
}

/* ==========================================================================
   Gutenberg Editor Preview Wrapper
   ========================================================================== */

.ts-ott-block-preview {
    padding: 0;
}
