/* chat-widget.css */
.chat-widget {
    position: fixed;
    z-index: 9999;
    bottom: 20px;
    right: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.chat-widget.closed .chat-container {
    display: none;
}

.chat-widget.open .chat-toggle .chat-icon {
    display: none;
}

.chat-widget.closed .chat-toggle .close-icon {
    display: none;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 28px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.chat-toggle:active {
    transform: scale(0.95);
}

.chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    border: 1px solid rgba(0,0,0,0.06);
}

@media (prefers-color-scheme: dark) {
    .chat-container {
        background: #1a1a2e;
        border-color: #2a2a4a;
        box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    }
    .chat-messages {
        background: #0f0f14;
    }
    .chat-input-container {
        background: #1a1a2e;
        border-top: 1px solid #2a2a4a;
    }
    .chat-input {
        background: #0f0f14;
        color: #f0f0f0;
        border-color: #2a2a4a;
    }
    .chat-input::placeholder { color: #555; }
    .chat-input:focus { border-color: #667eea; }
    .user-message .message-content {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border-bottom-right-radius: 4px;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
    .admin-message .message-content {
        background: #2a2a4a;
        color: #f0f0f0;
        border-bottom-left-radius: 4px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }
    .admin-message .admin-label { color: #FFB800; }
    .bot-message .message-content {
        background: #2a2a4a;
        color: #f0f0f0;
        border-bottom-left-radius: 4px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }
    .typing-indicator .message-content { background: #2a2a4a; }
    .chat-status { background: rgba(255,255,255,0.1); }
}

.chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chat-header-icon { font-size: 24px; }
.chat-header-title { font-weight: 600; font-size: 16px; flex: 1; }
.chat-status {
    font-size: 12px;
    opacity: 0.9;
    background: rgba(255,255,255,0.2);
    padding: 2px 10px;
    border-radius: 12px;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8f9fa;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message { align-self: flex-end; }
.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

.admin-message { align-self: flex-start; }
.admin-message .message-content {
    background: #ffffff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.04);
}
.admin-message .admin-label {
    font-size: 10px;
    opacity: 0.7;
    margin-bottom: 4px;
    color: #764ba2;
}

.bot-message { align-self: flex-start; }
.bot-message .message-content {
    background: #e9ecef;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.message-content {
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.typing-indicator .message-content {
    background: #e9ecef;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
}

@media (prefers-color-scheme: dark) {
    .typing-indicator .message-content { background: #2a2a4a; }
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

.chat-input-container {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 10px 16px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.5;
    background: #f8f9fa;
    color: #333;
}
.chat-input:focus {
    border-color: #667eea;
    background: #ffffff;
}
.chat-input::placeholder { color: #999; }

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-send-btn:hover { transform: scale(1.05); opacity: 0.9; }
.chat-send-btn:active { transform: scale(0.95); }

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: #f8f9fa; }
@media (prefers-color-scheme: dark) {
    .chat-messages::-webkit-scrollbar-track { background: #0f0f14; }
}
.chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
@media (prefers-color-scheme: dark) {
    .chat-messages::-webkit-scrollbar-thumb { background: #2a2a4a; }
}
.chat-messages::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
@media (prefers-color-scheme: dark) {
    .chat-messages::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .chat-container {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        animation: slideUpMobile 0.3s ease;
    }
    @keyframes slideUpMobile {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: translateY(0); }
    }
    .chat-toggle { width: 56px; height: 56px; font-size: 24px; }
    .chat-widget { bottom: 16px; right: 16px; }
    .chat-messages { padding: 12px; }
    .message-content { font-size: 15px; padding: 10px 14px; }
    
    /* ===== СКРЫВАЕМ КНОПКУ КОГДА ЧАТ ОТКРЫТ (ТОЛЬКО ТЕЛЕФОН) ===== */
    .chat-widget.open .chat-toggle {
        display: none !important;
    }
}

@media (max-width: 380px) {
    .chat-toggle { width: 48px; height: 48px; font-size: 20px; }
    .chat-widget { bottom: 12px; right: 12px; }
    .chat-header { padding: 12px 16px; }
    .chat-input { font-size: 13px; padding: 8px 12px; }
}