/*
 * Zibll AI Assistant Chat Widget Stylesheet
 */

/* 1. Floating Bubble Button */
#zib-ai-bubble {
    position: fixed;
    bottom: 25px;
    right: 90px; /* Dịch sang trái để tránh đè lên thanh công cụ Zibll */
    width: 50px;  /* Thu nhỏ kích thước bong bóng */
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--theme-color, #f04494) 0%, var(--theme-color-90, #d0307c) 100%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

#zib-ai-bubble:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

#zib-ai-bubble svg {
    width: 24px;  /* Tỉ lệ vừa vặn với nút 50px */
    height: 24px;
    fill: #ffffff;
    transition: transform 0.3s ease;
}

/* 2. Main Chat Box Container */
#zib-ai-chatbox {
    position: fixed;
    bottom: 85px; /* Giảm khoảng cách để mở khít với nút bong bóng mới */
    right: 25px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 120px);
    max-width: calc(100vw - 50px);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#zib-ai-chatbox.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* 3. Header Styling */
.zib-ai-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--theme-color, #f04494) 0%, var(--theme-color-90, #d0307c) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.zib-ai-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zib-ai-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    object-fit: cover;
}

.zib-ai-header-title {
    display: flex;
    flex-direction: column;
}

.zib-ai-header-name {
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.zib-ai-header-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.zib-ai-status-dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #4ade80;
    animation: status-pulse 2s infinite;
}

.zib-ai-close-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.2s ease, transform 0.2s ease;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zib-ai-close-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* 4. Messages Screen Area */
.zib-ai-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    -ms-overflow-style: none;
    scrollbar-width: thin;
}

.zib-ai-messages::-webkit-scrollbar {
    width: 6px;
}
.zib-ai-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 10px;
}
.zib-ai-messages::-webkit-scrollbar-thumb {
    background: var(--theme-color, #f04494);
    border-radius: 10px;
    opacity: 0.8;
}

/* Message Bubble */
.zib-ai-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 85%;
}

.zib-ai-msg-row.user {
    align-self: flex-end;
    justify-content: flex-end;
}

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

.zib-ai-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.zib-ai-msg-row.user .zib-ai-msg-bubble {
    background: var(--theme-color, #f04494);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(240, 68, 148, 0.2);
}

.zib-ai-msg-row.bot .zib-ai-msg-bubble {
    background: rgba(0, 0, 0, 0.05);
    color: #2d3748;
    border-bottom-left-radius: 4px;
}

/* Link and markdown formatting inside chatbot bubble */
.zib-ai-msg-bubble a {
    color: var(--theme-color, #f04494);
    font-weight: 700;
    text-decoration: underline;
}

.zib-ai-msg-bubble a:hover {
    opacity: 0.85;
}

.zib-ai-msg-bubble p {
    margin: 0 0 8px 0;
}
.zib-ai-msg-bubble p:last-child {
    margin-bottom: 0;
}
.zib-ai-msg-bubble ul, .zib-ai-msg-bubble ol {
    margin: 5px 0;
    padding-left: 20px;
}

/* Bot Mini Avatar beside bubble */
.zib-ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 4px;
}

/* 5. Typing Indicator */
.zib-ai-typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
}

.zib-ai-dot {
    width: 6px;
    height: 6px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 50%;
    animation: typing-jump 1.4s infinite ease-in-out both;
}

.zib-ai-dot:nth-child(1) { animation-delay: -0.32s; }
.zib-ai-dot:nth-child(2) { animation-delay: -0.16s; }

/* 6. Chat Input Area (Footer) */
.zib-ai-input-area {
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.6);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.zib-ai-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 13.5px;
    outline: none;
    color: #2d3748;
}

.zib-ai-send-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--theme-color, #f04494);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    opacity: 0.85;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.zib-ai-send-btn:hover {
    opacity: 1;
    transform: scale(1.08);
}

.zib-ai-send-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* 7. Zibll Dark Theme Support */
body.dark-theme #zib-ai-chatbox,
.dark-theme #zib-ai-chatbox {
    background: rgba(30, 30, 36, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

body.dark-theme .zib-ai-messages::-webkit-scrollbar-track,
.dark-theme .zib-ai-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

body.dark-theme .zib-ai-messages::-webkit-scrollbar-thumb,
.dark-theme .zib-ai-messages::-webkit-scrollbar-thumb {
    background: var(--theme-color, #f04494);
}

body.dark-theme .zib-ai-msg-row.bot .zib-ai-msg-bubble,
.dark-theme .zib-ai-msg-row.bot .zib-ai-msg-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

body.dark-theme .zib-ai-input-area,
.dark-theme .zib-ai-input-area {
    background: rgba(0, 0, 0, 0.25);
    border-top-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .zib-ai-input,
.dark-theme .zib-ai-input {
    color: #e2e8f0;
}

body.dark-theme .zib-ai-dot,
.dark-theme .zib-ai-dot {
    background: rgba(255, 255, 255, 0.5);
}

/* Animations */
@keyframes status-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

@keyframes typing-jump {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}
