/* Расширенное состояние */
.chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    will-change: transform, opacity;
}

body.expanded .chat-window {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Glass окно с сообщениями */
.chat-messages {
    position: fixed;
    bottom: 74px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 1000px;
    height: calc(100vh - 164px);
    
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    
    border-radius: 24px 24px 0 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: none;
    
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.08);
    
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    box-sizing: border-box;
    
    will-change: scroll-position;
    contain: layout style paint;
}

/* Строка ввода */
body.expanded .chatbot-bar {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 1000px;
    
    border-radius: 0 0 24px 24px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    
    padding: 16px;
    gap: 10px;
    box-sizing: border-box;
    
    contain: layout style;
}

/* Лента сообщений */
#chatMessages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Сообщения */
.chat-message {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 70%;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.5;
    will-change: transform, opacity;
}

.chat-message.user {
    background: rgba(232, 240, 254, 0.95);
    color: #1a73e8;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-message.bot {
    background: rgba(241, 243, 244, 0.95);
    color: #202124;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    opacity: 0;
    transform: translateY(5px);
    animation: fadeIn 0.35s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Иконки */
body.expanded .chatbot-edit-icon img,
body.expanded .chatbot-voice img,
body.expanded .chatbot-back img {
    width: 20px;
    height: 20px;
}

body.expanded .chatbot-send {
    position: static;
    transform: none;
    order: 3;
    margin: 0;
    transition: transform 0.2s ease;
}

body.expanded .chatbot-send:hover {
    transform: scale(1.02);
}

body.expanded .gpt-icon {
    width: 48px;
    height: 48px;
}

body.expanded .chatbot-input {
    font-size: 16px;
    flex: 1.3;
}

body.expanded .chatbot-back {
    display: flex;
}

/* Лоадер */
.loading-dots {
    display: inline-block;
    margin-left: 6px;
}

.loading-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background: #888;
    border-radius: 50%;
    animation: blink 1.2s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

/* Скроллбар */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.chat-container {
    position: relative;
}