.chatbot-widget {
    --chatbot-color: #2563eb;
    --chatbot-offset-x: 20px;
    --chatbot-offset-y: 20px;
    --chatbot-offset: var(--chatbot-offset-x);
    position: fixed;
    bottom: var(--chatbot-offset-y);
    z-index: 100000;
    font-family: inherit;
    font-size: var(--chatbot-font-size, 14px);
    line-height: 1.45;
    color: #1f2937;
}

.chatbot-widget *,
.chatbot-widget *::before,
.chatbot-widget *::after {
    box-sizing: border-box;
}

.chatbot-position-right {
    right: var(--chatbot-offset-x);
}

.chatbot-position-left {
    left: var(--chatbot-offset-x);
}

/* Toggle button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
    padding: 0;
}

.chatbot-toggle:hover {
    transform: scale(1.06);
}

.chatbot-toggle svg {
    width: 70%;
    height: 70%;
    display: none;
}

.chatbot-toggle svg:first-child {
    display: block;
}

.chatbot-toggle.chatbot-open svg:first-child {
    display: none;
}

.chatbot-toggle.chatbot-open svg:nth-child(2) {
    display: block;
}

.chatbot-toggle img {
    width: 70%;
    height: 70%;
    display: block;
    object-fit: contain;
    border-radius: 50%;
}

.chatbot-toggle.chatbot-open img {
    display: none;
}

/* Panel */
.chatbot-panel {
    position: fixed;
    bottom: calc(var(--chatbot-offset-y) + 76px);
    right: var(--chatbot-offset-x);
    width: 370px;
    max-width: calc(100vw - 24px);
    height: min(540px, calc(100vh - 130px));
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-position-left .chatbot-panel {
    right: auto;
    left: var(--chatbot-offset-x);
}

.chatbot-panel[hidden] {
    display: none;
}

.chatbot-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--chatbot-color);
    color: #fff;
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.143em;
    overflow: hidden;
    flex-shrink: 0;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chatbot-title {
    flex: 1;
    min-width: 0;
}

.chatbot-name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-status {
    font-size: 0.786em;
    opacity: 0.85;
}

.chatbot-clear,
.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.143em;
    padding: 4px 6px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
}

.chatbot-clear:hover,
.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f4f6f9;
}

.chatbot-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatbot-msg {
    display: flex;
}

.chatbot-msg-user {
    justify-content: flex-end;
}

.chatbot-bubble {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chatbot-msg-user .chatbot-bubble {
    background: var(--chatbot-color);
    color: #fff;
    border-bottom-right-radius: 3px;
}

.chatbot-msg-bot .chatbot-bubble {
    border-bottom-left-radius: 3px;
}

.chatbot-msg-web .chatbot-bubble {
    border: 1px solid #fbbf24;
}

.chatbot-text a {
    color: var(--chatbot-color);
}

.chatbot-msg-user .chatbot-text a {
    color: #fff;
    text-decoration: underline;
}

.chatbot-code {
    background: #1f2937;
    color: #e5e7eb;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.857em;
    overflow-x: auto;
    white-space: pre-wrap;
}

.chatbot-text code {
    background: rgba(0, 0, 0, 0.08);
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

.chatbot-msg-user .chatbot-text code {
    background: rgba(255, 255, 255, 0.25);
}

.chatbot-sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #d1d5db;
}

.chatbot-sources-title {
    font-size: 0.786em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    margin-bottom: 4px;
}

.chatbot-sources ul {
    margin: 0;
    padding-left: 16px;
}

.chatbot-sources li {
    font-size: 0.93em;
    margin-bottom: 3px;
}

.chatbot-sources a {
    color: var(--chatbot-color);
    text-decoration: none;
}

.chatbot-sources a:hover {
    text-decoration: underline;
}

.chatbot-typing-dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 4px;
    border-radius: 50%;
    background: #9ca3af;
    animation: chatbot-blink 1.2s infinite;
}

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

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

@keyframes chatbot-blink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}

.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0 4px;
}

.chatbot-suggestion {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #374151;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 0.93em;
    cursor: pointer;
}

.chatbot-suggestion:hover {
    border-color: var(--chatbot-color);
    color: var(--chatbot-color);
}

.chatbot-msg-error .chatbot-bubble {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.chatbot-form {
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.chatbot-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    border: none;
}

.chatbot-input-row {
    display: flex;
    gap: 8px;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 1em;
    outline: none;
    min-width: 0;
}

.chatbot-input:focus {
    border-color: var(--chatbot-color);
}

.chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--chatbot-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: default;
}

@media (max-width: 480px) {
    .chatbot-panel {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: none;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
    }

    .chatbot-toggle {
        width: 54px;
        height: 54px;
    }
}
