/* css/chat.css */
.av-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1050;
    font-family: system-ui, -apple-system, sans-serif;
}

.av-chat-button {
    width: 60px;
    height: 60px;
    background: #0d6efd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.4);
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
    outline: none;
    animation: chatPulseAttention 2s infinite ease-in-out;
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    -webkit-font-smoothing: subpixel-antialiased;
}

@keyframes chatPulseAttention {
    0% { transform: scale(1); box-shadow: 0 4px 15px rgba(13, 110, 253, 0.4); }
    50% { transform: scale(1.15); box-shadow: 0 4px 25px rgba(13, 110, 253, 0.7); }
    100% { transform: scale(1); box-shadow: 0 4px 15px rgba(13, 110, 253, 0.4); }
}

.av-chat-label {
    position: absolute;
    right: 85px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    color: #1e293b;
    padding: 12px 20px 12px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(13, 110, 253, 0.15), 0 2px 10px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: floatLabel 3s ease-in-out infinite;
}

/* Зеленая мигающая точка "В сети" */
.av-chat-label::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulseDot 2s infinite;
}

@keyframes floatLabel {
    0% { transform: translateY(-50%); }
    50% { transform: translateY(-55%); }
    100% { transform: translateY(-50%); }
}

@keyframes pulseDot {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.av-chat-label:hover {
    background: #ffffff;
    transform: translateY(-50%) scale(1.03);
    box-shadow: 0 10px 30px rgba(13, 110, 253, 0.2), 0 4px 15px rgba(0, 0, 0, 0.08);
    animation-play-state: paused;
}

.av-chat-label::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 7px 0 7px 7px;
    border-style: solid;
    border-color: transparent transparent transparent #f8f9fa;
    filter: drop-shadow(2px 0px 1px rgba(0,0,0,0.03));
}

/* Скрываем надпись, если окно чата открыто */
.av-chat-widget:has(.av-chat-window.open) .av-chat-label {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-50%) translateX(20px) scale(0.9);
    animation: none;
}

.av-chat-button:hover {
    animation-play-state: paused;
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.6);
}

.av-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.av-chat-window.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.av-chat-header {
    background: #0d6efd;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.av-chat-header-close {
    cursor: pointer;
    font-size: 20px;
    opacity: 0.8;
}

.av-chat-header-close:hover {
    opacity: 1;
}

.av-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

.av-chat-msg-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 5px;
}
.av-chat-msg-wrapper.client {
    flex-direction: row-reverse;
}
.av-chat-msg-wrapper.manager {
    flex-direction: row;
}

.av-chat-avatar {
    width: 32px;
    height: 32px;
    background: #0d6efd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.av-chat-msg-container {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.av-chat-msg-name {
    font-size: 11px;
    color: #6c757d;
    margin-bottom: 3px;
    margin-left: 5px;
}

.av-chat-msg {
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.av-chat-msg.client {
    background: #0d6efd;
    color: white;
    border-bottom-right-radius: 4px;
}

.av-chat-msg.manager {
    background: #e9ecef;
    color: #212529;
    border-bottom-left-radius: 4px;
}

.av-chat-msg-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.av-chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
}

.av-chat-input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 8px 15px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
}

.av-chat-input:focus {
    border-color: #0d6efd;
}

.av-chat-send {
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.av-chat-send:hover {
    background: #0b5ed7;
}

.av-chat-attach {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: #6c757d;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.av-chat-attach:hover {
    background: #e9ecef;
    color: #0d6efd;
}

.av-chat-attach.loading {
    animation: avChatPulse 1s infinite;
    pointer-events: none;
    opacity: 0.6;
}

@keyframes avChatPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.chat-image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 5px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.chat-image:hover {
    transform: scale(1.02);
}

.chat-lightbox {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 1060;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
}
.chat-lightbox.active {
    opacity: 1; pointer-events: auto;
}
.chat-lightbox img {
    max-width: 90%; max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    transform: scale(0.9); transition: transform 0.3s;
}
.chat-lightbox.active img {
    transform: scale(1);
}
.chat-lightbox-close {
    position: absolute; top: 20px; right: 30px;
    color: white; font-size: 40px; cursor: pointer;
    font-weight: 300;
}
.chat-lightbox-close:hover {
    color: #ccc;
}

/* Mobile responsive */
@media (max-width: 576px) {
    .av-chat-widget {
        bottom: 20px;
        right: 20px;
    }
    .av-chat-button {
        width: 55px;
        height: 55px;
        font-size: 24px;
        animation: chatPulseAttentionMobile 2s infinite ease-in-out;
    }
    @keyframes chatPulseAttentionMobile {
        0% { transform: scale(1); box-shadow: 0 4px 15px rgba(13, 110, 253, 0.4); }
        50% { transform: scale(1.12); box-shadow: 0 4px 25px rgba(13, 110, 253, 0.7); }
        100% { transform: scale(1); box-shadow: 0 4px 15px rgba(13, 110, 253, 0.4); }
    }
    .av-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important; /* Override base 500px */
        border-radius: 0 !important;
        z-index: 9999 !important;
        transform: translateY(100%);
    }
    .av-chat-window.open {
        transform: translateY(0) !important;
    }
    .av-chat-header {
        padding: 12px 15px;
    }
    .av-chat-input {
        font-size: 16px !important; /* Fix for iOS Safari auto-zoom bug */
    }
}
