/* Стили модального окна в стиле "Mulan" */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    backdrop-filter: blur(8px);
}

.modal-overlay.main-page {
    z-index: 2000;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 100%;
    height: 100vh;
    background: #1a1a1c;
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal.with-topbar {
    height: calc(100vh - 70px);
    margin-top: 70px;
    overflow-y: auto;
}

.modal.with-topbar .player-frame-wrap {
    padding-bottom: 0;
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
}

.modal.with-topbar .modal-hero {
    display: none;
}

.modal.with-topbar .modal-secondary {
    padding: 0;
    margin: 0;
}

.modal.with-topbar .player-container {
    margin-bottom: 0;
    border-radius: 0;
}

.modal-close-btn {
    position: absolute;
    top: 90px;
    right: 40px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.modal-overlay.main-page .modal-close-btn {
    display: none;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Hero Area */
.modal-hero {
    position: relative;
    width: 100%;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 100px 8% 60px 8%;
    box-sizing: border-box;
    overflow: hidden;
}

.modal.with-topbar .modal-hero {
    min-height: auto;
    padding: 40px 8%;
}

.modal-hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center 20%;
    z-index: 0;
}

.modal-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(26, 26, 28, 1) 0%, rgba(26, 26, 28, 0.8) 40%, rgba(26, 26, 28, 0.2) 100%),
        linear-gradient(0deg, rgba(26, 26, 28, 1) 0%, rgba(26, 26, 28, 0) 50%);
    z-index: 1;
}

.modal-hero-content {
    position: relative;
    z-index: 2;
    max-width: 650px;
    color: #fff;
}

.modal-hero-content h1 {
    font-size: clamp(48px, 8vw, 84px);
    font-weight: 800;
    margin: 0 0 20px 0;
    line-height: 1.1;
    letter-spacing: -2px;
}

.modal-meta-top {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.age-badge {
    background: #f2b749;
    color: #000;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 16px;
}

.m-duration {
    font-size: 18px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.modal-ratings {
    display: flex;
    gap: 25px;
    margin-bottom: 25px;
    font-size: 18px;
    font-weight: 600;
}

.rating-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rating-item .star {
    color: #f2b749;
    font-size: 20px;
}

#m-rating-kp,
#m-rating-imdb {
    color: #fff;
}

.modal-description {
    font-size: 18px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 40px;
    display: -webkit-box;
    -webkit-line-clamp: 10;
    -webkit-box-orient: vertical;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.btn-main-play {
    background: #f2b749;
    color: #000;
    border: none;
    padding: 16px 45px;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s, background 0.3s;
}

.btn-main-play:hover {
    background: #dfa33b;
    transform: scale(1.03);
}

.btn-main-play svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.btn-main-add {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    /*  border: 1px solid rgba(46, 204, 113, 0.3);*/
    padding: 15px 35px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(10px);
    box-sizing: border-box;
    transition: background 0.3s, transform 0.2s, border-color 0.3s, color 0.3s;
}

.btn-main-add:hover {
    background: rgba(46, 204, 113, 0.25);
    /* border-color: rgba(46, 204, 113, 0.5);*/
    /* transform: scale(0.8);*/
}

.btn-main-add.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    /* border: 1px solid transparent;*/
}

.btn-main-add.active:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: transparent;
}

.icon-plus {
    font-size: 24px;
    font-weight: 400;
}

.kp-rating-link {
    color: #ff6600;
    text-decoration: none;
    font-weight: bold;
    margin-left: 2px;
    transition: opacity 0.2s;
}

.kp-rating-link:hover {
    opacity: 0.8;
}

.imdb-rating-link {
    color: #f3ce13;
    text-decoration: none;
    font-weight: bold;
    margin-left: 2px;
    transition: opacity 0.2s;
}

.imdb-rating-link:hover {
    opacity: 0.8;
}

/* Hero Seasons (Right Side) */
.modal-hero-right {
    position: relative;
    z-index: 2;
    flex: 1;
    max-width: 400px;
    margin-left: 60px;
}

.hero-seasons-container {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 500px;
    min-width: 330px;
    display: flex;
    flex-direction: column;
}

.hero-seasons-container .section-title {
    margin-top: 0;
    font-size: 20px;
}

.season-list {
    overflow-y: auto;
    padding-right: 10px;
}

.season-list::-webkit-scrollbar {
    width: 6px;
}

.season-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* Similars Section (Bottom) */
.similars-section {
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 40px;
    margin: auto 30px;
}

.similars-scroll {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
    scrollbar-width: none;
}

.similars-scroll::-webkit-scrollbar {
    display: none;
}

#m-player-box {}

