/* 1. КНОПКА-МАЯЧОК (BEACON) */
a.modal-beacon {
    position: fixed;
    display: block;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    z-index: 998;
    border-radius: 50%;
    box-shadow: 1px 1px 3px 0 rgba(0,0,0,0.4);
    background: #d0021b url('data:image/svg+xml;utf-8,%3Csvg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z" fill="white"/%3E%3C/svg%3E') no-repeat center;
    background-size: 24px;
    border: none;
    text-decoration: none;
}

a.modal-beacon:hover { border: none; text-decoration: none; opacity: 0.9; }

@media (max-width: 640px) {
    a.modal-beacon { bottom: 15px; right: 15px; }
}

/* 2. ОСНОВНОЙ КОНТЕЙНЕР МОДАЛКИ */
.modal-box {
    width: 380px;
    background-color: #fff;
    position: fixed;
    bottom: 90px;
    right: 30px;
    z-index: 9999; /* Максимальный приоритет */
    border-radius: 2px;
    box-shadow: 2px 2px 15px 0 rgba(0,0,0,0.3);
    
    /* Скрыто по умолчанию */
    display: none !important; 
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    
    max-height: 80vh;
    overflow-y: auto;
}

/* СОСТОЯНИЕ: ВИДИМО */
.modal-box.modal-visible {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

/* АДАПТИВ ДЛЯ МОБИЛОК */
@media (max-width: 639px) {
    .modal-box {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        border-radius: 0;
        max-height: 100% !important;
    }
}

/* 3. ВНУТРЕННИЕ ЭЛЕМЕНТЫ */
.modal-box .modal-head {
    width: 100%;
    padding: 15px;
    border-bottom: 1px solid rgba(155,155,155,0.3);
    overflow: auto;
}

.modal-box .modal-head .modal-close {
    display: block;
    float: right;
    width: 16px;
    height: 16px;
    cursor: pointer;
    background: url('data:image/svg+xml;utf-8,%3Csvg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M10 8.586L2.929 1.515 1.515 2.929 8.586 10l-7.071 7.071 1.414 1.414L10 11.414l7.071 7.071 1.414-1.414L11.414 10l7.071-7.071-1.414-1.414L10 8.586z" fill="%23999"/%3E%3C/svg%3E') no-repeat center;
    background-size: contain;
}

.modal-box .modal-body {
    width: 100%;
    padding: 20px 25px;
}

/* ФОРМЫ */
.modal-box .modal-body form { margin-top: 20px; }
.modal-box .modal-body form input[type="text"],
.modal-box .modal-body form textarea {
    width: 100%;
    padding: 10px 15px;
    display: block;
    border: 1px solid rgba(155,155,155,0.5);
    background: transparent;
    margin-bottom: 10px;
    outline: none;
    border-radius: 0;
    font-size: 14px;
}

.modal-box .modal-body form textarea { height: 100px; resize: none; }

/* 4. КОРЗИНА ВНУТРИ МОДАЛКИ */
.modal-box .modal-body .modal-message.message-hidden { display: none; }
.modal-box .modal-body .modal-cart { display: none; }
.modal-box .modal-body .modal-cart.cart-visible { display: block; }

.modal-item-table { width: 100%; border-collapse: collapse; }
.modal-item-table tr:not(.h) td { padding: 5px 0; border-bottom: 1px solid #eee; }
.modal-item-table img { max-width: 40px; height: auto; }

/* СООБЩЕНИЯ ОБ УСПЕХЕ */
.modal-box .modal-msg {
    display: none;
    padding: 40px;
    text-align: center;
}

.modal-box.modal-sent .modal-body { display: none; }
.modal-box.modal-sent .modal-msg { display: block; }

/* БЛОКИРОВКА СКРОЛЛА */
.noscroll {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
}