
/* AI Assistant Styles */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #7209b7;
    --error-color: #ff4757;
    --success-color: #2ed573;
    --warning-color: #ffa502;
    --gray-light: #f8fafc;
    --gray-medium: #64748b;
    --gray-border: #e2e8f0;
}

.ai-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Промо-текст рядом с кнопкой */
.ai-promo-text {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    color: var(--primary-color);
    padding: 12px 18px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(67, 97, 238, 0.15);
    border: 2px solid rgba(67, 97, 238, 0.1);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    animation: promoGlow 6s infinite ease-in-out;
    transition: all 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.ai-promo-text::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(67, 97, 238, 0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes promoGlow {
    0%, 100% { 
        transform: translateY(0);
        box-shadow: 0 4px 20px rgba(67, 97, 238, 0.15);
        border-color: rgba(67, 97, 238, 0.1);
    }
    50% { 
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(67, 97, 238, 0.25);
        border-color: rgba(67, 97, 238, 0.2);
    }
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes fadeOut {
    0% { 
        opacity: 1;
        transform: translateY(0);
    }
    100% { 
        opacity: 0;
        transform: translateY(-10px);
    }
}

.ai-promo-text:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(67, 97, 238, 0.3);
    cursor: pointer;
}

/* Кнопка повтора для сообщений об ошибке */
.ai-retry-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.2);
}

.ai-retry-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
}

.ai-retry-btn i {
    font-size: 10px;
}

/* Стили для сообщений об ошибке */
.ai-error-message .ai-message-content {
    background: linear-gradient(135deg, #fff5f5, #fef2f2);
    border-left: 4px solid var(--error-color);
}

.ai-error-message .ai-message-content p {
    color: #dc2626;
    font-weight: 500;
}

.ai-toggle-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(67, 97, 238, 0.3), 0 0 0 0 rgba(67, 97, 238, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    animation: pulseGlow 4s infinite;
}

@keyframes pulseGlow {
    0% { 
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(67, 97, 238, 0.3), 0 0 0 0 rgba(67, 97, 238, 0.4);
    }
    25% { 
        transform: scale(1.05);
        box-shadow: 0 6px 25px rgba(67, 97, 238, 0.4), 0 0 0 10px rgba(67, 97, 238, 0.1);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 8px 30px rgba(67, 97, 238, 0.5), 0 0 0 20px rgba(67, 97, 238, 0.05);
    }
    75% { 
        transform: scale(1.05);
        box-shadow: 0 6px 25px rgba(67, 97, 238, 0.4), 0 0 0 10px rgba(67, 97, 238, 0.1);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(67, 97, 238, 0.3), 0 0 0 0 rgba(67, 97, 238, 0.4);
    }
}

.ai-toggle-btn:hover {
    transform: scale(1.15) !important;
    box-shadow: 0 8px 35px rgba(67, 97, 238, 0.6), 0 0 0 15px rgba(67, 97, 238, 0.15);
    animation-play-state: paused;
}

.ai-toggle-btn:active {
    transform: scale(1.05) !important;
    animation-play-state: paused;
}

.ai-notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: var(--error-color);
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Интенсивная анимация для привлечения внимания */
.ai-toggle-btn.attention {
    animation: attentionPulse 1.5s infinite, pulseGlow 4s infinite;
}

@keyframes attentionPulse {
    0% { 
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(67, 97, 238, 0.3), 0 0 0 0 rgba(255, 71, 87, 0.4);
    }
    50% { 
        transform: scale(1.2);
        box-shadow: 0 8px 35px rgba(67, 97, 238, 0.6), 0 0 0 20px rgba(255, 71, 87, 0.2);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(67, 97, 238, 0.3), 0 0 0 0 rgba(255, 71, 87, 0.4);
    }
}

.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(67, 97, 238, 0.1);
}

.ai-chat-window.open {
    display: flex;
    animation: slideInUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-window.auto-opening {
    display: flex;
    animation: autoOpenChat 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInUp {
    from {
        transform: translateY(30px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes autoOpenChat {
    0% {
        transform: translateY(50px) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translateY(-10px) scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.ai-chat-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    min-height: 70px;
}

.ai-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.ai-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.ai-greeting {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    color: white;
}

.ai-title {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.95);
}

.ai-status-container {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 2px;
}

.ai-status-main {
    font-size: 12px;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.2;
}

.ai-status-history {
    font-size: 11px;
    opacity: 0.8;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.2;
}

.ai-header-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ai-control-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.ai-control-btn:active {
    transform: scale(0.95);
}

.ai-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--gray-light);
    scroll-behavior: smooth;
}

.ai-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-bot-message {
    align-self: flex-start;
}

.ai-user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.ai-bot-message .ai-message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
}

.ai-user-message .ai-message-avatar {
    background: #64748b;
    color: white;
}

.ai-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    word-wrap: break-word;
}

.ai-user-message .ai-message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
}

.ai-message-content p {
    margin: 0;
    line-height: 1.4;
    font-size: 14px;
}

.ai-message-content strong {
    font-weight: 600;
    color: var(--primary-color);
}

