/* Затемнение фона */
#cinema-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none;
}

/* Модальное окно */
#cinema-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    background: #ffffff;
    max-width: 1097px;
    max-height: 659px;
    width: 90vw;
    height: auto;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: none;
}

/* Заголовок */
#cinema-modal-header {
    background: #2c3e50;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #34495e;
    flex-shrink: 0;
}

#cinema-modal-title {
    color: white;
    font-size: 18px;
    font-weight: bold;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Табы */
#cinema-modal-tabs {
    display: flex;
    gap: 15px;
    flex: 2;
    justify-content: center;
}

.cinema-modal-tab {
    color: white;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px;
    background: #3498db;
    transition: background 0.3s ease;
    border: none;
    font-size: 14px;
    flex: none;
}

.cinema-modal-tab.current {
    background: #2980b9;
    font-weight: bold;
}

.cinema-modal-tab:hover {
    background: #2980b9;
}

/* Кнопка закрытия */
#cinema-modal-close {
    background: #e74c3c;
    border: none;
    padding: 0 20px;
    border-radius: 5px;
    cursor: pointer;
    color: white;
    font-weight: bold;
    transition: background 0.3s ease;
    font-size: 14px;
    flex: 1;
    max-width: 120px;
}

#cinema-modal-close:hover {
    background: #c0392b;
}

/* Контейнер для видео */
#cinema-modal-content {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
    width: 100%;
}

/* Видео враппер */
.cinema-video-wrapper {
    width: 100%;
    position: relative;
    background: #000;
}

/* Основной контейнер для видео */
.cinema-video-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Стили для видео боксов */
#cinema-modal .video_box {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
}

/* Плееры занимают всю площадь */
#cinema-modal .iframePlayer1,
#cinema-modal .iframePlayer {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    background: #000 !important;
}

/* Скрываем оригинальные табы */
#cinema-modal .tabs_sel {
    display: none !important;
}

/* Контейнер для сохранения соотношения сторон */
.video-box-inner {
    width: 100%;
    height: 100%;
    position: relative;
}

.video-box-inner iframe,
.video-box-inner div {
    width: 100%;
    height: 100%;
}

/* Адаптация для десктопов */
@media (min-width: 1025px) {
    .cinema-video-wrapper {
        height: 0;
        padding-bottom: 56.25%;
    }
    
    .cinema-video-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* Адаптация для планшетов */
@media (max-width: 1024px) and (min-width: 769px) {
    #cinema-modal {
        width: 95vw;
        max-width: 900px;
    }
    
    .cinema-video-wrapper {
        height: 0;
        padding-bottom: 56.25%;
    }
    
    .cinema-video-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    
    #cinema-modal-header {
        padding: 12px 16px;
    }
    
    #cinema-modal-title {
        font-size: 16px;
    }
    
    #cinema-modal-tabs {
        gap: 10px;
    }
    
    .cinema-modal-tab {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    #cinema-modal-close {
        padding: 0 16px;
        font-size: 13px;
        max-width: 110px;
    }
}

/* Адаптация для мобильных (768px и меньше) */
@media (max-width: 768px) {
    #cinema-modal {
        width: 98vw;
        max-width: none;
        border-radius: 6px;
    }
    
    .cinema-video-wrapper {
        height: 0;
        padding-bottom: 56.25%;
    }
    
    .cinema-video-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    
    #cinema-modal-header {
        padding: 10px 12px;
    }
    
    #cinema-modal-title {
        font-size: 15px;
    }
    
    #cinema-modal-tabs {
        gap: 5px;
    }
    
    .cinema-modal-tab {
        padding: 6px 12px;
        font-size: 12px;
        max-width: 120px;
    }
    
    #cinema-modal-close {
        padding: 0x 12px;
        font-size: 12px;
        max-width: 100px;
    }
}

