/* Chat Container */
.ai-chatbot-chat {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 600px;
}

/* Chat Header */
.ai-chatbot-chat-header {
    padding: 1rem;
    background: #2271b1;
    color: #fff;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E7E7E7;
}
.ai-chatbot-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-chatbot-chat-avatar{
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ai-chatbot-avatar-img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    max-width: 20px;
}

.ai-chatbot-chat-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333333;
}

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

.ai-chatbot-chat-actions button {
    background: transparent;
    border: none;
    color: #888888;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    font-size: 1.2rem;
    transition: background-color 0.2s;
}

.ai-chatbot-chat-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Messages */
.ai-chatbot-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-chatbot-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.ai-chatbot-message:last-child{
    margin-bottom: 10px;
}

.ai-chatbot-message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.ai-chatbot-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-avatar {
    background: #2271b1;
    color: #fff;
}

.ai-chatbot-message-content {
    background: #f0f0f0;
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
    border-radius: 20px;
}

.ai-chatbot-message.user .ai-chatbot-message-content {
    background: #f0f0f0;
    border-radius: 20px;
    position: relative;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content {
    border: 1px solid #DCDCDC;
}

.ai-chatbot-message-text {
    margin: 0;
    line-height: 1.5;
}

/* Generation state (covers both pending + active streaming) */
.ai-chatbot-message.assistant.generating .ai-chatbot-message-content {
    min-width: 80px; /* ensure bubble renders even before text */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 18px;
    min-height: 36px;
}
.ai-chatbot-message.assistant.generating .stream-text:empty::before { content: '\00a0'; }

.ai-chatbot-message-metadata {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.ai-chatbot-message.user .ai-chatbot-message-metadata {
    color: rgba(255, 255, 255, 0.8);
}

/* Sources and Citations */
.ai-chatbot-message-sources {
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

.ai-chatbot-source-link {
    display: inline-block;
    margin-right: 10px;
    color: #2271b1;
    text-decoration: none;
}

.ai-chatbot-source-link:hover {
    text-decoration: underline;
}

/* Chat Input */
.ai-chatbot-chat-input {
    display: flex;
    padding: 1rem;
    gap: 0.5rem;
}

.ai-chatbot-input-form {
    display: flex;
    gap: 10px;
    /* border: 1px solid #e5e5e5; */
    border-radius: 4px;
}

.ai-chatbot-input {
    flex: 1;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem !important;
    padding: 0.5rem 0.875rem !important;
    box-shadow: 2px 2px 10px 0px #00000026;
    line-height: 2;
    min-height: 30px;
}

.ai-chatbot-input:focus {
    outline: none;
    /* border-color: #2271b1; */
    /* box-shadow: 0 0 0 1px #2271b1; */
}

.ai-chatbot-send-button {
    background-color: #008858;
    color: white;
    border: none;
    padding: 0 1rem;
    border-radius: 0.5rem;
}

.ai-chatbot-send-button:hover {
    background-color: #e1ebff;
    color: #00FFA5;
}

.ai-chatbot-send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Loading States */
/* Unified subtle dot pulse typing indicator (used pre-response and during streaming) */
.ai-chatbot-typing {
    display: inline-flex;
    gap: 4px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    width: auto;
    vertical-align: baseline;
}
.ai-chatbot-typing span {
    width: 5px;
    height: 5px;
    background: #aaa;
    border-radius: 50%;
    animation: stream-pulse 1s infinite ease-in-out;
}
.ai-chatbot-typing span:nth-child(2) { animation-delay: .2s; }
.ai-chatbot-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes stream-pulse { 0%,100% { opacity:.25; transform: scale(.7);} 50% { opacity:.9; transform: scale(1);} }

/* Spacing between streamed text and spinner (shared) */
.ai-chatbot-message.assistant.generating .stream-text { margin-right: 6px; display:inline-block; min-width:2px; }
.ai-chatbot-message.assistant.generating .ai-chatbot-typing { margin-left: 2px; position: relative; top: 0; }

/* When still pending (no response id yet) allow centering if empty */
.ai-chatbot-message.assistant.generating.is-pending .ai-chatbot-message-content { justify-content: center; }
.ai-chatbot-message.assistant.generating.is-pending .ai-chatbot-message-text { display:flex; align-items:center; gap:6px; }

/* Code Blocks */
.ai-chatbot-message pre {
    background: #f8f8f8;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
}

.ai-chatbot-message code {
    font-family: monospace;
    font-size: 14px;
    line-height: 1.4;
}

/* Markdown Styling */
.ai-chatbot-message-text p {
    margin: 0 0 10px;
}

.ai-chatbot-message-text p:last-child {
    margin-bottom: 0;
}

.ai-chatbot-message-text ul,
.ai-chatbot-message-text ol {
    margin: 10px 0;
    padding-left: 20px;
}

.ai-chatbot-message-text a {
    color: #2271b1;
    text-decoration: none;
}

.ai-chatbot-message-text a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media screen and (max-width: 782px) {

    .ai-chatbot-chat-header {
        border-radius: 0;
    }

    .ai-chatbot-message {
        max-width: 90%;
    }

    .ai-chatbot-input-form {
        flex-direction: column;
    }

    .ai-chatbot-send-button {
        height: 44px;
    }
}

/* Widget Specific Styles */
.ai-chatbot-widget {
    position: fixed;
    bottom: 80px;
    z-index: 9999;
    width: 424px;
    height: calc( 100% - 120px );
    box-shadow: 0 5px 20px rgb(15 15 15 / 16%);
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.3s ease-in-out;
}

/* Widget Container */
.ai-chatbot-widget-container {
    position: fixed;
    z-index: 9999;
    width: 424px;
    height: calc( 100% - 120px );
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    transform: translateY(0) scale(1);
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);

}

.ai-chatbot-widget.minimized {
    transform: translateY(calc(100% - 50px));
}

.ai-chatbot-widget .ai-chatbot-chat {
    height: 100%;
    max-width: 100%;
    border-radius: 1rem;
}

/* Widget Button Styles */
.ai-chatbot-widget-button {
    position: fixed;
    width: 55px;
    height: 55px;
    bottom: 1rem;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFFFFF;
    color: #333;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-shadow: none;
}

.ai-chatbot-widget-button:hover {
    background: #F5F5F5;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.ai-chatbot-widget-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.ai-chatbot-widget-button:focus{
    outline: none;
}

.ai-chatbot-widget-button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.ai-chatbot-widget-button:hover .ai-chatbot-widget-button-icon {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.ai-chatbot-widget-button .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    transition: transform 0.3s ease;
}

.ai-chatbot-widget-button:hover .dashicons {
    transform: rotate(-5deg);
}

.ai-chatbot-widget.minimized {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Mobile Styles */
@media screen and (max-width: 782px) {
    .ai-chatbot-widget-button {
        padding: 16px;
        border-radius: 28px;
    }

    .ai-chatbot-widget-button-text {
        display: none;
    }

    .ai-chatbot-widget-button-icon {
        margin: 0;
        padding: 4px;
    }

    .ai-chatbot-widget.minimized {
        transform: translateY(40px) scale(0.9);
    }
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.ai-chatbot-widget-button:not(:hover) {
    animation: pulse 2s infinite;
}

/* RTL Support */
.rtl .ai-chatbot-widget-button {
    flex-direction: row-reverse;
}

.rtl .ai-chatbot-widget {
    direction: rtl;
}

.ai-chatbot-bottom-left{
    left: 1rem;
}
.ai-chatbot-bottom-right{
    right: 1rem;
}
.ai-chatbot-message-feedback{
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    position: absolute;
    bottom: 0;
    right: 15px;
    border-radius: 10px;
    padding: 5px;
    background-color: #eaeaea;
    transform: translateY(50%);
}

.ai-chatbot-message-feedback i{
    cursor: pointer;
}
.ai-chatbot-message-feedback i:hover{
    color: #0051F9;
}

.ai-chatbot-chat-footer{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px;
    background-color: #f0f0f0;
}

.ai-chatbot-chat-footer-left{
    font-size: 12px;
    color: #71717A;
}

.ai-chatbot-chat-footer-right{
    font-size: 12px;
    color: #71717A;
}
.ai-chatbot-message.user .ai-chatbot-message-feedback{
    display: none;
}

/* Rate Limit Styling */
.ai-chatbot-input-container.rate-limited {
    position: relative;
    border: 1px solid #e74c3c;
    border-radius: 4px;
    padding-top: 30px;
}

.rate-limit-warning {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: #e74c3c;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    text-align: center;
    border-radius: 4px 4px 0 0;
}

.ai-chatbot-error {
    background-color: #fff3f3;
    border-left: 4px solid #e74c3c;
    padding: 10px;
    margin-bottom: 10px;
    color: #333;
}

.ai-chatbot-message.system {
    width: 100%;
    max-width: 100%;
    margin: 10px 0;
}

.ai-chatbot-message.system .ai-chatbot-message-content {
    width: 100%;
    background-color: #f8f8f8;
    border: 1px solid #e5e5e5;
}





