.ai-chat-widget {
    position: fixed;
    left: 20px;
    bottom: 24px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.ai-chat-widget.is-dragging {
    user-select: none;
}

.ai-chat-toggle {
    border: none;
    border-radius: 999px;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font: inherit;
    font-weight: 700;
    cursor: grab;
    touch-action: none;
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.2);
}

.ai-chat-toggle:hover {
    transform: translateY(-1px);
}

.ai-chat-widget.is-dragging .ai-chat-toggle {
    cursor: grabbing;
    transform: none;
}

.ai-chat-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.ai-chat-toggle-icon-svg {
    width: 19px;
    height: 19px;
}

.ai-chat-panel {
    width: min(390px, calc(100vw - 24px));
    max-height: min(620px, calc(100vh - 120px));
    background: rgba(10, 14, 22, 0.96);
    color: var(--color-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(14px);
}

.ai-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 18px 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0));
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-chat-title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
}

.ai-chat-subtitle {
    margin: 6px 0 0;
    color: rgba(245, 245, 245, 0.72);
    font-size: 13px;
    line-height: 1.8;
}

.ai-chat-close {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.ai-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    min-height: 220px;
    max-height: calc(min(620px, calc(100vh - 120px)) - 148px);
    overflow-y: auto;
    background:
        radial-gradient(circle at top left, rgba(255, 75, 43, 0.1), transparent 36%),
        radial-gradient(circle at top right, rgba(255, 202, 40, 0.08), transparent 28%),
        transparent;
}

.ai-chat-empty {
    text-align: center;
    color: rgba(245, 245, 245, 0.64);
    padding: 28px 16px;
    line-height: 1.9;
}

.ai-chat-message {
    max-width: 88%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-chat-message.user {
    align-self: flex-start;
}

.ai-chat-message.assistant,
.ai-chat-message.error,
.ai-chat-message.typing {
    align-self: flex-end;
}

.ai-chat-bubble {
    border-radius: 18px;
    padding: 12px 14px;
    line-height: 1.9;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-message.user .ai-chat-bubble {
    background: linear-gradient(135deg, rgba(255, 75, 43, 0.95), rgba(255, 65, 108, 0.92));
    color: #fff;
    border-bottom-left-radius: 8px;
}

.ai-chat-message.assistant .ai-chat-bubble,
.ai-chat-message.typing .ai-chat-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-right-radius: 8px;
}

.ai-chat-message.error .ai-chat-bubble {
    background: rgba(244, 67, 54, 0.14);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: #ffd4d1;
}

.ai-chat-meta {
    font-size: 11px;
    color: rgba(245, 245, 245, 0.56);
    padding: 0 4px;
}

.ai-chat-form {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(5, 6, 8, 0.85);
}

.ai-chat-input {
    width: 100%;
    resize: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-primary);
    padding: 12px 14px;
    font: inherit;
}

.ai-chat-input::placeholder {
    color: rgba(245, 245, 245, 0.48);
}

.ai-chat-input:focus {
    outline: none;
    border-color: rgba(255, 75, 43, 0.6);
}

.ai-chat-send,
.ai-chat-voice {
    border: none;
    border-radius: 16px;
    padding: 0 18px;
    background: linear-gradient(135deg, var(--color-secondary), #f59e0b);
    color: #111827;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.ai-chat-voice {
    width: 44px;
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-chat-voice.is-supported {
    display: inline-flex;
}

.ai-chat-voice.is-listening {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
}

.ai-chat-send:disabled,
.ai-chat-input:disabled,
.ai-chat-voice:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-chat-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ai-chat-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    animation: ai-chat-bounce 1.2s infinite ease-in-out;
}

.ai-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes ai-chat-bounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .ai-chat-widget {
        left: 12px;
        right: 12px;
        bottom: 12px;
        align-items: stretch;
    }

    .ai-chat-toggle {
        justify-content: center;
    }

    .ai-chat-panel {
        width: 100%;
        max-height: calc(100vh - 88px);
    }

    .ai-chat-form {
        grid-template-columns: 1fr 42px auto;
        gap: 8px;
    }

    .ai-chat-send {
        padding-inline: 14px;
    }

    .ai-chat-message {
        max-width: 94%;
    }
}

.ai-chat-bubble a {
    color: #8fd3ff;
    font-weight: 800;
    text-decoration: none;
    border-bottom: 1px solid rgba(143, 211, 255, 0.55);
}

.ai-chat-bubble a:hover {
    color: #fff;
    border-bottom-color: #fff;
}
