/* ═══════════════════════════════════════════
   Чат-бот «Александр» — виджет
   ═══════════════════════════════════════════ */

/* Кнопка открытия */
.chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    height: 52px;
    border-radius: 26px;
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(30, 136, 229, 0.4);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 20px 0 16px;
    transition: transform 0.3s, box-shadow 0.3s;
    animation: chatbot-btn-pulse 2.5s infinite;
}
@keyframes chatbot-btn-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(30, 136, 229, 0.4); }
    50%      { box-shadow: 0 4px 20px rgba(30, 136, 229, 0.4), 0 0 0 12px rgba(30, 136, 229, 0.15); }
}
.chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 28px rgba(30, 136, 229, 0.55);
    animation: none;
}
.chatbot-toggle svg {
    width: 24px;
    height: 24px;
    fill: #fff;
    flex-shrink: 0;
}
.chatbot-toggle__label {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
}
.chatbot-toggle__online {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #66bb6a;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.6);
    flex-shrink: 0;
}
.chatbot-toggle__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #e53935;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

/* Окно чата */
.chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}
.chatbot-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Шапка */
.chatbot-header {
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.chatbot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.chatbot-header-info {
    flex: 1;
    min-width: 0;
}
.chatbot-header-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}
.chatbot-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}
.chatbot-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #66bb6a;
    display: inline-block;
}
.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.chatbot-close:hover {
    opacity: 1;
}

/* Область сообщений */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 250px;
    max-height: 320px;
    background: #f5f7fa;
}
.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}
.chatbot-messages::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

/* Сообщение */
.chatbot-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: chatbot-msg-in 0.3s ease;
}
@keyframes chatbot-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chatbot-msg--bot,
.chatbot-msg--admin {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: 1px solid #e8eaed;
    border-bottom-left-radius: 4px;
}
.chatbot-msg--admin {
    border-left: 3px solid #1e88e5;
}
.chatbot-msg--visitor {
    align-self: flex-end;
    background: linear-gradient(135deg, #1e88e5, #1976d2);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Индикатор набора */
.chatbot-typing {
    align-self: flex-start;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: none;
}
.chatbot-typing.active {
    display: flex;
    gap: 4px;
    align-items: center;
}
.chatbot-typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: chatbot-dot 1.4s infinite;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatbot-dot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30%           { opacity: 1;   transform: scale(1);    }
}

/* Поле ввода */
.chatbot-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e8eaed;
    background: #fff;
    flex-shrink: 0;
}
.chatbot-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color 0.2s;
}
.chatbot-input textarea:focus {
    border-color: #1e88e5;
}
.chatbot-input button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.chatbot-input button:hover {
    transform: scale(1.08);
}
.chatbot-input button svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Приветственный пузырь — яркий и заметный */
.chatbot-greeting {
    position: fixed;
    bottom: 90px;
    right: 24px;
    max-width: 300px;
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    color: #fff;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 8px 35px rgba(30, 136, 229, 0.5), 0 0 0 3px #ff9800;
    font-size: 14px;
    line-height: 1.5;
    z-index: 99997;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.4s, transform 0.4s;
    overflow: hidden;
}
.chatbot-greeting.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    animation: chatbot-greeting-pulse 2s ease-in-out 1;
}
@keyframes chatbot-greeting-pulse {
    0%, 100% { box-shadow: 0 8px 35px rgba(30, 136, 229, 0.5), 0 0 0 3px #ff9800; }
    50%      { box-shadow: 0 8px 35px rgba(30, 136, 229, 0.7), 0 0 0 6px #ff9800, 0 0 0 12px rgba(255, 152, 0, 0.2); }
}
.chatbot-greeting__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 8px;
}
.chatbot-greeting__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}
.chatbot-greeting__name {
    font-weight: 600;
    font-size: 14px;
}
.chatbot-greeting__status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}
.chatbot-greeting__status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #66bb6a;
}
.chatbot-greeting__text {
    padding: 0 14px 12px;
    font-size: 13px;
    line-height: 1.5;
}
.chatbot-greeting::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 28px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #1565c0;
}
.chatbot-greeting-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: rgba(255,255,255,0.7);
    line-height: 1;
    transition: color 0.2s;
}
.chatbot-greeting-close:hover {
    color: #fff;
}

/* Кликабельные ссылки в сообщениях */
.chatbot-msg a,
.chatbot-msg a:visited {
    text-decoration: underline !important;
    font-weight: 600 !important;
    cursor: pointer !important;
}
.chatbot-msg--visitor a,
.chatbot-msg--visitor a:visited {
    color: #fff !important;
}
.chatbot-msg--bot a,
.chatbot-msg--bot a:visited,
.chatbot-msg--admin a,
.chatbot-msg--admin a:visited {
    color: #1565c0 !important;
}

/* Адаптив */
@media (max-width: 480px) {
    .chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
        z-index: 999999;
    }
    .chatbot-window.open {
        display: flex;
        flex-direction: column;
    }
    .chatbot-messages {
        flex: 1;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .chatbot-input {
        padding: 8px 10px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        flex-shrink: 0;
    }
    .chatbot-input textarea {
        font-size: 16px;
        padding: 10px 14px;
    }
    .chatbot-header {
        padding: 12px 14px;
        padding-top: max(12px, env(safe-area-inset-top));
        flex-shrink: 0;
    }
    .chatbot-toggle {
        bottom: 12px;
        right: 12px;
        height: 46px;
        padding: 0 16px 0 12px;
        gap: 6px;
    }
    .chatbot-toggle svg {
        width: 22px;
        height: 22px;
    }
    .chatbot-toggle__label {
        font-size: 13px;
    }
    .chatbot-greeting {
        right: 8px;
        left: 8px;
        max-width: none;
        bottom: 70px;
        font-size: 13px;
    }
    .chatbot-greeting__header {
        padding: 10px 12px 6px;
    }
    .chatbot-greeting__text {
        padding: 0 12px 10px;
        font-size: 12.5px;
    }
    .chatbot-greeting__avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

/* reCAPTCHA badge — скрыт, атрибуция в тексте страницы */
.grecaptcha-badge {
    visibility: hidden !important;
}
