.bb-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.bb-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0b64f6, #0047b3);
    box-shadow: 0 4px 12px rgba(11, 100, 246, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bb-chat-button:hover {
    transform: scale(1.1);
}

.bb-chat-button svg {
    width: 30px;
    height: 30px;
    fill: #fff;
}

.bb-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 440px !important;
    height: 650px !important;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #eee;
    z-index: 9999;
}

.bb-chat-window.open {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.bb-chat-header {
    background: linear-gradient(135deg, #0b64f6, #0047b3);
    color: #fff;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.bb-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    flex: 1;
}

.bb-chat-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    border: 1px solid rgba(255,255,255,0.3);
}

.bb-chat-details {
    display: flex;
    flex-direction: column;
}

.bb-chat-header-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bb-chat-status {
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.bb-status-dot {
    width: 8px;
    height: 8px;
    background: #4de18c;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 5px #4de18c;
}

.bb-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-left: 10px;
}

.bb-chat-end-session {
    cursor: pointer;
    font-size: 11px;
    color: #fff;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    padding: 5px 12px;
    border-radius: 20px;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.bb-chat-end-session:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.bb-chat-close {
    cursor: pointer;
    font-size: 18px;
    opacity: 0.8;
    transition: 0.2s;
}

.bb-chat-close:hover {
    opacity: 1;
}

.bb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f9fc;
}

.bb-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    display: flex;
    flex-direction: column;
}

.bb-msg-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.bb-msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
    font-size: 10px;
    user-select: none;
}

.bb-msg-time {
    opacity: 0.6;
}

.bb-msg-status {
    display: flex;
    align-items: center;
}

.bb-msg-status svg {
    width: 14px;
    height: 14px;
}

