/* ============================================================
   MFS Chat Assistant — стили чат-виджета для клиентов
   ============================================================ */

/* Плавающая кнопка-робот */
#mfs-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 1000;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 12px 18px 12px 14px;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(52,152,219,0.45);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}
#mfs-chat-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 22px rgba(52,152,219,0.55);
}
#mfs-chat-btn.open {
    background: linear-gradient(135deg, #1a252f, #2471a3);
}
.mfs-chat-btn-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* Панель чата */
#mfs-chat-panel {
    position: fixed;
    bottom: 84px;
    right: 20px;
    width: 340px;
    max-height: 500px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 36px rgba(0,0,0,0.18);
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    animation: mfsChatIn 0.22s ease;
}
#mfs-chat-panel.visible {
    display: flex;
}

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

/* Заголовок */
#mfs-chat-header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
}
#mfs-chat-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
#mfs-chat-close:hover { color: #fff; }

/* Сообщения */
#mfs-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f7fa;
    min-height: 180px;
    max-height: 320px;
}

.mfs-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}
.mfs-msg-user {
    align-self: flex-end;
    align-items: flex-end;
}
.mfs-msg-bot {
    align-self: flex-start;
    align-items: flex-start;
}

.mfs-bubble {
    padding: 9px 13px;
    border-radius: 14px 14px 14px 2px;
    font-size: 13.5px;
    line-height: 1.55;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    white-space: pre-wrap;
    word-break: break-word;
    background: #fff;
    color: #2c3e50;
}
.mfs-msg-user .mfs-bubble {
    background: #3498db;
    color: #fff;
    border-radius: 14px 14px 2px 14px;
}
.mfs-bubble.escalate {
    background: #fef9f0;
    border-left: 3px solid #e67e22;
    color: #7d5b2a;
}

.mfs-msg-time {
    font-size: 10px;
    color: #b0b8c5;
    margin-top: 3px;
    padding: 0 3px;
}

/* Анимация "печатает" */
.mfs-typing {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    align-items: center;
    background: #fff;
    border-radius: 14px 14px 14px 2px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.mfs-typing span {
    width: 7px;
    height: 7px;
    background: #3498db;
    border-radius: 50%;
    display: inline-block;
    animation: mfsDot 1.2s infinite;
}
.mfs-typing span:nth-child(2) { animation-delay: 0.2s; }
.mfs-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mfsDot {
    0%,80%,100% { transform: scale(0.65); opacity: 0.4; }
    40%          { transform: scale(1.1); opacity: 1; }
}

/* Поле ввода */
#mfs-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #edf0f4;
    align-items: flex-end;
}
#mfs-chat-input {
    flex: 1;
    border: 1.5px solid #dde3ea;
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 13px;
    resize: none;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #f8fafc;
}
#mfs-chat-input:focus {
    border-color: #3498db;
    background: #fff;
}
#mfs-chat-send {
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 10px;
    width: 38px;
    height: 38px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
#mfs-chat-send:hover:not(:disabled) { background: #2980b9; }
#mfs-chat-send:disabled { background: #bdc3c7; cursor: not-allowed; }

#mfs-chat-footer {
    text-align: center;
    font-size: 10px;
    color: #c0c8d2;
    padding: 4px 0 6px;
    background: #fff;
}

/* Адаптив для маленьких экранов */
@media (max-width: 400px) {
    #mfs-chat-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 76px;
    }
    #mfs-chat-btn {
        right: 12px;
        bottom: 16px;
    }
}
