#my-chatbot-container {
    --chat-bg: #fffdfd;
    --chat-surface: #ffffff;
    --chat-surface-soft: #f7eef3;
    --chat-border: rgba(101, 55, 90, 0.16);
    --chat-text: #44263f;
    --chat-text-muted: rgba(255, 255, 255, 0.74);
    --chat-primary: #2c0032;
    --chat-primary-soft: #5c3563;
    --chat-accent: #f47932;
    --chat-user-bubble: #2c0032;
    --chat-assistant-bubble: #f3e7ef;
    --chat-shadow: 0 24px 60px -24px rgba(44, 0, 50, 0.46);
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 12px;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--chat-text);
}

#my-chatbot-container *,
#my-chatbot-container *::before,
#my-chatbot-container *::after {
    box-sizing: border-box;
}

#my-chatbot-container button,
#my-chatbot-container textarea {
    font: inherit;
}

#chat-bubble {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.chat-bubble-hint {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--chat-text);
    border: 1px solid rgba(101, 55, 90, 0.12);
    box-shadow: 0 18px 36px -24px rgba(44, 0, 50, 0.45);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

#my-chatbot-container.chat-open .chat-bubble-hint {
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
}

.chat-bubble-pulse {
    position: absolute;
    right: 0;
    top: 50%;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    transform: translateY(-50%);
    border: 1px solid rgba(244, 121, 50, 0.18);
    box-shadow: 0 0 0 4px rgba(244, 121, 50, 0.06);
    animation: chat-bubble-pulse 2.8s ease-out infinite;
    pointer-events: none;
}

#my-chatbot-container.chat-open .chat-bubble-pulse {
    opacity: 0;
    animation: none;
}

.chat-bubble-icon {
    position: relative;
    z-index: 1;
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(145deg, #ffffff, #f5eaf0);
    border: 1px solid rgba(244, 121, 50, 0.28);
    box-shadow: 0 18px 44px -16px rgba(44, 0, 50, 0.5), 0 0 0 4px rgba(244, 121, 50, 0.12);
    overflow: hidden;
}

.chat-bubble-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
}

#chat-window {
    width: min(380px, calc(100vw - 16px));
    height: clamp(420px, 68vh, 580px);
    min-height: 420px;
    max-height: calc(100vh - 112px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 24px;
    background: linear-gradient(180deg, #fffefe 0%, #fcf8fb 100%);
    border: 1px solid var(--chat-border);
    box-shadow: var(--chat-shadow);
}

#chat-window.is-opening {
    animation: chat-window-enter 0.22s ease-out;
}

.chat-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 18px 16px;
    background: linear-gradient(135deg, #2c0032 0%, #5c3563 70%, #f47932 100%);
    color: #ffffff;
}

.chat-header-top,
.chat-header-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-header-main {
    min-width: 0;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
}

.chat-header-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: var(--chat-text-muted);
}

.chat-header-actions {
    display: inline-flex;
    gap: 6px;
}

.chat-header-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
}

.chat-header-btn i,
.chat-header-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

.chat-header-status {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chat-header-status.status-ready {
    background: rgba(255, 255, 255, 0.18);
}

.chat-header-status.status-sending {
    background: #f47932;
}

.chat-header-status.status-error {
    background: #d44c4c;
}

.chat-header-assistant {
    font-size: 10px;
    color: var(--chat-text-muted);
    letter-spacing: 0.02em;
}

#chat-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: transparent;
}

.chat-message-row {
    display: flex;
    margin-bottom: 12px;
}

.chat-message-row:last-child {
    margin-bottom: 0;
}

.chat-message-row.user {
    justify-content: flex-end;
}

.chat-message-row.bot,
.chat-message-row.system {
    justify-content: flex-start;
}

.chat-message {
    max-width: 85%;
    padding: 12px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: 0 14px 24px -22px rgba(44, 0, 50, 0.35);
    word-break: break-word;
}

.chat-message.user {
    background: var(--chat-user-bubble);
    color: #ffffff;
    border-bottom-right-radius: 6px;
}

