/* AI Chat Widget Styles */

/* Кнопка открытия чата */
.chat-widget-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
}

.chat-widget-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.chat-widget-trigger:active {
    transform: scale(0.95);
}

.chat-widget-trigger .chat-icon {
    font-size: 28px;
    transition: all 0.3s ease;
}

.chat-widget-trigger.active .chat-icon {
    transform: rotate(90deg);
}

/* Бейдж с непрочитанными сообщениями */
.chat-widget-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

.chat-widget-badge.visible {
    display: flex;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Контейнер чата */
.chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: var(--bg-primary, #ffffff);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chat-widget.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Шапка чата */
.chat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget-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: 20px;
}

.chat-widget-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-widget-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: online-pulse 2s infinite;
}

@keyframes online-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-widget-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

.chat-widget-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Область сообщений */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 320px;
    background: var(--bg-secondary, #f9fafb);
}

/* Сообщение */
.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: messageIn 0.3s ease;
}

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

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

.chat-message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Время сообщения */
.chat-message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    display: block;
}

/* Индикатор набора */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-primary, #ffffff);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.chat-typing span:nth-child(1) { animation-delay: 0s; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        background: #9ca3af;
    }
    30% {
        transform: translateY(-8px);
        background: #667eea;
    }
}

/* Форма ввода */
.chat-widget-input {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-primary, #ffffff);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-widget-input textarea {
    flex: 1;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 42px;
    max-height: 100px;
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-primary, #1f2937);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-widget-input textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.chat-widget-input textarea::placeholder {
    color: #9ca3af;
}

.chat-widget-send {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-widget-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

.chat-widget-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Быстрые ответы */
.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-primary, #ffffff);
}

.chat-quick-reply {
    background: var(--bg-secondary, #f3f4f6);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary, #374151);
}

.chat-quick-reply:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
    }
    
    .chat-widget.open {
        bottom: 0;
    }
    
    .chat-widget-trigger {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    .chat-widget-messages {
        max-height: calc(100vh - 200px);
    }
}

/* Темная тема */
[data-theme="dark"] .chat-widget {
    background: #1f2937;
}

[data-theme="dark"] .chat-widget-messages {
    background: #111827;
}

[data-theme="dark"] .chat-message.bot {
    background: #374151;
    color: #f9fafb;
}

[data-theme="dark"] .chat-widget-input {
    background: #1f2937;
    border-top-color: #374151;
}

[data-theme="dark"] .chat-widget-input textarea {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

[data-theme="dark"] .chat-quick-reply {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

[data-theme="dark"] .chat-quick-reply:hover {
    background: #667eea;
    border-color: #667eea;
}
