/* ========== CHAT BUBBLE ========== */

.chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
    transition: transform 0.2s, opacity 0.2s;
}

.chat-bubble:hover {
    transform: scale(1.08);
}

.chat-bubble-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    z-index: 1;
}

.chat-bubble-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #0a0a0f;
    z-index: 1;
}

.chat-bubble-status.online {
    background: #22c55e;
}

.chat-bubble-status.offline {
    background: #6b7280;
}

/* ========== CHAT WIDGET ========== */

.chat-widget {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #0a0a0f;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    z-index: 9999;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    overflow: hidden;
}

.chat-widget-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ========== HEADER ========== */

.chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.chat-widget-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.chat-widget-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.chat-widget-close:hover {
    color: #fff;
}

/* ========== BODY ========== */

.chat-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-widget-body::-webkit-scrollbar {
    width: 4px;
}

.chat-widget-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* ========== MESSAGES ========== */

.chat-msg {
    max-width: 80%;
    animation: chatFadeIn 0.2s ease;
}

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

.chat-msg-visitor {
    align-self: flex-end;
}

.chat-msg-operator {
    align-self: flex-start;
}

.chat-msg-text {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg-visitor .chat-msg-text {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-operator .chat-msg-text {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-bottom-left-radius: 4px;
}

.chat-msg-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 4px;
    padding: 0 4px;
}

.chat-msg-visitor .chat-msg-time {
    text-align: right;
}

.chat-msg-pending {
    opacity: 0.6;
}

.chat-msg-failed .chat-msg-text {
    border: 1px solid rgba(239, 68, 68, 0.5);
}

/* ========== WELCOME ========== */

.chat-welcome {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    padding: 40px 20px;
    line-height: 1.6;
}

/* ========== FOOTER ========== */

.chat-widget-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.chat-input-name {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    margin-bottom: 8px;
    outline: none;
    box-sizing: border-box;
}

.chat-input-name::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chat-input-name:focus {
    border-color: #7c3aed;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input-text {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
    box-sizing: border-box;
}

.chat-input-text::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chat-input-text:focus {
    border-color: #7c3aed;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.chat-send-btn:hover {
    opacity: 0.85;
}

/* ========== FEEDBACK FORM ========== */

.chat-feedback-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-fb-name,
.chat-fb-contact,
.chat-fb-message {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.chat-fb-name::placeholder,
.chat-fb-contact::placeholder,
.chat-fb-message::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chat-fb-name:focus,
.chat-fb-contact:focus,
.chat-fb-message:focus {
    border-color: #7c3aed;
}

.chat-fb-message {
    resize: none;
}

.chat-fb-submit {
    width: 100%;
    height: auto;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

/* ========== MOBILE ========== */

@media (max-width: 480px) {
    .chat-widget {
        width: 100vw;
        right: 0;
        left: 0;
        bottom: 0;
        top: 0;
        height: 100dvh;
        border-radius: 0;
    }

    .chat-bubble {
        bottom: 16px;
        right: 16px;
    }

    /* Inputs ≥16px чтобы iOS Safari не зумился при focus */
    .chat-input-name,
    .chat-input-text,
    .chat-fb-name,
    .chat-fb-contact,
    .chat-fb-message {
        font-size: 16px;
    }
}
