/* ========================================
   Assistant — Чат-виджет системного помощника
   ======================================== */

/* ---- Кнопка-триггер (GIF-кот) ---- */
.assistant-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9999;
    cursor: pointer;
    transition: transform 0.3s ease;
    line-height: 0;
}

.assistant-btn:hover {
    transform: scale(1.08);
}

.assistant-btn:active {
    transform: scale(0.95);
}

.assistant-btn-hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* ---- Виджет чата ---- */
.assistant-widget {
    position: fixed;
    bottom: 90px;
    left: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    transform: scale(0);
    transform-origin: bottom left;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.assistant-widget.assistant-open {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ---- Заголовок ---- */
.assistant-header {
    padding: 16px 20px;
    background: #1a56db;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.assistant-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.assistant-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistant-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
}

.assistant-status {
    font-size: 12px;
    opacity: 0.8;
    line-height: 1.3;
}

.assistant-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.assistant-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* ---- Тело чата ---- */
.assistant-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

.assistant-body::-webkit-scrollbar {
    width: 6px;
}

.assistant-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.assistant-body::-webkit-scrollbar-track {
    background: transparent;
}

/* ---- Сообщения ---- */
.assistant-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assistant-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgFadeIn 0.3s ease;
}

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

.assistant-message-user {
    background: #1a56db;
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.assistant-message-bot {
    background: #ffffff;
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.assistant-bot-text {
    line-height: 1.6;
}

.assistant-bot-text strong {
    color: #1a56db;
}

.assistant-bot-text br {
    content: '';
    display: block;
    margin: 4px 0;
}

/* ---- Источник ---- */
.assistant-source {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
    font-size: 12px;
    color: #6b7280;
}

/* ---- Похожие темы ---- */
.assistant-related {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.assistant-related-title {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
}

.assistant-related-btn {
    display: block;
    width: 100%;
    background: #f0f4ff;
    border: 1px solid #dbe6ff;
    color: #1a56db;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 4px;
    text-align: left;
    transition: all 0.2s;
}

.assistant-related-btn:hover {
    background: #dbe6ff;
    border-color: #1a56db;
}

/* ---- Предлагаемые вопросы ---- */
.assistant-suggestions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

/* ---- Индикатор печатания ---- */
.assistant-typing .assistant-bot-text {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.6;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ---- Футер ---- */
.assistant-footer {
    padding: 12px 16px 10px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
}

.assistant-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.assistant-input-wrap:focus-within {
    border-color: #1a56db;
    background: #ffffff;
}

.assistant-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    outline: none;
    color: #1f2937;
}

.assistant-input::placeholder {
    color: #9ca3af;
}

.assistant-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a56db;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.assistant-send:hover {
    background: #1549c0;
    transform: scale(1.05);
}

.assistant-send:active {
    transform: scale(0.95);
}

.assistant-disclaimer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 6px;
}

/* ---- Адаптивность ---- */
@media (max-width: 480px) {
    .assistant-widget {
        bottom: 0;
        left: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .assistant-btn {
        bottom: 16px;
        left: 16px;
        width: 50px;
        height: 50px;
    }
}
