#agtech-chatbot {
    --chatbot-header-bg: #163f7a;
    --chatbot-header-color: #ffffff;
    --chatbot-launcher-bg: #163f7a;
    --chatbot-launcher-color: #ffffff;
    --chatbot-body-bg: #ffffff;
    --chatbot-body-color: #1f2937;
    --chatbot-bot-bg: #e9eef6;
    --chatbot-bot-color: #1f2937;
    --chatbot-user-bg: #163f7a;
    --chatbot-user-color: #ffffff;
    --chatbot-input-bg: #ffffff;
    --chatbot-input-color: #1f2937;
    --chatbot-send-bg: #163f7a;
    --chatbot-send-color: #ffffff;
    --chatbot-message-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --chatbot-message-font-size: 15px;
    --chatbot-width: 470px;
    --chatbot-height: 560px;
    --chatbot-radius: 22px;
    --chatbot-launcher-size: 72px;
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.widget-position-bottom_right {
    bottom: 24px;
    right: 24px;
}

.widget-position-bottom_left {
    bottom: 24px;
    left: 24px;
}

.widget-position-top_right {
    top: 24px;
    right: 24px;
}

.widget-position-top_left {
    top: 24px;
    left: 24px;
}

#chatbot-window {
    width: min(var(--chatbot-width), calc(100vw - 32px));
    height: min(var(--chatbot-height), calc(100vh - 48px));
    background: var(--chatbot-body-bg);
    color: var(--chatbot-body-color);
    border-radius: var(--chatbot-radius);
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
}

#agtech-chatbot:not(.is-open) #chatbot-window {
    display: none;
}

#agtech-chatbot.is-open #chatbot-launcher {
    display: none;
}

#chatbot-teaser {
    width: max-content;
    max-width: min(340px, calc(100vw - 32px));
    background: var(--chatbot-body-bg);
    color: var(--chatbot-body-color);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: calc(var(--chatbot-radius) - 6px);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
    padding: 14px 44px 14px 14px;
    position: absolute;
    right: 0;
    bottom: calc(var(--chatbot-launcher-size) + 12px);
    cursor: pointer;
    display: none;
    box-sizing: border-box;
}

#chatbot-teaser-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: rgba(15, 23, 42, 0.6);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

#chatbot-teaser-close:hover {
    color: rgba(15, 23, 42, 0.9);
}

.chatbot-teaser-text {
    font-size: 14px;
    line-height: 1.45;
    font-weight: 600;
    white-space: normal;
}

#chatbot-launcher {
    width: var(--chatbot-launcher-size);
    height: var(--chatbot-launcher-size);
    border-radius: 50%;
    border: none;
    background: var(--chatbot-launcher-bg);
    color: var(--chatbot-launcher-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
    margin-left: auto;
}

.chatbot-launcher-icon {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 22px;
    border-radius: 7px;
    background: currentColor;
}

.chatbot-launcher-icon::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 6px;
    width: 10px;
    height: 10px;
    background: currentColor;
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.chatbot-launcher-icon span {
    position: absolute;
    left: 6px;
    right: 6px;
    height: 2px;
    border-radius: 999px;
    background: var(--chatbot-launcher-bg);
}

.chatbot-launcher-icon span:first-child {
    top: 7px;
}

.chatbot-launcher-icon span:last-child {
    top: 12px;
}

#chatbot-header {
    background: var(--chatbot-header-bg);
    color: var(--chatbot-header-color);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.chatbot-header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.chatbot-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    color: var(--chatbot-header-color);
    flex: 0 0 auto;
}

.chatbot-avatar .chatbot-launcher-icon span {
    background: var(--chatbot-header-bg);
}

.chatbot-brand-text {
    min-width: 0;
}

