:root {
    --max-gradient: linear-gradient(90deg, #4185F6 0%, #4930E0 48%, #964BDA 98%);
    --max-shadow: 0 10px 25px rgba(65, 133, 246, 0.3);
    --max-radius: 16px;
}
#max-consultant-widget { position: fixed; bottom: 25px; right: 25px; z-index: 99999; }
#max-consultant-toggle {
    width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
    box-shadow: var(--max-shadow); display: flex; align-items: center; justify-content: center;
    transition: transform 0.3s ease; position: relative;
}
#max-consultant-toggle:hover { transform: scale(1.08); }
.max-pulse {
    position: absolute; width: 100%; height: 100%; border-radius: 50%;
    animation: max-pulse 2s infinite; z-index: -1;
}
@keyframes max-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}
.max-icon { width: 40px; height: 40px; max-width: 140%; }


/* Окно виджета */
.max-consultant-popup {
    position: fixed; bottom: 100px; right: 25px; width: 360px; max-width: calc(100vw - 50px);
    background: white; border-radius: var(--max-radius); box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    transform: translateY(20px); opacity: 0; visibility: hidden; transition: all 0.3s ease; overflow: hidden;
    z-index: 100000;
}
.max-consultant-popup.active { transform: translateY(0); opacity: 1; visibility: visible; }

/* Шапка */
.max-header {
    color: white; padding: 20px; display: flex; align-items: center; gap: 15px; position: relative;
}
.max-avatar {
    width: 50px; height: 50px; background: rgba(255,255,255,0.2); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.max-avatar img { width: 100%; height: 100%; object-fit: cover; }
.max-info h4 { margin: 0 0 5px; font-size: 18px; font-weight: 600; color: #fff; }
.max-status { margin: 0; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.max-status-dot { width: 8px; height: 8px; background: #4cd964; border-radius: 50%; animation: blink 1.5s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* Кнопка закрытия — явные размеры */
.max-close {
    position: absolute !important;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50% !important;
    background: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    padding: 0 !important;
    margin: 0;
    flex-shrink: 0;
}
.max-close svg { width: 16px; height: 16px; display: block; }
.max-close:hover { background: rgba(255,255,255,0.3); transform: rotate(90deg); }

/* Тело сообщений */
.max-body { padding: 20px; max-height: 300px; overflow-y: auto; background: #f8f9fa; }
.max-messages { display: flex; flex-direction: column; gap: 12px; }
.max-message {
    background: white; padding: 12px 16px; border-radius: 18px 18px 18px 4px;
    max-width: 85%; box-shadow: 0 2px 8px rgba(0,0,0,0.05); font-size: 14px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* Футер */
.max-footer { padding: 20px; text-align: center; border-top: 1px solid #eee; background: white; }
.max-hint { font-size: 13px; color: #666; margin-bottom: 15px; }
.max-action-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    color: white; text-decoration: none; padding: 12px 20px; border-radius: 50px;
    font-weight: 600; font-size: 16px; width: 100%; transition: all 0.3s ease;
}
.max-action-button:hover { transform: translateY(-2px); color: white; text-decoration: none; }
.max-brand-icon { width: 20px; height: 20px; }
.max-note { font-size: 12px; color: #888; margin-top: 12px; }

/* Подложка — ниже виджета */
.max-consultant-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); z-index: 99998; opacity: 0; visibility: hidden;
    transition: all 0.3s ease;
}
.max-consultant-overlay.active { opacity: 1; visibility: visible; }

/* Адаптивность */
@media (max-width: 768px) {
    #max-consultant-toggle { width: 56px; height: 56px; bottom: 20px; right: 20px; }
    .max-icon { width: 36px !important; height: 36px !important; }
    .max-consultant-popup { bottom: 90px; right: 20px; width: calc(100vw - 40px); }
}
@media (max-width: 480px) {
    #max-consultant-toggle { width: 50px; height: 50px; bottom: 15px; right: 15px; }
    .max-icon { width: 36px !important; height: 36px !important; max-width: 200%;   }
    .max-consultant-popup { bottom: 80px; right: 15px; width: calc(100vw - 30px); }
    .max-header { padding: 15px; }
    .max-close { width: 28px; height: 28px; top: 12px; right: 12px; }
    .max-close svg { width: 14px; height: 14px; }
}
/* Базовый стиль точки статуса */
.max-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    transition: background-color 0.3s ease;
}

/* Зелёный (онлайн) */
.max-status-dot.blink-green {
    background-color: #4cd964 !important;
    animation: blink 1.5s infinite;
}

/* Красный (офлайн) */
.max-status-dot.blink-red {
    background-color: #ff3b30 !important;
    animation: blink-red 1.5s infinite;
}

/* Анимации */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes blink-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}