/* AI Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-button-container {
    position: relative;
    display: inline-block;
}

.chat-toggle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 40px rgba(102, 126, 234, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 60px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
    animation: pulseSize 2s ease-in-out infinite;
}

.chat-toggle::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #ff0080, #667eea, #764ba2, #ff0080);
    border-radius: 50%;
    z-index: -1;
    opacity: 0.7;
    animation: rotate 3s linear infinite;
}

.chat-toggle:hover {
    animation-play-state: paused;
    transform: scale(1.1);
    box-shadow: 0 8px 40px rgba(102, 126, 234, 0.8), 0 0 0 5px rgba(102, 126, 234, 0.2);
}

.chat-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(255, 71, 87, 0.5);
    z-index: 20;
    pointer-events: none;
}

@keyframes pulseSize {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 8px 40px rgba(102, 126, 234, 0.8);
    }
    50% { 
        transform: scale(1.15);
        box-shadow: 0 12px 60px rgba(102, 126, 234, 1);
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Дополнительные стили для привлечения внимания */
.chat-toggle::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.3) 0%, transparent 70%);
    animation: ripple 2s ease-out infinite;
}

@keyframes ripple {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.chat-window {
    position: absolute;
    bottom: 140px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

.chat-window.active {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

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

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

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

.chat-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

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

.chat-status {
    background: #f8f9ff;
    padding: 12px 20px;
    border-bottom: 1px solid #e1e5e9;
    font-size: 14px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse-green 2s infinite;
}

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

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafbfc;
}

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

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

.message.user {
    text-align: right;
}

.message.ai {
    text-align: left;
}

.message-content {
    display: inline-block;
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.ai .message-content {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.chat-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e1e5e9;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    position: relative;
}

.char-counter {
    position: absolute;
    right: 60px;
    bottom: 15px;
    font-size: 12px;
    color: #666;
    background: white;
    padding: 2px 5px;
    border-radius: 3px;
}

.chat-input {
    flex: 1;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 20px;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #667eea;
}

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

.chat-send:hover {
    transform: scale(1.05);
}

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

.model-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.model-btn {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.model-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.model-btn:hover:not(.active) {
    border-color: #667eea;
    background: #f8f9ff;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 14px;
    margin: 16px 0;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 16px;
    animation: fadeIn 0.3s ease-in;
}

.typing-indicator::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: pulse 1.5s infinite;
    margin-right: 4px;
}

@keyframes pulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    30% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

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

/* Три точки анимация */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
}

.typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #667eea;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #667eea;
    animation: typingDot 1.5s infinite;
}

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

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

.limit-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #8b6914;
}

.welcome-message {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.welcome-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.welcome-features {
    color: #666;
    font-size: 13px;
}

.welcome-features ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.welcome-features li {
    margin-bottom: 4px;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -10px;
    }
    
    .chat-toggle {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}
/* Мобильная адаптация для большой кнопки */
@media (max-width: 768px) {
    .chat-toggle {
        width: 80px;
        height: 80px;
        font-size: 40px;
    }
    
    .chat-badge {
        width: 28px;
        height: 28px;
        font-size: 14px;
        top: -5px;
        right: -5px;
    }
    
    .chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-window {
        position: fixed !important;
        width: calc(100vw - 30px) !important;
        height: 70vh !important;
        max-height: 450px !important;
        bottom: 100px !important;
        right: 15px !important;
        left: 15px !important;
        margin: 0 !important;
        max-width: none !important;
    }
    
    .chat-messages {
        height: calc(100% - 140px) !important;
    }
    
    .welcome-message {
        padding: 10px !important;
        font-size: 13px !important;
    }
    
    .welcome-features {
        display: none !important;
    }
}
