/* ===== AI CHAT COMPONENT ===== */
/* Mengikuti tema BlendPath: --text-hover: #0099ff, --radius: 8px, font Inter */

#ai-chat-wrapper {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* ── Toggle Button ── */
#ai-chat-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #4c4d52;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    position: relative;
    margin-left: auto;
}

#ai-chat-toggle:hover {
    background: #0099ff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 153, 255, 0.35);
}

.ai-notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
}

/* ── Chat Panel ── */
#ai-chat-panel {
    display: none;
    flex-direction: column;
    width: 350px;
    height: 500px;
    background: #fafafa;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    margin-bottom: 12px;
    /* jarak panel ke tombol toggle */
    border: 1px solid #e5e5e5;
    animation: aiSlideUp 0.25s ease;
    order: -1;
    /* panel di ATAS tombol */
}

#ai-chat-panel.active {
    display: flex;
}

@keyframes aiSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

/* ── Header ── */
.ai-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #4c4d52;
    color: white;
    flex-shrink: 0;
}

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.ai-name {
    font-weight: 600;
    font-size: 13.5px;
}

.ai-status {
    font-size: 11px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: aiPulse 2s infinite;
}

@keyframes aiPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.ai-close-btn {
    background: none;
    border: none;
    color: white;
    opacity: 0.7;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    transition: all 0.2s ease;
}

.ai-close-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* ── Messages ── */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f2f2f2;
    scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar {
    width: 3px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: #e5e5e5;
    border-radius: 2px;
}

.ai-msg {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 82%;
}

.ai-msg--bot {
    align-self: flex-start;
}

.ai-msg--user {
    align-self: flex-end;
}

.ai-bubble {
    padding: 9px 13px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}

.ai-msg--bot .ai-bubble {
    background: #fafafa;
    color: #4c4d52;
    border: 1px solid #e5e5e5;
    border-bottom-left-radius: 2px;
}

.ai-msg--user .ai-bubble {
    background: #4c4d52;
    color: white;
    border-bottom-right-radius: 2px;
}

.ai-time {
    font-size: 10px;
    color: #aaa;
    padding: 0 3px;
}

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

/* ── Typing Indicator ── */
.ai-typing .ai-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
}

.ai-typing-dot {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: aiTyping 1.2s infinite;
}

.ai-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes aiTyping {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-5px);
    }
}

/* ── Input Area ── */
.ai-chat-input-area {
    padding: 10px 12px 8px;
    background: #fafafa;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
}

.ai-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: white;
    border-radius: 8px;
    padding: 7px 7px 7px 12px;
    border: 1px solid #e5e5e5;
    transition: border-color 0.2s ease;
}

.ai-input-wrapper:focus-within {
    border-color: #0099ff;
}

#ai-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 13px;
    line-height: 1.5;
    max-height: 100px;
    outline: none;
    font-family: 'Inter', sans-serif;
    color: #4c4d52;
}

#ai-input::placeholder {
    color: #aaa;
}

#ai-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #4c4d52;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

#ai-send-btn:hover {
    background: #0099ff;
    transform: translateY(-1px);
}

#ai-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.ai-powered-by {
    text-align: center;
    font-size: 10px;
    color: #aaa;
    margin: 5px 0 0;
}

/* ── Image dalam chat ── */
.ai-img-wrapper {
    margin: 6px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e5e5;
    background: #f2f2f2;
}

.ai-img {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.ai-img:hover {
    opacity: 0.88;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    #ai-chat-panel {
        width: calc(100vw - 32px);
    }

    #ai-chat-wrapper {
        right: 16px;
        bottom: 16px;
    }
}