.ai-user-message .ai-message-content strong {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

/* Стили для курсива */
.ai-message-content em {
    font-style: italic;
    color: var(--secondary-color);
}

.ai-user-message .ai-message-content em {
    color: rgba(255, 255, 255, 0.85);
}

/* Стили для кода */
.ai-message-content code {
    background: rgba(67, 97, 238, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    color: var(--primary-color);
    border: 1px solid rgba(67, 97, 238, 0.2);
}

.ai-user-message .ai-message-content code {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Стили для блоков цитат */
.ai-message-content blockquote {
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 4px solid var(--primary-color);
    background: rgba(67, 97, 238, 0.05);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--secondary-color);
}

.ai-user-message .ai-message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

/* Стили для списков */
.ai-message-content ul, .ai-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.ai-message-content li {
    margin: 4px 0;
    line-height: 1.4;
}

.ai-message-content ul li {
    list-style-type: none;
    position: relative;
}

.ai-message-content ul li:before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    position: absolute;
    left: -15px;
}

.ai-user-message .ai-message-content ul li:before {
    color: rgba(255, 255, 255, 0.8);
}

/* Стили для заголовков в сообщениях */
.ai-message-content h1, 
.ai-message-content h2, 
.ai-message-content h3 {
    margin: 15px 0 10px 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--primary-color);
}

.ai-message-content h1 {
    font-size: 18px;
    border-bottom: 2px solid rgba(67, 97, 238, 0.2);
    padding-bottom: 5px;
}

.ai-message-content h2 {
    font-size: 16px;
    border-bottom: 1px solid rgba(67, 97, 238, 0.15);
    padding-bottom: 3px;
}

.ai-message-content h3 {
    font-size: 15px;
    margin-bottom: 8px;
}

.ai-user-message .ai-message-content h1,
.ai-user-message .ai-message-content h2,
.ai-user-message .ai-message-content h3 {
    color: rgba(255, 255, 255, 0.95);
}

.ai-user-message .ai-message-content h1 {
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.ai-user-message .ai-message-content h2 {
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

/* Стили для кликабельных библейских ссылок */
.bible-link {
    color: var(--primary-color);
    background: rgba(67, 97, 238, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(67, 97, 238, 0.2);
    transition: all 0.2s ease;
    display: inline-block;
    margin: 1px;
}

.bible-link:hover {
    background: rgba(67, 97, 238, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(67, 97, 238, 0.3);
}

.bible-link:active {
    transform: translateY(0);
}

.ai-user-message .bible-link {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.ai-user-message .bible-link:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
    display: block;
}

.ai-chat-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.ai-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-input-container input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    background: #f8fafc;
    transition: all 0.2s;
}

.ai-input-container input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.ai-input-container input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #64748b;
    animation: messageAppear 0.3s ease;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { 
        transform: scale(0.8); 
        opacity: 0.5; 
    }
    30% { 
        transform: scale(1); 
        opacity: 1; 
    }
}

/* Стилизация скроллбара для чата */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(67, 97, 238, 0.3);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(67, 97, 238, 0.5);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .ai-container {
        bottom: 10px;
        right: 10px;
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
    
    .ai-promo-text {
        font-size: 12px;
        padding: 8px 12px;
        max-width: 200px;
        text-align: center;
    }
    
    .ai-chat-window {
        width: calc(100vw - 20px);
        height: 400px;
        bottom: 70px;
        right: -10px;
    }
    
    .ai-toggle-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .ai-message {
        max-width: 90%;
    }
    
    .ai-retry-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
    
    /* Сдвигаем кнопку ассистента ниже при открытом чате */
    .ai-chat-window.open ~ .ai-toggle-btn {
        transform: translateY(50px);
    }
}

/* Tablet responsive */
@media (max-width: 768px) and (min-width: 481px) {
    .ai-container {
        gap: 12px;
    }
    
    .ai-promo-text {
        font-size: 13px;
        padding: 10px 15px;
    }
}

/* Кнопки подтверждения для очистки истории */
.ai-confirmation-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.ai-confirm-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 100px;
    justify-content: center;
}

.ai-confirm-yes {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.ai-confirm-yes:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.ai-confirm-no {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.ai-confirm-no:hover {
    background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(149, 165, 166, 0.3);
}

.ai-confirm-btn:active {
    transform: translateY(0);
}

/* Сообщения с подтверждением */
.ai-confirmation-message {
    border-left: 4px solid #f39c12;
    background: rgba(243, 156, 18, 0.1);
    border-radius: 8px;
    padding: 4px 8px;
}

/* Мобильная адаптация для заголовка */
@media (max-width: 480px) {
    .ai-chat-header {
        padding: 12px 14px;
        min-height: 65px;
    }
    
    .ai-avatar {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .ai-greeting {
        font-size: 15px;
    }
    
    .ai-title {
        font-size: 13px;
    }
    
    .ai-status-main {
        font-size: 11px;
    }
    
    .ai-status-history {
        font-size: 10px;
    }
    
    .ai-control-btn,
    .ai-close-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}
