/* WooCommerce AI Assistant Chat Widget Styles */
.wai-chat-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.wai-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wai-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.wai-chat-toggle {
    background: #2196F3;
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    transition: all 0.3s ease;
    border: none;
    font-size: 14px;
}

.wai-chat-toggle:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(33, 150, 243, 0.4);
}

.wai-chat-toggle.active {
    background: #1565C0;
}

.wai-chat-icon {
    font-size: 20px;
    line-height: 1;
}

.wai-chat-title {
    font-weight: 500;
}

.wai-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    max-width: 90vw;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.wai-position-bottom-left .wai-chat-window {
    right: auto;
    left: 0;
}

@media (max-width: 480px) {
    .wai-chat-window {
        width: 320px;
        right: 10px;
    }
    
    .wai-position-bottom-right {
        bottom: 10px;
        right: 10px;
    }
    
    .wai-position-bottom-left {
        bottom: 10px;
        left: 10px;
    }
}

.wai-chat-header {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.wai-chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.wai-close-chat {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.wai-close-chat:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.wai-chat-body {
    height: 350px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
}

.wai-chat-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    background: white;
}

#wai-message-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    transition: all 0.2s ease;
}

#wai-message-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

#wai-send-button {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

#wai-send-button:hover {
    background: linear-gradient(135deg, #1976D2, #1565C0);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

#wai-send-button:active {
    transform: translateY(0);
}

#wai-send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.wai-welcome-message {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    border-left: 4px solid #4CAF50;
}

.wai-welcome-message p {
    margin: 0;
    color: #2e7d32;
    font-size: 14px;
    line-height: 1.5;
}

.wai-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wai-message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.wai-user-message {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    margin-left: auto;
}

.wai-ai-message {
    background: #f0f0f0;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    margin-right: auto;
}

.wai-loading-message {
    background: #f0f0f0;
    color: #666;
    font-style: italic;
    align-self: flex-start;
}

.wai-error-message {
    background: #ffebee;
    color: #d32f2f;
    border-left: 3px solid #f44336;
    align-self: flex-start;
}

/* Стили для скроллбара */
.wai-chat-body::-webkit-scrollbar {
    width: 6px;
}

.wai-chat-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.wai-chat-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.wai-chat-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 🎯 ИСПРАВЛЕНИЕ для мобильных устройств */
@media (max-width: 768px) {
    .wai-chat-container {
        bottom: 10px !important;
        right: 10px !important;
    }
    
    .wai-chat-toggle {
        padding: 10px 16px !important;
        font-size: 13px !important;
        box-shadow: 0 3px 8px rgba(33, 150, 243, 0.3) !important;
    }
    
    .wai-chat-window {
        position: fixed !important;
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        right: 10px !important;
        left: 10px !important;
        bottom: 70px !important;
        top: auto !important;
        border-radius: 12px !important;
        box-shadow: 0 -5px 25px rgba(0,0,0,0.15) !important;
    }
    
    .wai-chat-body {
        height: 50vh !important;
        max-height: 50vh !important;
        padding: 15px !important;
    }
    
    #wai-message-input {
        font-size: 16px !important;
        padding: 12px 15px !important;
        min-height: 44px !important;
    }
    
    #wai-send-button {
        padding: 12px 20px !important;
        font-size: 16px !important;
        min-height: 44px !important;
    }
    
    .wai-message {
        font-size: 15px !important;
        line-height: 1.5 !important;
        padding: 12px 16px !important;
        max-width: 90% !important;
    }
    
    .wai-chat-header h4 {
        font-size: 15px !important;
    }
    
    .wai-close-chat {
        width: 32px !important;
        height: 32px !important;
        font-size: 24px !important;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .wai-chat-window {
        width: calc(100vw - 10px) !important;
        max-width: calc(100vw - 10px) !important;
        right: 5px !important;
        left: 5px !important;
    }
    
    .wai-chat-body {
        height: 55vh !important;
        max-height: 55vh !important;
    }
    
    .wai-chat-toggle {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }
    
    .wai-chat-icon {
        font-size: 18px !important;
    }
    
    .wai-welcome-message {
        padding: 12px !important;
        font-size: 13px !important;
    }
}

/* Для планшетов */
@media (min-width: 769px) and (max-width: 1024px) {
    .wai-chat-window {
        width: 400px !important;
    }
}

/* Исправление для iOS Safari */
@supports (-webkit-touch-callout: none) {
    #wai-message-input,
    #wai-send-button {
        font-size: 16px !important;
    }
    
    .wai-chat-body {
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Предотвращение выделения текста при касании на мобильных */
.wai-chat-toggle {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Улучшение видимости на темном фоне */
.wai-chat-toggle:active {
    transform: scale(0.95) !important;
}