/* Стили для чата с Дианой - AI помощником */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4caf50, #2e7d32);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(76, 175, 80, 0.4);
}

.chat-toggle.active {
    background: linear-gradient(135deg, #66bb6a, #388e3c);
}

.chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.chat-container.show {
    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, #4caf50, #2e7d32);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h6 {
    margin: 0;
    font-weight: 600;
}

.chat-header .status {
    font-size: 12px;
    opacity: 0.9;
}

.chat-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    touch-action: manipulation;
    min-width: 36px;
    min-height: 36px;
}

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

.chat-close:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

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

.chat-message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px; /* Увеличили размер шрифта */
    line-height: 1.5; /* Улучшили межстрочный интервал */
    word-wrap: break-word;
}

.message-bubble.user {
    background: linear-gradient(135deg, #2a46ff, #1e3acc);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble.assistant {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.3s ease;
    color: #333; /* Черный текст */
    background-color: white; /* Белый фон */
}

.chat-input:focus {
    border-color: #2a46ff;
    box-shadow: 0 0 0 2px rgba(42, 70, 255, 0.1);
}

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4caf50, #2e7d32);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.chat-send:hover:not(:disabled) {
    transform: scale(1.1);
}

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

.quick-responses {
    padding: 8px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    max-height: 80px;
    overflow-y: auto;
    display: block; /* Убеждаемся, что видимы на всех устройствах */
}

