/* =========================================
   1. БАЛУНЫ НА КАРТЕ (ОДИНОЧНЫЕ И КЛАСТЕРЫ)
   ========================================= */
.modern-balloon-root {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    z-index: 9999;
    overflow: hidden;
}

.modern-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    border: none;
    color: #888;
    background-color: #f0f0f0;
    transition: all 0.2s ease;
}

.modern-close-btn:hover {
    background-color: var(--danger-color);
    color: #fff;
    transform: scale(1.05);
}

.sidebar-toggle-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: none;
    color: var(--brand-primary);
    background-color: var(--brand-light-alpha);
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background-color: var(--brand-primary);
    color: #fff;
    transform: scale(1.05);
}

.simple-balloon {
    width: 360px;
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

.simple-balloon.schemas-balloon {
    width: 720px !important;
}

.simple-balloon-header {
    padding: 12px 50px 12px 15px;
    font-weight: 700;
    font-size: 14px;
    color: var(--brand-primary);
    border-bottom: 1px solid #eee;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.simple-balloon-body {
    flex: 1;
    background: #000;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    overflow: hidden;
}

.simple-balloon-body.schemas-balloon-body {
    background-color: #fff !important; 
}

.simple-balloon-footer {
    padding: 8px 15px;
    font-size: 11px;
    color: #999;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    text-align: right;
}

.cluster-layout {
    display: flex;
    width: 720px;
    height: 480px;
    transition: width 0.3s;
}

.cluster-sidebar {
    width: 220px;
    background: #f7f8fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cluster-layout.sidebar-closed .cluster-sidebar {
    margin-left: -220px;
}

.cluster-header {
    padding: 12px 15px;
    font-size: 12px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    height: 45px;
    display: flex;
    align-items: center;
}

.cluster-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    list-style: none;
    padding: 0;
    margin: 0;
}

.cluster-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    line-height: 1.4;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.cluster-item:hover {
    background: #fff;
    color: var(--brand-primary);
    padding-left: 18px;
}

.cluster-item.active {
    background: #fff;
    color: var(--brand-primary);
    font-weight: 600;
    border-left: 3px solid var(--brand-primary);
}

.cluster-sidebar-footer {
    padding: 12px 15px;
    border-top: 1px solid #e0e0e0;
    background: #fff;
    margin-top: auto;
}

.open-all-btn {
    width: 100%;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.open-all-btn:hover {
    background: var(--brand-hover);
}

.open-all-btn:active {
    transform: scale(0.98);
}

.cluster-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
    min-width: 0;
}

.cluster-view-header {
    background: #fff;
    padding-left: 50px;
    padding-right: 35px;
    box-sizing: border-box;
    width: 100%;
    height: 45px;
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
}

.cluster-view-body {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

.cluster-view-body .cam-id-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    z-index: 15;
    pointer-events: none;
}

.cluster-view-body img,
.cluster-view-body .preview,
.simple-balloon-body .preview,
.simple-balloon-body img,
.embed_video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    background: #000;
    display: block;
}

.simple-balloon-body img,
.cluster-view-body img {
    display: none !important;
}

.balloon-video-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.balloon-preview-container {
    flex: 1;
    width: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
    position: relative;
    background-color: #000;
    display: block;
    min-height: 150px;
    position: relative;
    cursor: pointer;
}

.balloon-preview-container .play.btn-play-window {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.balloon-preview-container .play.btn-play-window::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.balloon-preview-container .play.btn-play-window::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: 3px; 
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 18px;
    border-color: transparent transparent transparent #ffffff;
    transition: transform 0.2s ease;
}

.balloon-preview-container:hover .play.btn-play-window::before {
    background-color: rgba(93, 98, 211, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
    border-color: transparent;
}

.balloon-preview-container:hover .play.btn-play-window::after {
    transform: translate(-50%, -50%) scale(1.1); 
}

/* =========================================
   2. ОКНО ПЛЕЕРА
   ========================================= */
.video-container {
    width: 1296px;
    height: 858px;
    min-height: 300px;
    min-width: 400px;
    background-color: transparent;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    position: absolute;
    top: 30px;
    left: 250px;
}

.video-container .top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    padding: 10px 10px 0 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    color: #fff;
    z-index: 10;
    gap: 8px;
    pointer-events: none;
}

.video-container .top-bar .btn {
    pointer-events: auto;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.video-container .top-bar .btn:hover {
    background-color: var(--danger-color);
    transform: scale(1.05);
}

.video-container .top-bar .btn.stack-btn:hover {
    background-color: var(--brand-primary);
}

.video-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    min-height: 0;
    background-color: #000;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #000;
    pointer-events: auto;
    opacity: 1;
}

.video-wrapper video::-webkit-media-controls-timeline,
.video-wrapper video::-webkit-media-controls-time-remaining-display,
.video-wrapper video::-webkit-media-controls-current-time-display {
    display: none !important;
}