.chat-message.bot {
    background: var(--chat-assistant-bubble);
    color: var(--chat-text);
    border-bottom-left-radius: 6px;
}

.chat-message.system {
    background: rgba(244, 121, 50, 0.12);
    color: #955025;
    border-bottom-left-radius: 6px;
}

.chat-message.typing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.chat-message p,
.chat-message ul,
.chat-message ol,
.chat-message h1,
.chat-message h2,
.chat-message h3,
.chat-message pre,
.chat-message blockquote {
    margin: 0 0 10px;
}

.chat-message p:last-child,
.chat-message ul:last-child,
.chat-message ol:last-child,
.chat-message h1:last-child,
.chat-message h2:last-child,
.chat-message h3:last-child,
.chat-message pre:last-child,
.chat-message blockquote:last-child {
    margin-bottom: 0;
}

.chat-message ul,
.chat-message ol {
    padding-left: 18px;
}

.chat-message li + li {
    margin-top: 6px;
}

.chat-message h1,
.chat-message h2,
.chat-message h3 {
    line-height: 1.35;
    font-weight: 700;
}

.chat-message h1 {
    font-size: 1.04em;
}

.chat-message h2 {
    font-size: 1em;
}

.chat-message h3 {
    font-size: 0.96em;
}

.chat-message code {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(44, 0, 50, 0.08);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92em;
}

.chat-message pre {
    overflow-x: auto;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(44, 0, 50, 0.08);
}

.chat-message blockquote {
    padding-left: 12px;
    border-left: 3px solid rgba(244, 121, 50, 0.42);
}

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

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
    animation: chat-typing-dot 1s ease-in-out infinite;
}

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

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

.chat-composer {
    padding: 12px;
    border-top: 1px solid rgba(101, 55, 90, 0.12);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
}

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

#chat-input-field {
    flex: 1;
    min-height: 46px;
    max-height: 120px;
    resize: none;
    overflow-y: hidden;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding: 12px 14px;
    border: 1px solid rgba(101, 55, 90, 0.16);
    border-radius: 16px;
    background: var(--chat-bg);
    color: var(--chat-text);
    outline: none;
    line-height: 1.5;
}

#chat-input-field::-webkit-scrollbar {
    display: none;
}

#chat-input-field:focus {
    border-color: rgba(244, 121, 50, 0.48);
    box-shadow: 0 0 0 4px rgba(244, 121, 50, 0.12);
}

#chat-input-field:disabled {
    opacity: 0.72;
}

#chat-send-btn {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #2c0032 0%, #5c3563 100%);
    color: #ffffff;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 16px 28px -18px rgba(44, 0, 50, 0.65);
}

#chat-send-btn:hover {
    transform: translateY(-1px);
}

#chat-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#chat-send-btn i,
#chat-send-btn svg {
    width: 17px;
    height: 17px;
    display: block;
}

@keyframes chat-window-enter {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes chat-bubble-pulse {
    0% {
        transform: translateY(-50%) scale(1);
        opacity: 0.75;
    }

    70% {
        transform: translateY(-50%) scale(1.06);
        opacity: 0;
    }

    100% {
        transform: translateY(-50%) scale(1.08);
        opacity: 0;
    }
}

@keyframes chat-typing-dot {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    40% {
        transform: translateY(-3px);
        opacity: 0.9;
    }
}

@media (max-width: 640px) {
    #my-chatbot-container {
        right: 8px;
        left: 8px;
        bottom: 8px;
        align-items: stretch;
        flex-direction: column-reverse;
    }

    #chat-bubble {
        align-self: flex-end;
    }

    .chat-bubble-hint {
        display: none;
    }

    #chat-window {
        width: 100%;
        height: min(72vh, 560px);
        min-height: 400px;
        max-height: calc(100vh - 88px);
        border-radius: 20px;
    }

    .chat-header {
        padding: 16px;
    }

    #chat-messages {
        padding: 16px;
    }

    .chat-composer {
        padding: 10px;
    }

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