:root {
    --ai-primary: #16a34a;
    --ai-primary-dark: #15803d;
    --ai-blue: #2563eb;
    --ai-bg: #f8fafc;
    --ai-card: #ffffff;
    --ai-text: #111827;
    --ai-muted: #64748b;
    --ai-border: #e5e7eb;
}

/* WRAPPER */
#ai-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
    font-family: Arial, sans-serif;
}

/* FLOAT BUTTON */
#ai-chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 14px 35px rgba(22, 163, 74, 0.45);
}

/* CHAT BOX */
#ai-chat-box {
    display: none;
    position: fixed;
    right: 24px;
    bottom: 100px;

    width: 390px;
    height: min(620px, calc(100vh - 130px));

    background: var(--ai-card);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(255,255,255,.6);

    z-index: 999999;

    grid-template-rows: auto auto 1fr auto;
}

/* HEADER */
#ai-chat-header {
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#ai-chat-header strong {
    font-size: 16px;
}

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

/* WELCOME */
#ai-chat-welcome {
    padding: 14px;
    border-bottom: 1px solid var(--ai-border);
    background: #ffffff;
}

.welcome-title {
    font-weight: 700;
    color: var(--ai-text);
    margin-bottom: 5px;
    font-size: 15px;
}

.welcome-text {
    font-size: 12.5px;
    color: var(--ai-muted);
    margin-bottom: 12px;
    line-height: 1.45;
}

.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.quick-btn {
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
    padding: 7px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
}

.quick-btn:hover {
    background: var(--ai-primary);
    color: #fff;
}

/* MESSAGES */
#ai-chat-messages {
    height: calc(100% - 255px);
    min-height: 180px;
    overflow-y: auto;
    padding: 14px;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.ai-msg,
.user-msg {
    margin-bottom: 12px;
    line-height: 1.55;
    font-size: 14px;
}

.user-msg {
    text-align: right;
}

.user-msg .bubble {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    display: inline-block;
    padding: 10px 13px;
    border-radius: 18px 18px 4px 18px;
    max-width: 82%;
    text-align: left;
    word-wrap: break-word;
}

.ai-msg .bubble {
    background: #ffffff;
    color: var(--ai-text);
    display: inline-block;
    padding: 10px 13px;
    border-radius: 18px 18px 18px 4px;
    max-width: 86%;
    white-space: pre-wrap;
    border: 1px solid var(--ai-border);
    word-wrap: break-word;
}

/* INPUT */
#ai-chat-input-area {
    min-height: 92px;
    display: flex;
    gap: 9px;
    padding: 12px;
    border-top: 1px solid var(--ai-border);
    background: #ffffff;
}

#ai-chat-input {
    flex: 1;
    resize: none;
    padding: 11px 12px;
    border-radius: 14px;
    border: 1px solid var(--ai-border);
    outline: none;
    font-size: 14px;
    color: var(--ai-text);
    background: #f8fafc;
}

#ai-chat-input:focus {
    border-color: var(--ai-primary);
    background: #ffffff;
}

#ai-chat-send {
    width: 78px;
    border: none;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
    color: white;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 600;
}

#ai-chat-send:disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* TABLET */
@media (max-width: 768px) {
    #ai-chat-widget {
        right: 16px;
        bottom: 16px;
    }

    #ai-chat-toggle {
        width: 58px;
        height: 58px;
        font-size: 24px;
    }

    #ai-chat-box {
        right: 16px;
        bottom: 86px;
        width: calc(100vw - 32px);
        height: min(620px, calc(100vh - 110px));
        border-radius: 18px;
    }

    #ai-chat-messages {
        height: calc(100% - 250px);
    }
}

/* MOBILE KECIL */
@media (max-width: 480px) {
    #ai-chat-widget {
        right: 12px;
        bottom: 12px;
    }

    #ai-chat-box {
        right: 8px;
        bottom: 76px;
        width: calc(100vw - 16px);
        height: calc(100vh - 92px);
        border-radius: 16px;
    }

    #ai-chat-header {
        padding: 12px 14px;
    }

    #ai-chat-welcome {
        padding: 12px;
    }

    .quick-btn {
        font-size: 11.5px;
        padding: 6px 9px;
    }

    #ai-chat-messages {
        height: calc(100% - 245px);
        padding: 12px;
    }

    #ai-chat-input-area {
        min-height: 86px;
        padding: 10px;
    }

    #ai-chat-send {
        width: 68px;
    }
}

.ai-msg .bubble a {
    color: #15803d;
    font-weight: 600;
    text-decoration: underline;
    word-break: break-all;
}

.user-msg .bubble a {
    color: #ffffff;
    text-decoration: underline;
    word-break: break-all;
}