.video-container .bottom-bar {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    padding: 10px 15px;
    gap: 15px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.title-container {
    flex: 1;
    min-width: 0;
    padding: 6px 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(239, 243, 255, 0.6);
    transition: background 0.3s ease;
}

.video-container:hover .bottom-bar,
.video-container.is-moving .bottom-bar {
    background: #fff;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    border-top: 1px solid #eaeaea;
}

.video-container:hover .title-container,
.video-container.is-moving .title-container {
    background: var(--brand-light);
}

.video-title {
    color: var(--brand-primary);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.video-record-days {
    font-size: 11px;
    color: #777;
    margin-top: 2px;
}

.actions-container {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    background: var(--brand-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: all 0.2s;
    font-size: 16px;
    text-decoration: none;
}

.action-btn:hover,
.action-btn:focus {
    background: var(--brand-hover);
    text-decoration: none;
    color: white;
    transform: translateY(-1px);
}

.action-btn img.icon {
    width: 16px;
    height: 16px;
}

.skeleton-loading {
    background: linear-gradient(90deg, #111 25%, #2a2a2a 50%, #111 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s infinite linear;
    border-radius: 8px;
}

@keyframes skeleton-pulse {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-loading video,
.skeleton-loading iframe {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-container .video-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background-color: #000;
}

.video-content iframe {
    width: 100%;
    flex: 1;
    border: none;
    pointer-events: auto;
    background-color: #000;
    opacity: 1;
}

.iframe-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.iframe-controls .top-bar {
    display: flex;
    padding: 10px 10px 0 0;
    justify-content: flex-end;
    gap: 8px;
}

.iframe-controls .btn {
    pointer-events: auto;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.iframe-controls .btn:hover {
    background-color: var(--danger-color);
    transform: scale(1.05);
}

.iframe-controls .btn.buy-record {
    background-color: var(--brand-primary);
    color: #fff;
    border-radius: 6px;
    width: fit-content;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.iframe-controls .btn.buy-record:hover {
    background-color: var(--brand-hover);
    color: #fff;
    text-decoration: none;
}

/* =========================================
   3. МИНИ-ПЛЕЕРЫ
   ========================================= */
.stack-outer-wrapper {
    position: fixed;
    bottom: 10px;
    left: 0;
    width: 100%;
    z-index: 900;
    pointer-events: none;
}

.stack-container {
    display: flex;
    flex-wrap: wrap-reverse;
    justify-content: center;
    gap: 10px;
    max-width: 100%;
    pointer-events: all;
    max-height: 50vh;
    overflow-y: auto;
    padding: 10px;
    padding-left: 210px;
    transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.stack-container.expanded {
    max-height: calc(100vh - 70px);
}

.stack-container.minimized {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
}

.stack-controls {
    position: absolute;
    top: -45px;
    right: 15px;
    display: flex;
    gap: 8px;
    z-index: 10;
    pointer-events: auto;
}

.stack-control-btn {
    width: 36px;
    height: 36px;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    opacity: 0.5;
}

.stack-control-btn:hover {
    background: var(--brand-hover);
    transform: translateY(-2px);
    opacity: 1;
}

.stack-control-btn.close-all-btn:hover {
    background: var(--danger-color);
}

.stack-video-block {
    width: 320px;
    height: 240px;
    background-color: #000;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
}

.stack-video-block .top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    height: 30px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 5px;
    background: transparent;
    color: #fff;
    z-index: 10;
}

.stack-video-block .top-bar .btn {
    background: var(--brand-primary);
    color: white;
    border: none;
    padding: 2px 6px;
    margin-left: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.5;
}

.stack-video-block .top-bar .btn:hover {
    opacity: 1;
}

.stack-video-block .top-bar .btn.close-btn:hover {
    background-color: var(--danger-color);
}

.stack-video-block .stack-preview {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.stack-video-block .stack-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =========================================
   4. ОСТАЛЬНЫЕ ЭЛЕМЕНТЫ (МОДАЛКИ, ПОПОВЕРЫ)
   ========================================= */
@media (max-width: 768px) {
    .action-btn {
        width: 30px;
        height: 30px;
        padding: 4px 8px;
    }
}

#modal-cams {
    pointer-events: none;
}

#modal-cams .modal-dialog {
    pointer-events: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

body.modal-open {
    overflow: auto !important;
    padding-right: 0 !important;
}

.modal-backdrop {
    display: none !important;
}

.modal {
    z-index: 99999 !important;
}

.popover.cam-settings-popover {
    background-color: #f8f8f8;
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    padding: 0 !important;
    font-family: inherit;
}

.cam-settings-popover .popover-title {
    background-color: #f8f8f8 !important;
    color: var(--brand-primary);
    font-weight: 600;
    font-size: 14px;
    padding: 12px 15px;
    border-bottom: 1px solid #e5e5e5;
    border-radius: 12px 12px 0 0 !important;
}

.cam-settings-popover .popover-content {
    border-radius: 0 0 12px 12px !important;
    padding: 10px 15px;
}

.cam-popover-list {
    list-style: none;
    padding: 0;
    margin: 0;

    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px;
}

.cam-popover-list li {
    margin-bottom: 12px;
}

.cam-popover-list li:last-child {
    margin-bottom: 0;
}

.cam-popover-list a {
    display: flex;
    align-items: center;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease-in-out;
}

.cam-popover-list a:hover {
    color: var(--brand-primary);
}

.cam-popover-list a i {
    margin-right: 10px;
    font-size: 16px;
    color: var(--brand-primary);
    width: 16px;
    text-align: center;
}

.popover-subtitle {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: #888;
    font-weight: 500;
}

.sets-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background-color: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.sets-select:focus {
    border-color: var(--brand-primary);
}

.cam-settings-popover.right>.arrow {
    border-right-color: transparent;
}

.cam-settings-popover.right>.arrow:after {
    border-right-color: #f8f8f8;
}

.cam-settings-popover.left>.arrow {
    border-left-color: transparent;
}

.cam-settings-popover.left>.arrow:after {
    border-left-color: #f8f8f8;
}

.cam-settings-popover.top>.arrow {
    border-top-color: transparent;
}

.cam-settings-popover.top>.arrow:after {
    border-top-color: #f8f8f8;
}

.cam-settings-popover.bottom>.arrow {
    border-bottom-color: transparent;
}

.cam-settings-popover.bottom>.arrow:after {
    border-bottom-color: #f8f8f8;
    top: 1px;
}