.quick-response {
    display: inline-block;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 4px 8px;
    margin: 2px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #333; /* Изменяем цвет текста на более темный */
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-response:hover {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    border: 1px solid #e9ecef;
    margin-bottom: 15px;
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #666;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.chat-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
    font-size: 13px;
}

/* Улучшенная адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 15px;
        right: 15px;
        left: 15px;
        position: fixed;
    }
    
    .chat-toggle {
        width: 55px;
        height: 55px;
        font-size: 22px;
        box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
        position: absolute;
        right: 0;
        bottom: 0;
    }
    
    .chat-toggle:hover {
        transform: scale(1.05);
    }
    
    .chat-container {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        margin: 0;
        border-radius: 0;
        position: fixed;
        z-index: 1001;
        display: none;
        flex-direction: column;
    }
    
    /* Стили для обработки виртуальной клавиатуры */
    .chat-container.keyboard-open {
        height: calc(100vh - env(keyboard-inset-height, 0px));
        bottom: env(keyboard-inset-height, 0px);
    }
    
    .chat-header {
        padding: 12px 16px;
        border-radius: 12px 12px 0 0;
    }
    
    .chat-header h6 {
        font-size: 16px;
        margin-bottom: 2px;
    }
    
    .chat-header .status {
        font-size: 11px;
        opacity: 0.9;
    }
    
    .chat-messages {
        padding: 15px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0; /* Важно для flex */
    }
    
    .message-bubble {
        max-width: 85%;
        padding: 12px 16px;
        font-size: 15px; /* Увеличили размер шрифта для мобильных */
        line-height: 1.5; /* Улучшили межстрочный интервал */
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .chat-input-container {
        padding: 15px;
        border-radius: 0 0 12px 12px;
        flex-shrink: 0; /* Не сжимается */
        background: white;
        border-top: 1px solid #e9ecef;
    }
    
    .chat-input {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 10px 14px;
        min-height: 40px;
        max-height: 80px;
        border-radius: 20px;
        -webkit-appearance: none;
        appearance: none;
        color: #333; /* Черный текст */
        background-color: white; /* Белый фон */
    }
    
    .chat-send {
        width: 40px;
        height: 40px;
        font-size: 14px;
        flex-shrink: 0;
    }
    
    .quick-responses {
        padding: 8px 12px;
        max-height: 60px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: block; /* Принудительно показываем на мобильных */
        background: #f8f9fa;
        border-top: 1px solid #e9ecef;
    }
    
    .quick-response {
        font-size: 10px;
        padding: 4px 8px;
        max-width: 120px;
        margin: 2px;
        border-radius: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        background: white;
        border: 1px solid #e9ecef;
        color: #333; /* Темный текст для лучшей видимости */
    }
}

@media (max-width: 576px) {
    .chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .chat-toggle {
        width: 50px;
        height: 50px;
        font-size: 20px;
        position: absolute;
        right: 0;
        bottom: 0;
    }
    
    .chat-container {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        margin: 0;
        border-radius: 0;
        max-width: none;
        position: fixed;
        z-index: 1001;
        display: none;
        flex-direction: column;
    }
    
    /* Стили для обработки виртуальной клавиатуры */
    .chat-container.keyboard-open {
        height: calc(100vh - env(keyboard-inset-height, 0px));
        bottom: env(keyboard-inset-height, 0px);
    }
    
    .chat-header {
        padding: 10px 14px;
        border-radius: 10px 10px 0 0;
    }
    
    .chat-header h6 {
        font-size: 15px;
        margin-bottom: 1px;
    }
    
    .chat-header .status {
        font-size: 10px;
        opacity: 0.9;
    }
    
    .chat-messages {
        padding: 12px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0; /* Важно для flex */
    }
    
    .message-bubble {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px; /* Увеличили размер шрифта */
        border-radius: 15px;
        line-height: 1.4; /* Улучшили межстрочный интервал */
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .chat-input-container {
        padding: 12px;
        border-radius: 0 0 10px 10px;
        flex-shrink: 0; /* Не сжимается */
        background: white;
        border-top: 1px solid #e9ecef;
    }
    
    .chat-input {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 8px 12px;
        min-height: 36px;
        max-height: 70px;
        border-radius: 18px;
        -webkit-appearance: none;
        appearance: none;
        color: #333; /* Черный текст */
        background-color: white; /* Белый фон */
    }
    
    .chat-send {
        width: 36px;
        height: 36px;
        font-size: 13px;
        flex-shrink: 0;
    }
    
    .quick-responses {
        padding: 6px 10px;
        max-height: 50px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: block; /* Принудительно показываем на мобильных */
        background: #f8f9fa;
        border-top: 1px solid #e9ecef;
    }
    
    .quick-response {
        font-size: 9px;
        padding: 3px 6px;
        max-width: 100px;
        border-radius: 10px;
        margin: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        background: white;
        border: 1px solid #e9ecef;
        color: #333; /* Темный текст для лучшей видимости */
    }
}

@media (max-width: 480px) {
    .chat-widget {
        bottom: 8px;
        right: 8px;
        left: 8px;
    }
    
    .chat-toggle {
        width: 48px;
        height: 48px;
        font-size: 19px;
        position: absolute;
        right: 0;
        bottom: 0;
    }
    
    .chat-container {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        margin: 0;
        border-radius: 0;
        max-width: none;
        min-height: auto;
        position: fixed;
        z-index: 1001;
        display: none;
        flex-direction: column;
    }
    
    /* Стили для обработки виртуальной клавиатуры */
    .chat-container.keyboard-open {
        height: calc(100vh - env(keyboard-inset-height, 0px));
        bottom: env(keyboard-inset-height, 0px);
    }
    
    .chat-header {
        padding: 8px 12px;
        border-radius: 8px 8px 0 0;
    }
    
    .chat-header h6 {
        font-size: 14px;
        margin-bottom: 1px;
    }
    
    .chat-header .status {
        font-size: 9px;
        opacity: 0.9;
    }
    
    .chat-messages {
        padding: 10px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0; /* Важно для flex */
    }
    
    .message-bubble {
        max-width: 95%;
        padding: 8px 12px;
        font-size: 13px; /* Увеличили размер шрифта */
        border-radius: 12px;
        line-height: 1.4; /* Улучшили межстрочный интервал */
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .chat-input-container {
        padding: 10px;
        border-radius: 0 0 8px 8px;
        flex-shrink: 0; /* Не сжимается */
        background: white;
        border-top: 1px solid #e9ecef;
    }
    
    .chat-input {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 6px 10px;
        min-height: 34px;
        max-height: 60px;
        border-radius: 17px;
        -webkit-appearance: none;
        appearance: none;
        color: #333; /* Черный текст */
        background-color: white; /* Белый фон */
    }
    
    .chat-send {
        width: 34px;
        height: 34px;
        font-size: 12px;
        flex-shrink: 0;
    }
    
    .quick-responses {
        padding: 4px 8px;
        max-height: 40px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: block; /* Принудительно показываем на мобильных */
        background: #f8f9fa;
        border-top: 1px solid #e9ecef;
    }
    
    .quick-response {
        font-size: 8px;
        padding: 2px 4px;
        max-width: 80px;
        border-radius: 8px;
        margin: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        background: white;
        border: 1px solid #e9ecef;
        color: #333; /* Темный текст для лучшей видимости */
    }
}

/* Touch-friendly стили для мобильных устройств */
@media (hover: none) and (pointer: coarse) {
    .chat-toggle {
        min-width: 48px;
        min-height: 48px;
        touch-action: manipulation;
    }
    
    .chat-toggle:hover {
        transform: none;
    }
    
    .chat-toggle:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .chat-close {
        touch-action: manipulation;
        min-width: 36px;
        min-height: 36px;
        background: rgba(255, 255, 255, 0.15);
    }
    
    .chat-close:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(1.05);
    }
    
    .chat-close:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.9);
        transition: transform 0.1s ease;
    }
    
    .chat-send {
        touch-action: manipulation;
    }
    
    .chat-send:hover {
        transform: none;
    }
    
    .chat-send:active {
        transform: scale(0.9);
        transition: transform 0.1s ease;
    }
    
    .quick-response {
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        color: #333; /* Обеспечиваем темный текст на touch устройствах */
    }
    
    .quick-response:hover {
        background: #4caf50;
        color: white;
        border-color: #4caf50;
    }
    
    .quick-response:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
        background: #4caf50;
        color: white;
        border-color: #4caf50;
    }
    
    .chat-input {
        touch-action: manipulation;
    }
    
    /* Улучшенная прокрутка для touch устройств */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    .quick-responses {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}
