/* Основной контейнер чата */
#chat-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* Кнопка чата */
#chat-button {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color, #4361ee), var(--secondary-color, #3f37c9));
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 10;
    animation: pulse 2s infinite;
}

#chat-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(67, 97, 238, 0.4);
}

/* Анимация пульсации */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(67, 97, 238, 0.4);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(67, 97, 238, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(67, 97, 238, 0);
    }
}

/* Анимация вибрации */
@keyframes vibrate {
    0%, 100% { transform: translate(0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-1px, -1px); }
    20%, 40%, 60%, 80% { transform: translate(1px, 1px); }
}

#chat-button.vibrating {
    animation: vibrate 0.5s ease-in-out;
}

/* Анимация смены иконки */
@keyframes iconChange {
    0% { transform: rotate(0deg) scale(1); opacity: 1; }
    50% { transform: rotate(180deg) scale(0.8); opacity: 0; }
    100% { transform: rotate(360deg) scale(1); opacity: 1; }
}

.chat-button-icon {
    transition: all 0.3s ease;
}

.chat-button-icon.changing {
    animation: iconChange 0.5s ease;
}

/* Окно выбора мессенджеров */
#chat-options {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: white;
    border-radius: 18px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    padding: 20px;
    width: 290px;
    display: none;
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid #eef2f7;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

#chat-options.show {
    display: block;
    transform: translateY(0);
    opacity: 1;
}

.chat-option {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 10px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 15px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
}

.chat-option:last-child {
    margin-bottom: 0;
}

.chat-option:hover {
    background: #f1f5f9;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.chat-option i {
    font-size: 20px;
    margin-right: 15px;
    width: 24px;
    text-align: center;
}

