/* ========================================
   JustWatch Components - Consolidated Styles
   ======================================== */

/* ========================================
   1. SHARED STYLES
   ======================================== */

/* JustWatch Logo SVG */
.jw-logo-svg {
    filter: brightness(0) saturate(100%) invert(79%) sepia(56%) saturate(449%) hue-rotate(357deg) brightness(94%) contrast(97%);
}

/* Rank Badge Shared Styles */
.jw-rank-wrapper {
    display: flex;
    align-items: center;
    flex-direction: row;
}

.jw-rank-text {
    font-size: 24px;
    padding-left: 8px;
    padding-right: 8px;
    color: #bec1c5;
}

.jw-change-arrow {
    width: 8px;
    height: 6px;
}

.jw-change-arrow-negative {
    transform: rotate(180deg);
}

.jw-change-box {
    font-size: 16px;
    padding-left: 8px;
    display: flex;
    align-items: center;
    border-radius: 16px;
}

.jw-change-box-positive {
    border: 1px solid #47ad45;
}

.jw-change-box-negative {
    border: 1px solid #ff0000;
}

.jw-change-text {
    padding: 2px 6px 2px 4px;
}

.jw-change-text-positive {
    color: #47ad45;
}

.jw-change-text-negative {
    color: #ff0000;
}

/* ========================================
   2. STREAMING COMPONENT STYLES
   ======================================== */

.justwatch-streaming-component {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
}

/* Streaming Tabs Styles */
.jw-offers-container {
    /* Removed position: relative since arrows are now in wrapper */
}

.jw-tabs-wrapper {
    position: relative;
}