.chatbot-title {
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.chatbot-status {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.9;
}

#chatbot-toggle {
    border: none;
    background: transparent;
    color: var(--chatbot-header-color);
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

#chatbot-body {
    display: flex;
    flex-direction: column;
    height: calc(100% - 88px);
    background: var(--chatbot-body-bg);
}

.chatbot-intro {
    padding: 20px 22px 8px;
    font-family: var(--chatbot-message-font-family);
    font-size: var(--chatbot-message-font-size);
    line-height: 1.6;
    color: rgba(31, 41, 55, 0.88);
}

#chatbot-messages {
    flex: 1;
    padding: 8px 22px 18px;
    overflow-y: auto;
}

.chatbot-message {
    margin-bottom: 14px;
    padding: 15px 18px;
    border-radius: 20px;
    max-width: 82%;
    line-height: 1.7;
    font-family: var(--chatbot-message-font-family);
    font-size: var(--chatbot-message-font-size);
    word-break: break-word;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.chatbot-message.user {
    background: var(--chatbot-user-bg);
    color: var(--chatbot-user-color);
    margin-left: auto;
    border-bottom-right-radius: 8px;
}

.chatbot-message.bot {
    background: var(--chatbot-bot-bg);
    color: var(--chatbot-bot-color);
    margin-right: auto;
    border-bottom-left-radius: 8px;
}

.chatbot-message.bot a {
    color: #1d4ed8;
    text-decoration: underline;
}

.chatbot-message.bot a:hover {
    color: #1e40af;
}

.chatbot-message.bot table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 14px;
}

.chatbot-message.bot table th,
.chatbot-message.bot table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.chatbot-message.bot table th {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.35);
}

#chatbot-thinking {
    padding: 13px 16px;
    margin: 0 22px 14px;
    display: none;
    background: color-mix(in srgb, var(--chatbot-bot-bg) 88%, #ffffff 12%);
    border-radius: 20px;
    border-bottom-left-radius: 8px;
    color: var(--chatbot-bot-color);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

#chatbot-thinking-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--chatbot-message-font-family);
    font-size: var(--chatbot-message-font-size);
    line-height: 1.45;
    font-weight: 600;
}

#chatbot-thinking-text::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chatbot-header-bg);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--chatbot-header-bg) 14%, transparent);
    animation: chatbotThinkingPulse 1.5s infinite ease-in-out;
}

@keyframes chatbotThinkingPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.55;
    }
}

#chatbot-input-container {
    padding: 16px 22px 20px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: var(--chatbot-body-bg);
}

.chatbot-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chatbot-input {
    flex: 1;
    padding: 13px 16px;
    border: 1px solid rgba(22, 63, 122, 0.35);
    border-radius: 14px;
    outline: none;
    font-family: var(--chatbot-message-font-family);
    font-size: var(--chatbot-message-font-size);
    background: var(--chatbot-input-bg);
    color: var(--chatbot-input-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
}

#chatbot-input::placeholder {
    color: rgba(100, 116, 139, 0.85);
}

#chatbot-input:focus {
    border-color: var(--chatbot-header-bg);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

#chatbot-send {
    min-width: 110px;
    padding: 13px 20px;
    background: var(--chatbot-send-bg);
    color: var(--chatbot-send-color);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

#chatbot-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

#chatbot-send:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.chatbot-footer-hint {
    margin-top: 12px;
    font-size: 13px;
    color: #64748b;
}

@media (max-width: 640px) {
    #agtech-chatbot {
        right: 12px;
        left: 12px;
        bottom: 12px;
        top: auto;
    }

    #chatbot-window {
        width: auto;
        height: min(var(--chatbot-height), calc(100vh - 24px));
    }

    #chatbot-launcher {
        margin-left: auto;
    }

    #chatbot-teaser {
        width: min(320px, calc(100vw - 24px));
    }

    .chatbot-title {
        font-size: 24px;
    }

    .chatbot-message {
        max-width: 92%;
    }

    .chatbot-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    #chatbot-send {
        width: 100%;
    }
}
