.ai-chat-widget {
    --primary-color: #192f59;
    --text-color: #1F2937; /* Warna teks tetap gelap agar mudah dibaca */
    --bg-color: #FFFFFF; /* Latar belakang tetap putih */
    --bot-message-bg: #E0E7FF; /* Warna balon chat bot lebih soft */
    --bot-text-color: var(--text-color);
    --user-text-color: #FFFFFF;
    --bot-link-color: #2563EB; /* Biru lebih pekat untuk link */
    --user-link-color: #FFFFFF;
    font-family: system-ui, -apple-system, sans-serif !important;
}

.ai-chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    padding: 0;
}

.ai-chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: var(--bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
}

.ai-chat-window.active {
    display: flex;
}

.ai-chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-agent-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.ai-chat-agent-name {
    font-weight: 600;
    color: var(--text-color);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Category Selection Styles */
.ai-chat-category-selection {
    border-top: 1px solid #E5E7EB;
    background: #f9fafb;
}

.ai-chat-category-list {
    padding: 12px 16px;
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat-category-item {
    margin-bottom: 0;
}

.category-btn {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: inherit;
}

.category-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-btn:active {
    transform: translateY(0);
}

.category-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    font-size: 14px;
}

.category-description {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
    line-height: 1.3;
}

.category-has-children {
    font-size: 16px;
    color: #6b7280;
    margin-left: 8px;
}

.ai-chat-input {
    padding: 12px;
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#ai-chat-input-field {
    flex: 1;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    padding: 8px 12px;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}

#ai-chat-send {
    background: var(--primary-color);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#ai-chat-send:hover {
    background: #0f1e3d;
}

.ai-chat-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 85%;
}

.ai-chat-message-body {
    display: flex;
    flex-direction: column;
}

.ai-chat-message-agent {
    align-self: flex-start;
}

.ai-chat-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-chat-message-content {
    padding: 8px 12px;
    border-radius: 12px;
    background: #F3F4F6;
    font-size: 14px !important;
    line-height: 1.5 !important;
    word-wrap: break-word;
    color: var(--text-color) !important;
}

.ai-chat-message-user .ai-chat-message-content {
    background: var(--primary-color);
    color: #FFFFFF !important;
}

.ai-chat-reset,
.ai-chat-close {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6B7280;
    transition: all 0.2s ease;
}

.ai-chat-reset:hover {
    background: #F3F4F6;
    color: #1F2937;
}

.ai-chat-close:hover {
    background: #FEE2E2;
    color: #DC2626;
}

/* Avatar styles */
.ai-chat-bubble-avatar,
.ai-chat-header-avatar,
.ai-chat-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.ai-chat-header-avatar {
    width: 32px;
    height: 32px;
}

.ai-chat-message-avatar {
    width: 24px;
    height: 24px;
}

.ai-chat-bubble-avatar-placeholder,
.ai-chat-header-avatar-placeholder,
.ai-chat-message-avatar-placeholder {
    background: #E5E7EB;
    color: #4B5563;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Updated avatar styles */
.ai-chat-message-avatar,
.ai-chat-message-avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Improved user avatar placeholder */
.ai-chat-message-user .ai-chat-message-avatar-placeholder {
    background: #5e6d8a; /* Warna utama biru */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    border: 2px solid #d1d5dd; /* Border biru lebih soft */
    border-radius: 50%; /* Membuat tampilan lebih mirip avatar */
}


/* Hide user avatar on mobile for better space usage */
@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100% - 40px);
        height: calc(100% - 100px);
    }
    .ai-chat-message-user .ai-chat-message-avatar,
    .ai-chat-message-user .ai-chat-message-avatar-placeholder {
        display: none;
    }
    
    .ai-chat-category-list {
        max-height: 150px;
        padding: 10px 12px;
    }
    
    .category-btn {
        padding: 10px 12px;
    }
}

/* Add these new styles */
.ai-chat-message-content a {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Ensure user messages with white text still show properly */
.ai-chat-message-user .ai-chat-message-content a {
    color: white;
}

.ai-chat-powered-by {
    font-size: 12px;
    color: #6B7280;
    text-align: center;
    margin-bottom: 12px;
}

.ai-chat-powered-by a {
    color: var(--primary-color);
    text-decoration: none;
}

.ai-chat-powered-by a:hover {
    text-decoration: underline;
}

/* Ensure links are visible */
.ai-chat-widget .ai-chat-message-content a {
    color: #0000FF !important;
    text-decoration: underline !important;
}

.ai-chat-widget .ai-chat-message-user .ai-chat-message-content a {
    color: #FFFFFF !important;
    text-decoration: underline !important;
}

/* Typing indicator styles */
.ai-chat-typing-indicator {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 85%;
    align-self: flex-start;
    margin-top: 8px;
}

.ai-chat-typing-indicator .ai-chat-message-content {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bot-message-bg);
    border-radius: 12px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #6B7280;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
    opacity: 0.6;
}

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

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

@keyframes typingAnimation {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Error message styles */
.ai-chat-widget .error-message .message-content {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 6px 8px;
    margin: 3px 0;
    font-size: 12px;
    line-height: 1.2;
    max-width: 85%;
    align-self: center;
}

.ai-chat-widget .error-message .error-text {
    margin: 0;
    font-size: 12px;
} 

.ai-chat-message-time-user {
    display: block;
    font-size: 0.65rem;
    color: #888;
    margin-top: 5px;
    text-align: right;
}

.ai-chat-message-time-agent {
    display: block;
    font-size: 0.65rem;
    color: #888;
    margin-top: 5px;
    text-align: left;
}

/* Scrollbar styles for category list */
.ai-chat-category-list::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-category-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ai-chat-category-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ai-chat-category-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}