.jw-offers-container .nav-tabs {
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 0;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    scroll-behavior: smooth;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.jw-offers-container .nav-tabs::-webkit-scrollbar {
    display: none;
}

.jw-offers-container .nav-tabs .nav-item {
    margin-bottom: -2px;
    flex-shrink: 0;
}

.jw-offers-container .nav-tabs .nav-link {
    border: 1px solid transparent;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: #666;
    background: transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    white-space: nowrap;
}

.jw-offers-container .nav-tabs .nav-link:hover {
    border-color: #e9ecef #e9ecef #dee2e6;
    color: #333;
    background: #f8f9fa;
    text-decoration: none;
}

.jw-offers-container .nav-tabs .nav-link.active {
    color: #ffc107;
    background-color: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
    border-bottom: 2px solid #fff;
    font-weight: 600;
}

.jw-offers-container .nav-tabs .nav-link .badge {
    background-color: #007bff !important;
    color: #fff !important;
}

.jw-offers-container .nav-tabs .nav-link.active .badge {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.jw-offers-container .tab-content {
    padding-top: 0;
}

.jw-offers-container .tab-pane {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.jw-header h6 {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.jw-section-header {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    color: #666;
    gap: 3px;
}

.jw-section-header .badge {
    color: #fff;
}

.jw-providers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.jw-provider-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    background: #fff;
}

.jw-provider-card:hover {
    border-color: #ffc107;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    text-decoration: none;
    color: #333;
}

.jw-provider-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.jw-provider-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.jw-provider-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 8px;
}

.jw-provider-fallback i {
    font-size: 2rem;
    color: #999;
}

.jw-provider-info {
    text-align: center;
    width: 100%;
}

.jw-provider-name {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jw-quality-badge {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    background: #ffc107;
    color: #000;
    border-radius: 3px;
    text-transform: uppercase;
}

/* Ranks Section */
.jw-ranks-section {
    border-top: 1px solid #e0e0e0;
    padding-top: 1.5rem;
}

.jw-ranks-section h6 {
    font-weight: 600;
    color: #333;
}

.jw-rank-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.jw-rank-period {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.jw-rank-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.jw-rank-delta {
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.jw-rank-delta.positive {
    color: #28a745;
}

.jw-rank-delta.negative {
    color: #dc3545;
}

.jw-rank-link {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.jw-rank-link:hover {
    color: #ffc107;
    text-decoration: none;
}

/* Footer */
.jw-footer {
    border-top: 1px solid #e0e0e0;
    padding-top: 1rem;
}

.jw-powered-by {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.75rem;
}

.jw-powered-by:hover {
    text-decoration: none;
}

.jw-logo {
    font-weight: 700;
    color: #ffc107;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .jw-offers-container .nav-tabs .nav-link {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    .jw-providers-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }
    
    .jw-provider-icon {
        width: 50px;
        height: 50px;
    }
    
    .jw-rank-number {
        font-size: 1.5rem;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .justwatch-streaming-component {
        background: #1a1a1a;
    }
    
    .jw-header h6,
    .jw-ranks-section h6,
    .jw-rank-number,
    .jw-provider-card {
        color: #fff;
    }
    
    .jw-provider-card {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .jw-provider-card:hover {
        background: #333;
        border-color: #ffc107;
    }
    
    .jw-rank-card {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .jw-section-header,
    .jw-rank-period {
        color: #aaa;
    }
    
    .jw-rank-link {
        color: #fff;
    }
    
    .jw-rank-link:hover {
        color: #ffc107;
    }
}

/* ========================================
   3. RANK BADGE COMPONENT STYLES
   ======================================== */

.jw-rank-badge-link {
    text-decoration: none;
    display: inline-block;
}

.jw-rank-badge-link:hover .jw-rank-badge-wrapper {
    opacity: 0.8;
}

.jw-rank-badge-wrapper {
    display: flex;
    align-items: center;
    flex-direction: row;
    transition: opacity 0.2s ease;
}

/* ========================================
   4. FILM CARD COMPONENT STYLES
   ======================================== */

/* Film card title */
.jw-film-card__title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

/* Film card widget container */
.jw-film-card__widget-wrapper {
    margin-bottom: 1rem;
    max-width: 100%;
    overflow: hidden;
}

/* Constrain JustWatch widget inside carousel */
.jw-film-card__widget-wrapper [data-jw-widget] {
    max-width: 100% !important;
    width: 100% !important;
}

/* Override JustWatch widget styles to fit container */
.jw-film-card__widget-wrapper [data-jw-widget] > div {
    max-width: 100% !important;
}

/* Target the actual JustWatch widget iframe and containers after it loads */
.jw-film-card__widget-wrapper iframe,
.jw-film-card__widget-wrapper .jw-widget,
.jw-film-card__widget-wrapper .jw-widget-container {
    max-width: 100% !important;
    width: 100% !important;
}

/* Ensure widget content doesn't overflow */
.detail-carousel-wrap * {
    box-sizing: border-box;
}

/* Standalone rank badge (for carousel items) */
.jw-film-card__rank-standalone {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.jw-film-card__rank-badge {
    text-decoration: none;
    display: inline-block;
}

.jw-film-card__rank-badge:hover .jw-rank-wrapper {
    opacity: 0.8;
}

    .jw-film-card__rank-badge.fix_gap {
        padding-right: 11px;
    }

/* Carousel wrapper constraints */
.detail-carousel-wrap {
    max-width: 100%;
    overflow: visible;
    position: relative;
}

.detail-carousel-wrap .owl-carousel {
    width: 100%;
}

/* Film details item wrapper - ensure proper display */
.film-details-item {
    width: 100%;
    box-sizing: border-box;
    padding: 0 45px;
}

/* Streaming container within carousel - prevent overflow */
.film-streaming-container {
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

/* Ensure carousel items display properly */
#ind_details.owl-carousel .owl-item {
    float: left;
}

/* Prevent JustWatch component from overflowing in carousel */
#ind_details .justwatch-streaming-component {
    max-width: 100%;
    box-sizing: border-box;
}

#ind_details .jw-providers-grid {
    max-width: 100%;
}

/* Ensure carousel items don't expand beyond container */
#just_watch.owl-carousel .owl-item {
    width: 100% !important;
    max-width: 100%;
    overflow: hidden;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Constrain all content inside carousel items */
#just_watch.owl-carousel .owl-item > div {
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    padding: 0 45px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .film-details-item {
        padding: 0 15px;
    }
    
    #just_watch.owl-carousel .owl-item > div {
        padding: 0 15px;
    }
}

/* Responsive behavior for film card */
@media (max-width: 768px) {
    .jw-film-card__rank-standalone {
        justify-content: flex-start;
    }
    
    .jw-rank-text {
        font-size: 20px;
    }
}

/* ========================================
   5. FILM TABS STYLES
   ======================================== */

.jw-film-tabs {
    margin: 2rem 0;
}

.jw-film-tabs .nav-tabs {
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 1.5rem;
}

.jw-film-tabs .nav-item {
    margin-bottom: -2px;
}

.jw-film-tabs .nav-link {
    border: 1px solid transparent;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-weight: 500;
    color: #666;
    background: transparent;
    transition: all 0.2s ease;
}

.jw-film-tabs .nav-link:hover {
    border-color: #e9ecef #e9ecef #dee2e6;
    color: #333;
    background: #f8f9fa;
}

.jw-film-tabs .nav-link.active {
    color: #ffc107;
    background-color: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
    border-bottom: 2px solid #fff;
    font-weight: 600;
}

.jw-film-tabs .tab-content {
    padding: 1.5rem 0;
}

.jw-film-tabs .tab-pane {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsive tabs */
@media (max-width: 768px) {
    .jw-film-tabs .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    .jw-film-tabs .nav-item {
        flex-shrink: 0;
    }
    
    .jw-film-tabs .nav-link {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }
    
    .jw-film-tabs .tab-content {
        padding: 1rem 0;
    }
}

/* Tab Navigation Arrows - Specific to JustWatch tabs only */
.jw-tabs-wrapper .jw-tab-nav-arrow {
    position: absolute;
    top: 0;
    width: 40px;
    height: 100%;
    max-height: 48px;
    display: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
    cursor: pointer;
    z-index: 10;
    transition: opacity 0.2s ease;
    pointer-events: auto;
}

.jw-tabs-wrapper .jw-tab-nav-arrow.show {
    display: flex;
}

.jw-tabs-wrapper .jw-tab-nav-arrow:hover {
    opacity: 0.8;
}

.jw-tabs-wrapper .jw-tab-nav-arrow.left {
    left: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.jw-tabs-wrapper .jw-tab-nav-arrow.right {
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.jw-tabs-wrapper .jw-tab-nav-arrow i {
    font-size: 1.25rem;
    color: #666;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.9);
}

.jw-tabs-wrapper .jw-tab-nav-arrow:hover i {
    color: #ffc107;
}

/* Mobile specific arrow adjustments */
@media (max-width: 768px) {
    .jw-tabs-wrapper .jw-tab-nav-arrow {
        width: 32px;
        max-height: 44px;
    }
    
    .jw-tabs-wrapper .jw-tab-nav-arrow i {
        font-size: 1rem;
    }
}
