/* chat.css */
#ai-chat {
    background: var(--bg-dashboard) !important;
}

/* Чат экран */
.chat-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 388px;
    background: var(--gradient-primary);
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    z-index: 1000;
    height: 60px;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

/* Специальный стиль для кнопки назад в чате */
.chat-header .back-btn {
    position: static;
    margin-right: 16px;
}

.chat-title {
    display: flex;
    align-items: center;
    margin-left: 16px;
}

.trainer-avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 12px;
    color: var(--primary);
}

.trainer-name {
    font-weight: 600;
    font-size: 16px;
    color: white;
}

.trainer-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
}

.chat-container {
    padding-top: 12px;
    padding-bottom: 120px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.chat-messages::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.message {
    display: flex;
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease-out;
}

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    display: none;
}

.message-content {
    max-width: 80%;
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.user-message .message-content {
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
}

.ai-message .message-content {
    background: var(--white);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.message-content p {
    margin: 0;
    font-size: 13px !important;
    line-height: 1.5;
}

/* Настройка размеров для разных элементов */
.message-content h1 {
    font-size: 18px !important;
    font-weight: 600;
    margin: 8px 0 4px 0;
}

.message-content h2 {
    font-size: 16px !important;
    font-weight: 600;
    margin: 6px 0 3px 0;
}

.message-content h3 {
    font-size: 15px !important;
    font-weight: 600;
    margin: 4px 0 2px 0;
}

.message-content strong {
    font-size: 13px !important;
    font-weight: 600;
}

.message-content li {
    font-size: 13px !important;
    margin: 2px 0;
}

/* Дополнительные правила для переопределения системных стилей */
.message-content span,
.message-content div {
    font-size: 13px !important;
    -webkit-text-size-adjust: none !important;
    text-size-adjust: none !important;
}

.message-content p + p {
    margin-top: 8px;
}

/* Markdown в AI-сообщениях */
.ai-message .message-content ul,
.ai-message .message-content ol {
    margin: 4px 0;
    padding-left: 20px;
}

.ai-message .message-content p:first-child,
.ai-message .message-content h1:first-child,
.ai-message .message-content h2:first-child,
.ai-message .message-content h3:first-child {
    margin-top: 0;
}

.ai-message .message-content p:last-child {
    margin-bottom: 0;
}

.ai-message .message-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 13px;
}

.ai-message .message-content pre {
    background: rgba(0, 0, 0, 0.06);
    padding: 8px 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 6px 0;
}

.ai-message .message-content pre code {
    background: none;
    padding: 0;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    align-self: flex-end;
}

/* Быстрые действия */
.chat-quick-actions {
    position: fixed;
    bottom: 115px; /* Над полем ввода */
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 388px;
    padding: 16px 20px;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto; /* Прокрутка если кнопки не помещаются */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    background: transparent;
    z-index: 999;
}

/* Скрываем скроллбар в WebKit браузерах (Chrome, Safari) */
.chat-quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-action {
    background: var(--primary);
    border: 1px solid var(--primary);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.quick-action svg {
    color: inherit;
}

/* Поле ввода */
.chat-input-container {
    position: fixed;
    bottom: 56px; /* Вплотную к навбару */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 8px 16px;
    z-index: 1000;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-small);
    padding: 4px 8px;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
}

#chatInput {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}

/* Голосовой ввод */
.voice-btn {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    flex-shrink: 0;
    padding: 0;
}

.voice-btn:active {
    transform: scale(0.9);
}

.voice-btn.recording {
    color: #e53e3e;
    animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.send-btn {
    width: 32px;
    height: 32px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.send-btn:disabled {
    background: var(--muted);
    cursor: not-allowed;
}

.send-icon {
    color: white;
    font-size: 16px;
}

/* Индикатор печатания */
.typing-indicator {
    display: flex;
    align-items: center;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.typing-dots {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background: var(--text-secondary);
    border-radius: 50%;
    margin: 0 1px;
    animation: typingDot 1.4s infinite;
}

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

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

/* Typing indicator в чате (три точки) */
.chat-typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 20px !important;
    min-height: auto;
}
.chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary, #8c8279);
    opacity: 0.4;
    animation: chatTypingBounce 1.4s ease-in-out infinite;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

