.video-widget {
    position: fixed;
    width: var(--collapsed-width, 80px);
    height: var(--collapsed-height, 120px);
    background: rgba(240, 240, 240, 0.5);
    border: 1px solid #ccc;
    cursor: move;
    transition: width 0.4s cubic-bezier(0.4, 0.0, 0.2, 1),
                height 0.4s cubic-bezier(0.4, 0.0, 0.2, 1),
                opacity 0.3s ease-in-out,
                visibility 0.3s ease-in-out;
    z-index: 9999;
    touch-action: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
}

.video-widget.expanded[data-aspect-ratio="16:9"] {
    height: min(var(--expanded-size-vh, 60vh), 80vh, calc(80vw * 9 / 16));
    width: calc(min(var(--expanded-size-vh, 60vh), 80vh, calc(80vw * 9 / 16)) * 16 / 9);
}

.video-widget.expanded[data-aspect-ratio="9:16"] {
    height: min(var(--expanded-size-vh, 60vh), 80vh);
    width: calc(min(var(--expanded-size-vh, 60vh), 80vh) * 9 / 16);
}

.video-widget[data-aspect-ratio="16:9"] {
    --aspect-width: 16;
    --aspect-height: 9;
}

.video-widget[data-aspect-ratio="9:16"] {
    --aspect-width: 9;
    --aspect-height: 16;
}

/* Класс для запуска анимации */
.video-widget.animate {
    visibility: visible;
}

/* Анимация Fade */
.video-widget[data-animation-type="fade"].animate {
    animation: fadeIn 0.5s ease-in-out forwards;
}

/* Анимация Slide с учётом позиции */
.video-widget[data-animation-type="slide"][data-initial-position="bottom-left"].animate,
.video-widget[data-animation-type="slide"][data-initial-position="bottom-right"].animate {
    animation: slideInFromBottom 0.5s ease-in-out forwards;
}

.video-widget[data-animation-type="slide"][data-initial-position="top-left"].animate,
.video-widget[data-animation-type="slide"][data-initial-position="top-right"].animate {
    animation: slideInFromTop 0.5s ease-in-out forwards;
}

/* Анимация Bounce */
.video-widget[data-animation-type="bounce"].animate {
    animation: bounceIn 0.8s ease-in-out forwards;
}

/* Keyframes для анимаций */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.video-widget.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.video-widget.animating {
    transition: width 0.6s cubic-bezier(0.4, 0.0, 0.2, 1),
                height 0.6s cubic-bezier(0.4, 0.0, 0.2, 1),
                transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1),
                top 0.6s cubic-bezier(0.4, 0.0, 0.2, 1),
                bottom 0.6s cubic-bezier(0.4, 0.0, 0.2, 1),
                left 0.6s cubic-bezier(0.4, 0.0, 0.2, 1),
                right 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.video-widget video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.widget-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: rgba(255,255,255,0.3);
    z-index: 2;
    display: none;
    cursor: pointer;
}

.video-widget.expanded .widget-progress-bar {
    display: block;
}

.progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: white;
    width: 0;
    transition: width 0.1s linear;
    pointer-events: none;
}

.timer {
    position: absolute;
    top: 15px;
    right: 15px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    display: none;
}

.video-widget.expanded .timer {
    display: block;
}

.controls {
    position: absolute;
    top: 50px;
    right: 15px;
    display: none;
    flex-direction: column;
    gap: 10px;
}

.video-widget.expanded .controls {
    display: flex;
}

.sound-btn {
    background: rgba(128,128,128,0.8);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background-color 0.2s;
}

.sound-btn:hover {
    background: rgba(128,128,128,0.9);
}

.play-control, .replay-control {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(128,128,128,0.8);
    border: none;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background-color 0.2s;
    z-index: 3;
}

.video-widget.expanded.ended .play-control {
    display: none;
}

.video-widget.expanded .play-control {
    display: flex;
}

.play-control:hover, .replay-control:hover {
    background: rgba(128,128,128,0.9);
}

.video-widget.playing .replay-control {
    display: none;
}

.video-widget.ended .replay-control {
    display: flex;
}

.video-widget.expanded.playing .play-control {
    opacity: 0;
    transition: opacity 0.3s;
}

.video-widget.expanded.playing:hover .play-control {
    opacity: 1;
}

.video-widget.expanded:not(.playing) .play-control {
    opacity: 1;
}

/* CTA Button Styles */
.video-widget .cta-button {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1a237e;
    color: white;
    padding: 12px 24px;
    font-size: 14px;
    border-radius: 8px;
    text-decoration: none;
    white-space: nowrap;
    text-align: center;
    font-weight: 500;
    opacity: 1;
    transition: 
        opacity 0.3s ease-in-out, 
        visibility 0.3s ease-in-out,
        transform 0.3s ease-in-out;
    z-index: 5;
}

.video-widget[data-video-played='true'] .cta-button {
    opacity: 1;
    visibility: visible;
}

.video-widget:not(.expanded) .cta-button, 
.video-widget:not([data-video-played='true']) .cta-button, 
.video-widget.animating .cta-button {
    visibility: hidden;
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

/* Hide Zone Styles */
.hide-zone {
    position: fixed;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 10001;
    transition: top 0.3s, background-color 0.3s;
    pointer-events: none;
}

.hide-zone.visible {
    top: 15px;
}

.hide-zone.active {
    background: rgba(209, 45, 28, 0.85);
}

.hide-zone.active i {
    color: rgba(255, 255, 255, 0.95);
}