/* Виджет чата поддержки */
#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#chat-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
    transition: transform 0.2s, opacity 0.2s;
    position: relative;
}
#chat-bubble:hover { transform: scale(1.08); }
#chat-bubble.chat-bubble-hidden { opacity: 0; pointer-events: none; transform: scale(0.5); }

#chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chat-pulse 1.5s infinite;
}
@keyframes chat-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

#chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 370px;
    max-width: calc(100vw - 24px);
    height: 520px;
    max-height: calc(100vh - 40px);
    background: #1a1a2e;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 40px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chat-slide-up 0.25s ease-out;
}
@keyframes chat-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

#chat-header {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}
#chat-header-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}
#chat-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
#chat-close:hover { color: #fff; }

#chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Форма старта */
#chat-start-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#chat-welcome-text {
    color: #d1d5db;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 4px;
}
#chat-start-form input[type="text"],
#chat-start-form input[type="email"] {
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
#chat-start-form input:focus {
    border-color: #6366f1;
}
#chat-start-form input::placeholder {
    color: #6b7280;
}
#chat-captcha {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #9ca3af;
    font-size: 14px;
}
#chat-captcha input {
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 14px;
    outline: none;
}
#chat-start-btn {
    padding: 10px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
#chat-start-btn:hover { opacity: 0.9; }
#chat-start-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#chat-start-error {
    color: #ef4444;
    font-size: 13px;
    text-align: center;
}

/* Сообщения */
#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
}
.chat-msg {
    display: flex;
    max-width: 85%;
}
.chat-msg-user {
    align-self: flex-end;
    margin-left: auto;
}
.chat-msg-support {
    align-self: flex-start;
}
.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.chat-msg-user .chat-msg-bubble {
    background: #6366f1;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-support .chat-msg-bubble {
    background: rgba(255,255,255,0.08);
    color: #e0e0e0;
    border-bottom-left-radius: 4px;
}
.chat-msg-time {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: 4px;
}
.chat-msg-support .chat-msg-time { color: #6b7280; }

/* Ввод */
#chat-input-area {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
}
#chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 14px;
    outline: none;
}
#chat-input:focus { border-color: #6366f1; }
#chat-input::placeholder { color: #6b7280; }
#chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #6366f1;
    color: #fff;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    flex-shrink: 0;
}
#chat-send-btn:hover { opacity: 0.85; }
#chat-attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s, background 0.2s;
}
#chat-attach-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* Мобильная версия */
@media (max-width: 480px) {
    #chat-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}