.player-container {
    width: 100%;
    max-width: calc((100vh - 150px) * 16 / 9);
    margin: 0 auto 50px auto;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

.player-header {
    background: #111;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.btn-close-player {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    width: 200px;
}

.player-source-row {
    /*width: 100%;*/
}

.select-player {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
}

.select-player option {
    background: #111;
}

.player-frame-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
}

.player-frame-wrap iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.modal-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    margin-bottom: 60px;
}

@media (max-width: 1000px) {
    .modal-details-grid {
        grid-template-columns: 1fr;
    }
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 25px;
    color: #fff;
    border-left: 4px solid #f2b749;
    padding-left: 15px;
}

.season-list {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.episode-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
}

.episode-row:last-child {
    border-bottom: none;
}

.episode-row.future {
    color: #f2b749;
    font-weight: 600;
}

/* Similars Scroll */
.similars-scroll {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
}

.sim-card {
    min-width: 160px;
    cursor: pointer;
    transition: transform 0.3s;
}

.sim-card:hover {
    transform: translateY(-8px);
}

.sim-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.btn-refresh {
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 25px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-refresh:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

/* Animations */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .modal-hero {
        min-height: auto;
        padding-top: 160px;
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-close-btn {
        top: 150px;
        right: 20px;
    }

    .modal-hero-bg {
        height: 60%;
    }

    .modal-hero-overlay {
        background: linear-gradient(0deg, rgba(26, 26, 28, 1) 0%, rgba(26, 26, 28, 0.7) 60%, rgba(26, 26, 28, 0.2) 100%);
    }

    .modal-hero-right {
        display: none;
    }

    .modal-hero-content h1 {
        font-size: 38px;
    }
}

/* Custom Popup Dialogs (User Management, Subscriptions, etc.) */
.modal-dialog {
    background: #151516;
    border-radius: 20px;
    padding: 35px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    border-left: 4px solid var(--accent);
    padding-left: 12px;
}

.modal-dialog .modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    font-size: 22px;
    background: rgba(255, 255, 255, 0.06);
}

.modal-dialog .modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.modal-dialog input,
.modal-dialog select {
    width: 100%;
    margin-bottom: 15px;
    box-sizing: border-box;
}

/* User management Action buttons styling */
.btn-action-edit,
.btn-action-subs,
.btn-action-delete {
    padding: 6px 10px;
    font-size: 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 5px;
    width: auto;
    margin-top: 0;
}

.btn-action-edit {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.btn-action-edit:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-action-subs {
    background: rgba(242, 183, 73, 0.1);
    color: #f2b749;
}

.btn-action-subs:hover {
    background: rgba(242, 183, 73, 0.2);
}

.btn-action-delete {
    background: rgba(255, 77, 77, 0.1);
    color: #ff4d4d;
}

.btn-action-delete:hover {
    background: rgba(255, 77, 77, 0.2);
}

/* --- Сворачивание модального окна (Мини-плеер в нижнем левом углу) --- */
.modal-overlay.minimized {
    position: fixed;
    top: auto !important;
    right: auto !important;
    bottom: 20px !important;
    left: 20px !important;
    width: 320px !important;
    height: 180px !important;
    background: transparent !important;
    z-index: 9999 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    backdrop-filter: none !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

.modal-overlay.minimized .modal {
    width: 100% !important;
    height: 100% !important;
    background: #151516 !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Скрываем все ненужные элементы при сворачивании */
.modal-overlay.minimized .modal-hero,
.modal-overlay.minimized .modal-secondary> :not(#m-player-box),
.modal-overlay.minimized .modal-footer-actions,
.modal-overlay.minimized .modal-close-btn,
.modal-overlay.minimized .player-header,
.modal-overlay.minimized #m-loader {
    display: none !important;
}

/* Принудительно передаем высоту 100% через все вложенные контейнеры к плееру */
.modal-overlay.minimized #m-content,
.modal-overlay.minimized .modal-secondary {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

.modal-overlay.minimized #m-player-box {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.modal-overlay.minimized .player-frame-wrap {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: auto !important;
    padding-bottom: 0 !important;
}

.modal-overlay.minimized .player-frame-wrap iframe {
    position: relative !important;
    /* Убираем absolute, чтобы iframe появился */
    width: 100% !important;
    height: 100% !important;
    border-radius: 12px !important;
}

/* Кнопка "Свернуть" в полноэкранном режиме */
.modal-minimize-btn {
    position: absolute;
    top: 90px;
    right: 94px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, transform 0.2s;
}

.modal-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Кнопка "Развернуть" в свернутом режиме */
.modal-maximize-btn {
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 20px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    transition: background 0.3s, transform 0.2s;
}

.modal-maximize-btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    transform: scale(1.1);
}

/* Скрываем кнопку свертывания на мобильных или меняем ее позицию */
@media (max-width: 768px) {
    .modal-minimize-btn {
        top: 150px;
        right: 74px;
    }
}