/* ---------- Ваши исходные стили (с исправлениями) ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

#videoWidget {
    position: fixed;
    bottom: 20px; left: 20px;
    overflow: hidden;
    border-radius: 14px;
    background: transparent;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease,
                width 0.3s ease, height 0.3s ease;
    z-index: 9999;
}

.volume-range-vertical {
    display: none;
}

#videoWidget:not(.expanded) {
    width: 130px; height: 180px;
}
#videoWidget:not(.expanded):hover {
    transform: scale(1.05);
    box-shadow: 0 14px 21px 0 rgba(0,0,0,0.15), 0 0 0 3px #587640;
}

#videoWidget.expanded {
    width: 244px; height: 444px;
    background: #fff;
}

/* Видео – пропускает клики через себя */
.video-variant-preview-video {
    position: absolute; top: 50%; left: 50%;
    width: 100%; height: 100%;
    transform: translate(-50%,-50%);
    object-fit: cover;
    border-radius: 14px;
    z-index: 0;
    pointer-events: none; /* клики проходят сквозь видео */
}

/* Внутренний крестик (минус) – кликабельный */
.video-widget-close-btn {
    position: absolute; top: 8px; right: 8px;
    width: 24px; height: 24px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.8);
    font-size: 16px; line-height: 1;
    display: none; cursor: pointer;
    transition: background 0.2s;
    z-index: 2;
    pointer-events: auto; /* чтобы клик проходил */
}
#videoWidget.expanded .video-widget-close-btn {
    display: block;
}
#videoWidget.expanded .video-widget-close-btn:hover {
    background: #f0a500; color: #fff;
}

/* Блок громкости – кликабельный */
.video-widget-volume-vertical {
    position: absolute;
    top: 8px; right: 40px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 2;
    pointer-events: auto;
}
#videoWidget.expanded .video-widget-volume-vertical {
    display: flex;
}
.volume-btn {
    background: rgba(255,255,255,0.8);
    border: none; border-radius: 50%;
    width: 24px; height: 24px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    pointer-events: auto;
}
.volume-btn:hover {
    background: #f0a5003; color: #fff;
}
.volume-range-vertical {
    writing-mode: bt-lr;
    width: 4px; height: 80px;
    background: rgba(255,255,255,0.5);
    border-radius: 2px;
    appearance: none;
    cursor: pointer;
    pointer-events: auto;
}
.volume-range-vertical::-webkit-slider-thumb,
.volume-range-vertical::-moz-range-thumb {
    width: 12px; height: 12px;
    background: #f0a500;
    border-radius: 50%;
    cursor: pointer;
}

/* Прогресс – не интерактивен */
.progress-container {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 4px;
    background: rgba(0,0,0,0.2);
    overflow: hidden;
    border-radius: 2px 2px 0 0;
    display: none;
    z-index: 1;
    pointer-events: none;
}
#videoWidget.expanded .progress-container {
    display: block;
}
.progress-bar {
    width: 0%; height: 100%;
    background: #f0a500;
    transition: width 0.1s linear;
}

/* Кнопка "Записаться" – кликабельна, должна быть поверх всего */
.video-widget-form {
    position: absolute;
    bottom: 16px; left: 50%;
    transform: translateX(-50%);
    display: none;
    z-index: 10; /* высокий z-index */
    pointer-events: auto;
}
#videoWidget.expanded .video-widget-form {
    display: block;
}
.video-widget-form .btn {
    background-color: #f0a500;
    color: #fff;
    box-shadow: #f0a500 0px 14px 21px 0px;
    display: inline-block;
    width: 200px!important;
    padding: 10px;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: box-shadow 0.2s, background-color 0.2s;
    pointer-events: auto;
    cursor: pointer;
}
.video-widget-form .btn:hover {
    background-color: #f0a500;
    box-shadow: 0 5px 10px 0 rgb(172 172 172);
    color: #fff;
}

#videoWidget:not(.expanded):hover {
    box-shadow: 0 0 0 3px #f0a500;
}
#videoWidget.expanded .video-widget-close-btn:hover {
    background: #f0a500;
    color: #fff;
}

/* ---------- НОВЫЕ СТИЛИ (обёртка, внешняя кнопка) ---------- */

#videoWidgetWrapper {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    width: 130px;
    height: 180px;
    transition: width 0.3s ease, height 0.3s ease;
}
#videoWidgetWrapper:has(.expanded) {
    width: 244px;
    height: 444px;
}
#videoWidget {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Внешняя кнопка – крестик (серый) */
#widgetMinimizeBtn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #aaa;
    color: #fff;
    border: 1px solid #ccc;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    padding: 0;
    transition: transform 0.2s, background 0.2s, width 0.3s, height 0.3s,
                top 0.3s, left 0.3s, bottom 0.3s, right 0.3s;
    z-index: 10000;
    display: none;
    font-family: Arial, sans-serif;
    font-variant-emoji: text;
    pointer-events: auto;
}
#widgetMinimizeBtn img {
    display: none !important;
}
#widgetMinimizeBtn:hover {
    background: #888;
    transform: scale(1.05);
}

@media (max-width: 768px) {
    #widgetMinimizeBtn {
        display: block;
    }
    #videoWidget.expanded ~ #widgetMinimizeBtn,
    #videoWidget.minimized ~ #widgetMinimizeBtn {
        display: none;
    }
}

#videoWidgetWrapper.loading #widgetMinimizeBtn {
    display: none !important;
}

#videoWidget.minimized {
    display: none !important;
}

/* Мини-режим: кнопка Play с треугольником */
#videoWidget.minimized ~ #widgetMinimizeBtn {
    position: fixed !important;
    top: auto !important;
    bottom: 20px !important;
    left: 20px !important;
    right: auto !important;
    width: 40px !important;
    height: 40px !important;
    background: #f0a500 !important;
    border: none !important;
    box-shadow: 0 4px 12px #f0a50040;
    transform: none;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 0 !important;
    line-height: 0 !important;
    border-radius: 50% !important;
    pointer-events: auto;
}
#videoWidget.minimized ~ #widgetMinimizeBtn::before {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent #ffffff;
}
#videoWidget.minimized ~ #widgetMinimizeBtn:hover {
    transform: scale(1.05);
}