/* =============================================
   AI-КОНСУЛЬТАНТ (ВИДЖЕТ ЧАТА)
   ============================================= */

/* --- Плавающая кнопка --- */
.chat-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(200, 149, 106, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 1000;
    transition: all 0.3s ease;
    animation: chatPulse 2.5s infinite;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(200, 149, 106, 0.6);
}

.chat-toggle-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #E74C3C;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 50px;
    letter-spacing: 0.5px;
}

@keyframes chatPulse {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(200, 149, 106, 0.45);
    }
    50% {
        box-shadow: 0 8px 32px rgba(200, 149, 106, 0.45), 0 0 0 12px rgba(200, 149, 106, 0.1);
    }
}

/* --- Окно чата --- */
.chat-window {
    position: fixed;
    bottom: 7rem;
    right: 2rem;
    width: 400px;
    max-width: calc(100vw - 2rem);
    height: 600px;
    max-height: calc(100vh - 10rem);
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 64px rgba(44, 44, 44, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* --- Заголовок --- */
.chat-header {
    background: var(--gradient-dark);
    color: white;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
}

.chat-header-info h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: white;
}

.chat-header-info p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chat-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ECC71;
    display: inline-block;
    animation: onlinePulse 2s infinite;
}

@keyframes onlinePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.chat-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* --- Сообщения --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--light);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
}

.chat-message {
    display: flex;
    max-width: 85%;
    animation: messageFadeIn 0.3s ease;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-user {
    align-self: flex-end;
}

.chat-message-assistant {
    align-self: flex-start;
}

.chat-bubble {
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-message-user .chat-bubble {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-assistant .chat-bubble {
    background: white;
    color: var(--dark);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(44, 44, 44, 0.06);
}

.chat-bubble strong {
    font-weight: 600;
}

/* --- Индикатор печати --- */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 1rem 1.25rem;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: typingBounce 1.4s infinite;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* --- Поле ввода --- */
.chat-input-area {
    padding: 1rem 1.25rem;
    background: white;
    border-top: 1px solid var(--light-gray);
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1.5px solid var(--light-gray);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    max-height: 120px;
    line-height: 1.4;
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(200, 149, 106, 0.1);
}

.chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send:hover:not(:disabled) {
    transform: scale(1.05);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Адаптивность --- */
@media (max-width: 576px) {
    .chat-toggle {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }

    .chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-message {
        max-width: 90%;
    }
}