/* ВЕРТИКАЛЬНАЯ ориентация на мобильных */
@media (max-width: 768px) and (orientation: portrait) {
    #cinema-modal {
        width: 95vw !important;
        height: auto !important;
        max-height: 90vh !important;
        border-radius: 12px !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
    
    #cinema-modal-header {
        padding: 15px 20px;
        min-height: 65px;
        flex-wrap: nowrap;
    }
    
    #cinema-modal-title {
        font-size: 16px;
        flex: 1;
        text-align: left;
    }
    
    #cinema-modal-tabs {
        flex: 1;
        justify-content: center;
        gap: 10px;
        margin: 0 15px;
    }
    
    .cinema-modal-tab {
        padding: 8px 15px;
        font-size: 13px;
        max-width: 120px;
    }
    
    #cinema-modal-close {
        flex: none;
        width: auto;
        padding: 0 15px;
        font-size: 13px;
        max-width: 100px;
    }
    
    .cinema-video-wrapper {
        height: auto !important;
        padding-bottom: 56.25% !important;
    }
    
    .cinema-video-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    #cinema-modal {
        width: 100vw;
        height: 100vh;
        max-height: none;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
    
    #cinema-modal-header {
        padding: 8px 12px;
        height: 50px;
        background: rgba(44, 62, 80, 0.95);
    }
    
    #cinema-modal-title {
        font-size: 14px;
    }
    
    #cinema-modal-tabs {
        gap: 5px;
    }
    
    .cinema-modal-tab {
        padding: 4px 8px;
        font-size: 11px;
        max-width: 90px;
    }
    
    #cinema-modal-close {
        padding: 0 8px;
        font-size: 11px;
        max-width: 80px;
    }
    
    .cinema-video-wrapper {
        height: calc(100vh - 50px) !important;
        padding-bottom: 0 !important;
    }
    
    .cinema-video-container {
        width: 100%;
        height: 100%;
    }
}

/* Для очень маленьких экранов в портретной ориентации */
@media (max-width: 360px) and (orientation: portrait) {
    #cinema-modal {
        width: 92vw !important;
        max-height: 85vh !important;
    }
    
    #cinema-modal-header {
        padding: 12px 15px;
        min-height: 60px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #cinema-modal-title {
        order: 1;
        width: 100%;
        text-align: center;
        font-size: 15px;
    }
    
    #cinema-modal-tabs {
        order: 2;
        width: 100%;
        justify-content: center;
        gap: 8px;
        margin: 0;
    }
    
    #cinema-modal-close {
        order: 3;
        width: 100%;
        max-width: none;
        margin-top: 5px;
        padding: 0 12px;
    }
    
    .cinema-modal-tab {
        max-width: 110px;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .cinema-video-wrapper {
        padding-bottom: 56.25% !important;
    }
}

/* Для очень маленьких экранов в ландшафтной ориентации */
@media (max-width: 480px) and (orientation: landscape) {
    #cinema-modal-header {
        padding: 6px 10px;
        height: 45px;
    }
    
    #cinema-modal-title {
        font-size: 13px;
    }
    
    .cinema-modal-tab {
        padding: 3px 6px;
        font-size: 10px;
        max-width: 80px;
    }
    
    #cinema-modal-close {
        padding: 0 6px;
        font-size: 10px;
        max-width: 70px;
    }
    
    .cinema-video-wrapper {
        height: calc(100vh - 45px) !important;
    }
}

/* Для планшетов в ландшафтной ориентации */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    .cinema-video-wrapper {
        height: 0;
        padding-bottom: 56.25%;
    }
    
    .cinema-video-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* Гарантируем, что затемнение всегда поверх всего */
#cinema-modal-overlay {
    z-index: 10000 !important;
}

#cinema-modal {
    z-index: 10001 !important;
}

/* Предотвращаем скроллинг тела когда модальное окно открыто */
body.cinema-modal-open {
    overflow: hidden !important;
    height: 100% !important;
}