/* Site Chat Widget - Disshelp.ru */
/* Онлайн-чат виджет */

/* ============ CHAT WINDOW ============ */
.site-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.site-chat-window {
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 500px;
    max-height: calc(100vh - 180px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.site-chat-widget.active .site-chat-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ============ HEADER ============ */
.site-chat-header {
    background: linear-gradient(135deg, #2e7d32 0%, #4caf50 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.site-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-chat-avatar svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.site-chat-title {
    font-size: 16px;
    font-weight: 600;
}

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

.site-chat-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

.site-chat-close svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* ============ MESSAGES AREA ============ */
.site-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message bubble */
.site-chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
}

/* Visitor message (right) */
.site-chat-message.visitor {
    align-self: flex-end;
    background: #2e7d32;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Admin message (left) */
.site-chat-message.admin {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* System/auto-response message */
.site-chat-message.system {
    align-self: flex-start;
    background: #e3f2fd;
    color: #1565c0;
    border-bottom-left-radius: 4px;
    font-style: italic;
}

.site-chat-message-text {
    margin: 0;
    white-space: pre-wrap;
}

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

.site-chat-message.visitor .site-chat-message-meta {
    text-align: right;
}

/* File attachment */
.site-chat-message-file {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
}

.site-chat-message.visitor .site-chat-message-file {
    background: rgba(255, 255, 255, 0.1);
}

.site-chat-message-file svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.site-chat-message-file span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Welcome message */
.site-chat-welcome {
    text-align: center;
    padding: 20px;
    color: #666;
}

.site-chat-welcome h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #333;
}

.site-chat-welcome p {
    margin: 0;
    font-size: 13px;
}

/* ============ INPUT AREA ============ */
.site-chat-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.site-chat-input-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f5f5f5;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
}

.site-chat-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 14px;
    padding: 8px 0;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}

.site-chat-input::placeholder {
    color: #999;
}

/* Attach button */
.site-chat-attach-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.site-chat-attach-btn:hover {
    opacity: 1;
}

.site-chat-attach-btn svg {
    width: 20px;
    height: 20px;
    fill: #666;
}

/* Send button */
.site-chat-send-btn {
    width: 40px;
    height: 40px;
    background: #2e7d32;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.site-chat-send-btn:hover {
    background: #1b5e20;
    transform: scale(1.05);
}

.site-chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.site-chat-send-btn svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* Hidden file input */
.site-chat-file-input {
    display: none;
}

/* ============ CONTACT FORM ============ */
.site-chat-contact-form {
    padding: 16px;
    background: #fff8e1;
    border-top: 1px solid #ffecb3;
    display: none;
}

.site-chat-contact-form.show {
    display: block;
}

.site-chat-contact-form h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #f57c00;
}

.site-chat-contact-form input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

.site-chat-contact-form input:focus {
    outline: none;
    border-color: #2e7d32;
}

.site-chat-contact-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.site-chat-contact-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.site-chat-contact-submit {
    background: #2e7d32;
    color: #fff;
}

.site-chat-contact-submit:hover {
    background: #1b5e20;
}

.site-chat-contact-skip {
    background: #eee;
    color: #666;
}

.site-chat-contact-skip:hover {
    background: #ddd;
}

/* ============ TYPING INDICATOR ============ */
.site-chat-typing {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #666;
    font-size: 13px;
}

.site-chat-typing.show {
    display: flex;
}

.site-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.site-chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.site-chat-typing-dots span:nth-child(1) { animation-delay: 0s; }
.site-chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.site-chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* ============ OFFLINE MESSAGE ============ */
.site-chat-offline {
    padding: 12px 16px;
    background: #fff3e0;
    border-top: 1px solid #ffe0b2;
    text-align: center;
    font-size: 13px;
    color: #e65100;
    display: none;
}

.site-chat-offline.show {
    display: block;
}

/* ============ UNREAD BADGE ============ */
.site-chat-unread-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    background: #f44336;
    color: #fff;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s;
}

.site-chat-unread-badge.show {
    opacity: 1;
    transform: scale(1);
}

/* ============ LOADING ============ */
.site-chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.site-chat-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid #eee;
    border-top-color: #2e7d32;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ MOBILE STYLES ============ */
@media (max-width: 480px) {
    .site-chat-widget {
        bottom: 90px;
        right: 16px;
        left: 16px;
    }

    .site-chat-window {
        width: auto;
        max-width: none;
        height: calc(100vh - 180px);
        max-height: none;
        border-radius: 12px;
    }

    .site-chat-header {
        padding: 12px 16px;
    }

    .site-chat-messages {
        padding: 12px;
    }

    .site-chat-message {
        max-width: 90%;
    }

    .site-chat-input-area {
        padding: 10px 12px;
    }
}

/* ============ SOUND TOGGLE ============ */
.site-chat-sound-toggle {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    transition: background 0.2s;
}

.site-chat-sound-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.site-chat-sound-toggle svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

.site-chat-sound-toggle.muted svg {
    opacity: 0.5;
}

/* ============ FILE PREVIEW ============ */
.site-chat-file-preview {
    display: none;
    padding: 8px 16px;
    background: #e8f5e9;
    border-top: 1px solid #c8e6c9;
    align-items: center;
    gap: 8px;
}

.site-chat-file-preview.show {
    display: flex;
}

.site-chat-file-preview-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: #2e7d32;
}

.site-chat-file-preview-remove {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.site-chat-file-preview-remove:hover {
    opacity: 1;
}

.site-chat-file-preview-remove svg {
    width: 16px;
    height: 16px;
    fill: #666;
}
