/* ==========================================================================
   1. ПЛАВАЮЩАЯ КНОПКА ЧАТА (ПИРАТ)
   ========================================================================== */
.chat-button {
    position: fixed;
    bottom: 30px;
    left: 30px;
    background-color: transparent;
    border: none;
    z-index: 999;
    display: flex;
    align-items: center;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease, transform 0.3s ease;
    animation: pulseGhost 3s infinite ease-in-out;
}
.chat-button:hover {
    opacity: 1;
    animation: none;
    transform: scale(1.05);
}
.chat-button:hover .chat-button__tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(100%) translateY(-50%) scale(1);
}
@keyframes pulseGhost {
    0% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
    100% { opacity: 0.5; transform: scale(1); }
}
.chat-button__avatar-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 4px 15px rgba(72, 123, 199, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 3px solid #CDD8EA;
}
.chat-button__avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.chat-button__badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 35px;
    height: 35px;
    background-color: #487BC7;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 3px solid white;
}
.chat-button__badge svg {
    width: 18px;
    height: 18px;
}
.chat-button__tooltip {
    position: absolute;
    top: 50%;
    right: -15px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%) translateY(-50%) scale(0.9);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    background-color: #fff;
    color: #1A365D;
    padding: 12px 20px;
    border-radius: 20px;
    border-bottom-left-radius: 0;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #CDD8EA;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
}
.chat-button__tooltip::before {
    content: "";
    position: absolute;
    bottom: -1px;
    left: -10px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 15px 15px;
    border-color: transparent transparent #fff transparent;
}

/* ==========================================================================
   2. ОКНО ЧАТА (ОКНО-ОТЛАДКА И АДАПТИВ)
   ========================================================================== */
.chat-overlay {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background-color: #fff;
    border: none;
    padding: 0;
    margin: 0;
    display: none;
    flex-direction: column;
    border-radius: 0;
}
.chat-overlay[open] {
    display: flex;
}
@media (min-width: 1000px) {
    .chat-overlay {
        inset: 0;
        margin: auto;
        width: 450px; /* Сузил под формат аккуратного виджета, как на макете */
        height: 700px;
        max-width: 85vw !important;
        max-height: 85vh !important;
        box-shadow: 0px 10px 40px rgba(72, 123, 199, 0.5);
    }
}

/* --- ШАПКА ЧАТА --- */
.chat-overlay__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #CDD8EA;
    border-bottom: 1px solid #b8c7df;
}
.chat-overlay__header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}
.chat-overlay__header-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}
.chat-overlay__header-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.chat-overlay__header-name {
    font-weight: 700;
    font-size: 1.3rem;
    color: #1A365D;
}
.chat-overlay__header-role {
    font-weight: 500;
    font-size: 0.95rem;
    color: #333;
}
.chat-overlay__close-form {
    display: flex;
    align-items: center;
}
.chat-overlay__close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}
.chat-overlay__close-btn:hover {
    transform: scale(1.1);
}

/* --- ТЕЛО ЧАТА --- */
.chat-overlay__body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #FAFAFA;
}
.chat-overlay__message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 1rem;
    line-height: 140%;
    word-wrap: break-word;
}
.chat-overlay__message--ai {
    align-self: flex-start;
    background-color: #FFFFFF;
    color: #1A365D;
    border: 1px solid #487BC7;
    border-bottom-left-radius: 4px;
    white-space: pre-wrap;
}
.chat-overlay__message--user {
    align-self: flex-end;
    background-color: #487BC7;
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
}

/* --- ПОДВАЛ ЧАТА --- */
.chat-overlay__footer {
    display: flex;
    padding: 15px 20px;
    gap: 15px;
    background-color: #FFFFFF;
    border-top: 1px solid #E2EAF5;
    align-items: center;
}
.chat-overlay__input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid #CDD8EA;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}
.chat-overlay__input:focus {
    border-color: #487BC7;
}
.chat-overlay__send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #487BC7;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s, transform 0.2s;
}
.chat-overlay__send-btn:hover {
    background-color: #3661A3;
    transform: scale(1.05);
}
.chat-overlay__send-btn svg {
    width: 24px;
    height: 24px;
}