.bb-msg-in .bb-msg-time { color: rgba(255,255,255,0.8); }
.bb-msg-out .bb-msg-time { color: #888; }
.bb-msg-status.read svg { fill: #4fc3f7; }
.bb-msg-status.unread svg { fill: rgba(0,0,0,0.2); }
.bb-msg-in .bb-msg-status.unread svg { fill: rgba(255,255,255,0.4); }

.bb-msg-in {
    align-self: flex-end;
    background: #0b64f6;
    color: #fff;
    border-bottom-right-radius: 2px;
}

.bb-msg-out {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Typing Indicator */
.typing span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

.bb-chat-input-area {
    padding: 12px 15px;
    background: #fff;
    border-top: 1px solid #edf2f7;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.bb-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 15px;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
}

.bb-chat-input:focus {
    border-color: #0b64f6;
}

.bb-chat-send {
    background: #0b64f6;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    padding: 0;
    flex-shrink: 0;
}

.bb-chat-send:hover {
    background: #0047b3;
}

.bb-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.bb-chat-attach {
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #a0aec0;
    transition: 0.2s;
}

.bb-chat-attach:hover {
    color: #0b64f6;
}

.bb-chat-attach svg {
    width: 20px;
    height: 20px;
}

.bb-chat-footer {
    font-size: 10px;
    text-align: center;
    color: #a0aec0;
    padding: 5px;
    background: #f7f9fc;
}

.bb-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4d4f;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.bb-chat-preview-container {
    display: none;
    padding: 10px 15px;
    background: #fff;
    border-top: 1px solid #edf2f7;
    flex-wrap: wrap;
    gap: 10px;
}

.bb-chat-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.bb-chat-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bb-chat-preview-remove {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff4d4f;
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    border: 2px solid #fff;
    line-height: 1;
}

.bb-msg-img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 5px;
    cursor: pointer;
    display: block;
    transition: opacity 0.2s;
}

.bb-msg-img:hover {
    opacity: 0.9;
}

.bb-msg-video {
    max-width: 380px;
    max-height: 320px;
    width: 100%;
    border-radius: 10px;
    display: block;
    contain: layout;
    background: #000;
}

.bb-msg-video::-webkit-media-controls-panel {
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

/* Модальное окно для полного просмотра */
.bb-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: fadeIn 0.3s ease;
}

.bb-chat-overlay-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    cursor: default;
}

.bb-chat-overlay-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.bb-chat-overlay-close:hover {
    background: rgba(0,0,0,0.9);
}

.bb-chat-mic {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #a0aec0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bb-chat-mic:hover {
    color: #4a5568;
}

.bb-chat-mic svg {
    width: 20px;
    height: 20px;
}

.bb-chat-mic.recording {
    color: #f56565;
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.bb-msg audio {
    display: none;
}

.bb-voice-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 0;
    min-width: 180px;
    user-select: none;
}

.bb-voice-play {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.bb-msg-in .bb-voice-play { background: #fff; color: #3182ce; }
.bb-msg-out .bb-voice-play { background: #3182ce; color: #fff; }

.bb-voice-play svg {
    width: 16px;
    height: 16px;
}

.bb-voice-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 30px;
    flex-grow: 1;
}

.bb-voice-bar {
    width: 2px;
    background: currentColor;
    opacity: 0.3;
    border-radius: 1px;
    transition: height 0.2s, opacity 0.2s;
}

.bb-voice-player.playing .bb-voice-bar {
    animation: voiceWave 1.2s infinite ease-in-out;
}

@keyframes voiceWave {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1.5); }
}

/* Разная высота для статической волны */
.bb-voice-bar:nth-child(3n) { height: 12px; }
.bb-voice-bar:nth-child(3n+1) { height: 18px; }
.bb-voice-bar:nth-child(3n+2) { height: 8px; }

.bb-voice-info {
    font-size: 11px;
    opacity: 0.8;
    min-width: 30px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Индикатор набора текста */
.bb-msg.typing {
    display: none;
    align-items: center;
    flex-direction: row;
    gap: 4px;
    padding: 10px 14px;
    width: fit-content;
    background: #f1f3f5 !important;
    border-radius: 14px;
    margin: 5px 0;
    border-bottom-left-radius: 2px;
}

.bb-msg.typing span {
    width: 6px;
    height: 6px;
    background: rgba(0,0,0,0.3);
    border-radius: 50%;
    display: inline-block;
    animation: bbTyping 1.4s infinite ease-in-out;
}

.bb-msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.bb-msg.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bbTyping {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

.bb-voice-timer {
    flex-grow: 1;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 20px;
    padding: 0 15px;
    color: #4a5568;
    font-family: monospace;
    font-size: 15px;
    height: 40px;
}

.bb-timer-dot {
    width: 8px;
    height: 8px;
    background: #f56565;
    border-radius: 50%;
    animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.bb-chat-faq {
    display: flex;
    flex-direction: column;
    padding: 15px 20px 20px;
    gap: 10px;
    background: #fff;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    border-top: 1px solid #f0f4f8;
}

.bb-chat-faq:empty {
    display: none !important;
}

.bb-faq-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 20px;
    text-align: center;
}

.bb-faq-btn {
    width: 100%;
    max-width: 250px;
    padding: 12px 16px;
    background: #f7fafc;
    border: 1px solid #edf2f7;
    border-radius: 12px;
    color: #3182ce;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-weight: 500;
    outline: none;
}

.bb-faq-btn:hover {
    background: #ebf8ff;
    border-color: #bee3f8;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

@media screen and (max-width: 480px) {
    .bb-chat-window {
        width: calc(100vw - 40px) !important;
        height: calc(100vh - 120px) !important;
        bottom: 80px;
        right: 0;
    }
}

.bb-msg-doc {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: background 0.2s;
    margin-top: 5px;
    min-width: 180px;
}

.bb-msg-out .bb-msg-doc {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #3182ce;
}

.bb-msg-in .bb-msg-doc {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.bb-msg-doc:hover {
    background: rgba(255, 255, 255, 0.2);
}

.bb-msg-out .bb-msg-doc:hover {
    background: #edf2f7;
}

.bb-msg-doc svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.bb-msg-doc span {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
