/* ============================
   Чат-виджет AI-ассистента
   ============================ */

.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #d4af37;
    border: none;
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.35);
    cursor: pointer;
    z-index: 1050;
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(212, 175, 55, 0.45);
}
.chat-toggle-btn:active {
    transform: scale(0.95);
}

.chat-widget {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    z-index: 1051;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.25s ease;
}
.chat-widget.chat-hidden {
    display: none;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    background: #d4af37;
    color: #fff;
    flex-shrink: 0;
}
.chat-header-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-header-actions {
    display: flex;
    gap: 4px;
}
.chat-header-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}
.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f7f4;
}

.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: msgIn 0.2s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
    align-self: flex-end;
    background: #d4af37;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-message.assistant {
    align-self: flex-start;
    background: #fff;
    color: #262626;
    border: 1px solid #e6e4df;
    border-bottom-left-radius: 4px;
}

.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: #fff;
    border: 1px solid #e6e4df;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.chat-typing span {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e6e4df;
    background: #fff;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    border: 1px solid #e6e4df;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.chat-input:focus {
    border-color: #d4af37;
}
.chat-send-btn {
    background: #d4af37;
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.chat-send-btn:hover { background: #c4a030; }
.chat-send-btn:disabled { background: #ccc; cursor: not-allowed; }

.chat-apply-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #e6e4df;
    background: #f0ede5;
    flex-shrink: 0;
}
.chat-apply-bar.chat-visible {
    display: flex;
}
.chat-apply-text {
    flex: 1;
    font-size: 13px;
    color: #6b6b6b;
}
.chat-apply-btn {
    background: #28a745;
    border: none;
    color: #fff;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.chat-apply-btn:hover { background: #218838; }

@media (max-width: 480px) {
    .chat-widget {
        right: 8px;
        bottom: 84px;
        width: calc(100% - 16px);
        height: calc(100vh - 100px);
        border-radius: 12px;
    }
    .chat-toggle-btn {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
}
