:root {
    --primary-gradient: var(--primary-color);
    --chat-width: 450px;
    --chat-height: 520px;
    --header-height: 56px;
    --border-radius: 16px;
    --transition-speed: 0.3s;
}

#chatbot-popup {
    display: none;
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: var(--chat-width);
    height: var(--chat-height);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 18px 40px -5px rgba(0, 0, 0, 0.2),
        0 15px 20px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    opacity: 0;
    transform-origin: bottom right;
    transform: scale(0.95);
    transition: all var(--transition-speed) ease-in-out;
    z-index: 10000;
}

#chatbot-popup.visible {
    display: block;
    opacity: 1;
    transform: scale(1);
}

#chatbot-header {
    background: var(--primary-color);
    padding: 16px 20px;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--header-textColor);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 500;
}

.header-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.icon-button {
    background: none;
    border: none;
    color: var(--header-textColor);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-button:hover {
    color: var(--header-textColor);
    background: rgba(255, 255, 255, 0.1);
}

.icon-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

#webchat {
    height: calc(100% - var(--header-height));
    background-color: #f9fafb;
    position: relative;
}

.chat-consent {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px;
    background: #f6f8fc;
    overflow-y: auto;
    z-index: 3;
}

.chat-consent h3 {
    font-size: 18px;
    line-height: 1.5;
    margin: 0 0 14px;
    color: #0a2896;
}

.chat-consent ul {
    margin: 0 0 16px;
    padding-left: 18px;
    color: #333;
    line-height: 1.7;
    list-style-type: disc;
}

.chat-consent-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #222;
}

.chat-consent-check input {
    margin-top: 2px;
}

.chat-consent-actions {
    display: flex;
    gap: 10px;
}

.chat-consent-btn {
    border: 1px solid #0a2896;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.chat-consent-btn.is-primary {
    color: #fff;
    background: #0a2896;
}

.chat-consent-btn.is-primary:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.chat-consent-btn.is-secondary {
    color: #0a2896;
    background: #fff;
}

.chat-init-error {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    color: #cc0000;
    text-align: center;
    padding: 20px;
    background: #f6f8fc;
    z-index: 3;
}

.webchat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    pointer-events: none;
    z-index: 1;
}

#webchat>div {
    position: relative;
    z-index: 2;
}

#webchat .webchat__basic-transcript__content {
    white-space: pre-wrap !important;
    word-break: break-word !important;
}

#webchat .webchat__bubble__content {
    padding: 8px 12px !important;
}

#webchat .webchat__bubble {
    max-width: 85% !important;
    margin: 8px !important;
}

#webchat .webchat__basic-transcript__content ul,
#webchat .webchat__basic-transcript__content ol,
#webchat .webchat__bubble__content ul,
#webchat .webchat__bubble__content ol {
    padding-left: 24px !important;
    margin: 8px 0 !important;
    list-style-position: outside !important;
}

#webchat .webchat__basic-transcript__content li,
#webchat .webchat__bubble__content li {
    margin: 4px 0 !important;
    padding-left: 4px !important;
}

#webchat ul, #webchat ol {
    list-style: initial;
}

#webchat div:has(.webchat__typing-indicator) {
    display: none;
}

#webchat .webchat__typing-indicator {
    display: none;
}

.webchat__keyboard-help {
    display: none;
}

.webchat__text-content__markdown hr {
    display: block;
    margin-block-start: 0.5em;
    margin-block-end: 0.5em;
    margin-inline-start: auto;
    margin-inline-end: auto;
    color: gray;
    unicode-bidi: isolate;
    overflow: hidden;
    border-style: inset;
    border-width: 1px;
}

#open-chat {
    width: 100px;
    height: 100px;
    position: fixed;
    bottom: 45px;
    right: 75px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background-image: url('logikun-icon.png');
    background-size: contain;
    background-repeat: no-repeat;
}

#open-chat:hover {
    animation: bounce 1s ease-in-out forwards;
    background-image: url('logikun-hover.png');
}

@keyframes bounce {
    0% {
        transform: scale(1.0, 1.0) translate(0, 0);
    }
    15% {
        transform: scale(0.98, 0.9) translate(0, 5px);
    }
    30% {
        transform: scale(1.02, 1.0) translate(0, 8px);
    }
    50% {
        transform: scale(0.98, 1.05) translate(0, -8px);
    }
    70% {
        transform: scale(1.0, 0.9) translate(0, 5px);
    }
    100% {
        transform: scale(1.0, 1.0) translate(0, 0);
    }
}

#open-chat.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    pointer-events: none;
}

#open-chat:hover .logikun-balloon {
    display: block;
    animation: fadeInBalloon 0.4s ease-out forwards;
    animation-delay: 1s;
}

@keyframes fadeInBalloon {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 0.85;
        transform: translateY(0);
    }
}

.logikun-balloon {
    position: absolute;
    top: -50px;
    left: -130px;
    z-index: 2;
    display: none;
    opacity: 0;
}

@media (max-width: 768px) {
    #chatbot-popup {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    #open-chat {
        bottom: 60px;
        right: 20px;
        width: 80px;
        height: 80px;
    }

    body.showing-chatbot {
        overflow: hidden;
    }
}