.chat-option.phone { 
    color: var(--phone-option-color, #ff6b6b); 
}

.chat-option.viber { color: #7360F2; }
.chat-option.telegram { color: #0088cc; }
.chat-option.whatsapp { color: #25D366; }
.chat-option.online { 
    color: var(--online-option-color, #f39c12); 
}

/* Онлайн-чат */
#online-chat {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: white;
    border-radius: 18px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    width: 360px;
    display: none;
    flex-direction: column;
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    height: 520px;
    border: 1px solid #eef2f7;
    overflow: hidden;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

#online-chat.show {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.chat-header {
    background: linear-gradient(135deg, var(--primary-color, #4361ee), var(--secondary-color, #3f37c9));
    color: var(--header-text-color, #ffffff);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--header-text-color, #ffffff) !important;
}

.close-chat {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--header-text-color, #ffffff);
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    position: absolute;
    top: 15px;
    right: 15px;
}

.close-chat:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

.message {
    margin-bottom: 15px;
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 80%;
    position: relative;
    animation: fadeIn 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    line-height: 1.5;
    font-size: 14px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    background: linear-gradient(135deg, var(--primary-color, #4361ee), var(--secondary-color, #3f37c9));
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.admin {
    background: #ffffff;
    color: #495057;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.message.user-info {
    background: #ffffff;
    color: #495057;
    margin: 10px auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    width: 100%;
    max-width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message.user-info h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--primary-color, #4361ee);
    font-size: 15px;
    font-weight: 600;
}

.message.user-info p {
    margin: 5px 0;
    color: #64748b;
    font-size: 14px;
}

.message.user-info strong {
    color: #334155;
}

.chat-input-container {
    display: flex;
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    background: white;
}

#chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    outline: none;
    font-size: 15px;
    transition: all 0.2s;
    background: #f8fafc;
}

#chat-input:focus {
    border-color: var(--primary-color, #4361ee);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
    background: white;
}

#send-message {
    background: linear-gradient(135deg, var(--primary-color, #4361ee), var(--secondary-color, #3f37c9));
    color: white;
    border: none;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    margin-left: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.2);
}

#send-message:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(67, 97, 238, 0.3);
}

/* Форма ввода данных пользователя */
.user-info-form-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    display: none;
    transform: translateY(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-top: 1px solid #eef2f7;
    z-index: 100;
    max-height: 80%;
    overflow-y: auto;
}

.user-info-form-container.show {
    display: block;
    transform: translateY(0);
    opacity: 1;
}

.user-info-form {
    position: relative;
    padding-top: 30px;
}

.user-info-form h4 {
    margin-top: 0;
    color: var(--primary-color, #4361ee);
    font-size: 18px;
    margin-bottom: 20px;
    font-weight: 600;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 15px;
    color: #495057;
}

.form-group input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-sizing: border-box;
    font-size: 15px;
    transition: all 0.2s;
    background: #f8fafc;
}

.form-group input:focus {
    border-color: var(--primary-color, #4361ee);
    outline: none;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
    background: white;
}

.response-method-group {
    margin-bottom: 25px;
}

.response-method-group h5 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 15px;
    color: #495057;
    font-weight: 500;
}

.response-method-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.response-method-option {
    position: relative;
}

.response-method-option input {
    display: none;
}

.response-method-option label {
    display: block;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    background: #f8fafc;
}

.response-method-option input:checked + label {
    background: linear-gradient(135deg, var(--primary-color, #4361ee), var(--secondary-color, #3f37c9));
    color: white;
    border-color: var(--primary-color, #4361ee);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.2);
}

.response-method-option label:hover {
    border-color: var(--primary-color, #4361ee);
}

#save-user-info {
    background: linear-gradient(135deg, var(--primary-color, #4361ee), var(--secondary-color, #3f37c9));
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.2);
}

#save-user-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(67, 97, 238, 0.3);
}

.close-form {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--close-button-color, #64748b);
    font-size: 24px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 10;
}

.close-form:hover {
    background: #f1f5f9;
    color: var(--close-button-color, #64748b);
}

/* Кнопка "Оставить контакты для ответа" */
.leave-contact-btn {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    margin: 12px auto;
    display: block;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.leave-contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Кнопка "Очистить чат" */
.clear-chat-btn {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    margin: 8px auto;
    display: block;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.clear-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Редактирование сообщений */
.edit-message-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    font-size: 12px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .edit-message-btn {
    opacity: 1;
}

.edit-message-btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

.edit-message-form {
    display: none;
    margin-top: 10px;
}

.edit-message-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    resize: vertical;
    font-size: 14px;
    margin-bottom: 10px;
}

.edit-message-actions {
    display: flex;
    gap: 10px;
}

.edit-message-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.save-edit-btn {
    background: linear-gradient(135deg, var(--primary-color, #4361ee), var(--secondary-color, #3f37c9));
    color: white;
}

.cancel-edit-btn {
    background: #e9ecef;
    color: #495057;
}

/* Редактирование информации пользователя */
.edit-info-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    font-size: 12px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.message.user-info:hover .edit-info-btn {
    opacity: 1;
}

.edit-info-btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

.edit-info-form {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

.edit-info-form .form-group {
    margin-bottom: 15px;
}

.edit-info-form .response-method-options {
    grid-template-columns: 1fr 1fr;
}

.edit-info-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.edit-info-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.save-info-btn {
    background: linear-gradient(135deg, var(--primary-color, #4361ee), var(--secondary-color, #3f37c9));
    color: white;
}

.cancel-info-btn {
    background: #e9ecef;
    color: #495057;
}

/* Адаптивность */
@media (max-width: 768px) {
    #chat-options, #online-chat {
        right: 15px;
        width: calc(100vw - 50px);
        max-width: 360px;
    }
    
    #chat-button {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    #online-chat {
        height: 480px;
    }
    
    .chat-messages {
        max-height: 250px;
    }
    
    .response-method-options {
        grid-template-columns: 1fr;
    }
    
    .response-method-option label {
        font-size: 12px;
        padding: 8px;
    }
}

/* Стили для прелоадера */
.chat-loader {
    display: none;
    text-align: center;
    padding: 15px;
}

.chat-loader.show {
    display: block;
}

.chat-loader span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--primary-color, #4361ee);
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.5s infinite;
}

.chat-loader span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-loader span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Стили для сообщения с данными пользователя */
.user-info-message {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    margin-top: 10px;
    font-size: 14px;
    width: 100%;
}

.user-info-message h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #495057;
    font-size: 15px;
}

.user-info-message p {
    margin: 5px 0;
    color: #64748b;
}

.user-info-message strong {
    color: #334155;
}

/* Стили для временных меток */
.message-timestamp {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

.message.user .message-timestamp {
    color: rgba(255, 255, 255, 0.8);
}

.message.admin .message-timestamp,
.message.user-info .message-timestamp {
    color: #94a3b8;
}

/* Индикатор новых сообщений */
.new-message-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Стили для сообщения о редактировании */
.edited-indicator {
    font-size: 10px;
    opacity: 0.6;
    margin-left: 5px;
}