/* ── AI Ассистент ─────────────────────────────────────────────────────────── */

/* Плавающая кнопка */
.ai-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 9000;
    padding: 0;
}
.ai-fab:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(0,123,255,0.55); }
.ai-fab.active { background: linear-gradient(135deg, #0056b3, #003d82); }
.ai-fab-icon { line-height: 1; }

/* Панель */
.ai-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 360px;
    max-height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    z-index: 8999;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    overflow: hidden;
}
.ai-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Шапка */
.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff;
    border-radius: 12px 12px 0 0;
}
.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
}
.ai-panel-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.15s;
}
.ai-panel-close:hover { background: rgba(255,255,255,0.35); }

/* Сообщения */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-thumb { background: #dee2e6; border-radius: 4px; }

/* Пузыри */
.ai-msg { display: flex; }
.ai-msg-user  { justify-content: flex-end; }
.ai-msg-assistant { justify-content: flex-start; flex-direction: column; gap: 4px; }

.ai-bubble {
    max-width: 88%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}
.ai-msg-user .ai-bubble {
    background: #007bff;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg-assistant .ai-bubble {
    background: #fff;
    color: #33475b;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

/* Индикатор набора */
.ai-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
}
.ai-typing span {
    width: 7px;
    height: 7px;
    background: #007bff;
    border-radius: 50%;
    animation: ai-bounce 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* Кнопки действий */
.ai-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    padding-left: 2px;
}
.ai-action-btn {
    background: #e8f4fd;
    border: 1px solid #b8daff;
    color: #0056b3;
    border-radius: 8px;
    padding: 7px 11px;
    font-size: 12.5px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
    font-weight: 500;
    line-height: 1.4;
}
.ai-action-btn:hover:not(:disabled) { background: #cce5ff; border-color: #80bdff; }
.ai-action-btn:disabled { opacity: 0.7; cursor: default; }
.ai-action-btn.applied { background: #d4edda; border-color: #c3e6cb; color: #155724; }

/* Поле ввода */
.ai-panel-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e9ecef;
    background: #fff;
}
.ai-textarea {
    flex: 1;
    resize: none;
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13.5px;
    font-family: inherit;
    color: #33475b;
    line-height: 1.45;
    outline: none;
    transition: border-color 0.15s;
    overflow-y: auto;
    max-height: 120px;
}
.ai-textarea:focus { border-color: #007bff; }
.ai-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.15s, transform 0.1s;
}
.ai-send:hover:not(:disabled) { background: #0069d9; transform: scale(1.08); }
.ai-send:disabled { background: #adb5bd; cursor: default; }

/* Кнопка очистки */
.ai-clear-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
}
.ai-clear-btn:hover { background: rgba(255,255,255,0.35); }

/* Toast-уведомление */
.ai-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #28a745;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9999;
    max-width: 320px;
    text-align: center;
}
.ai-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    .ai-panel {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: 84px;
        max-height: 70vh;
    }
    .ai-fab { bottom: 16px; right: 16px; }
}
