.lab-chatbot-widget {
    position: fixed;
    bottom: 80px;
    right: 10px;
    z-index: 9999; /* Increased z-index to ensure it's above other elements */
    font-family: 'Almarai', sans-serif;
}

.lab-chatbot-widget--rtl {
    left: 10px;
    right: auto;
}

.lab-chatbot-widget__toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #5e72e4;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    z-index: 10000; /* Ensure toggle button is always visible */
}

.lab-chatbot-widget__toggle:hover {
    transform: scale(1.05);
    background-color: #324cdd;
}

.lab-chatbot-widget__toggle--active {
    transform: scale(1.1);
    background-color: #324cdd;
}

.lab-chatbot-widget__window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 500px;
    height: 600px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.9);
    z-index: 9999; /* High z-index */
}

/* Fullscreen mode styles */
.lab-chatbot-widget__window--fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 80%;
    max-width: 900px;
    height: 80vh;
    margin: auto;
    transform: none !important; /* Remove transform that's causing issues */
    z-index: 10001; /* Ensure high z-index for fullscreen */
}
@media (min-width: 768px) {
    .lab-chatbot-widget__window--fullscreen {
        top: 10vh;
        left: 0;
        right: 0;
        margin-left: auto;
        margin-right: auto;
    }
}
.lab-chatbot-widget--rtl .lab-chatbot-widget__window {
    right: auto;
    left: 0;
}

.lab-chatbot-widget__window--expanded {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.lab-chatbot-widget__header {
    background-color: #5e72e4;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    z-index: 10; /* Ensure header is above content */
}

.lab-chatbot-widget__avatar {
    width: 38px;
    height: 38px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.lab-chatbot-widget__actions {
    display: flex;
}

.lab-chatbot-widget__messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f5f7fb;
}

/* Improved markdown rendering styles */
.lab-chatbot-widget__message-content ul, 
.lab-chatbot-widget__message-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.lab-chatbot-widget__message-content ul li, 
.lab-chatbot-widget__message-content ol li {
    margin-bottom: 4px;
}

.lab-chatbot-widget__message-content strong,
.lab-chatbot-widget__message-content b {
    font-weight: 700;
}

.lab-chatbot-widget__message-content em,
.lab-chatbot-widget__message-content i {
    font-style: italic;
}

.lab-chatbot-widget__message-content a {
    color: #5e72e4;
    text-decoration: underline;
}

.lab-chatbot-widget__message-content code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.lab-chatbot-widget__message-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

.lab-chatbot-widget__message-content h1,
.lab-chatbot-widget__message-content h2,
.lab-chatbot-widget__message-content h3,
.lab-chatbot-widget__message-content h4,
.lab-chatbot-widget__message-content h5,
.lab-chatbot-widget__message-content h6 {
    margin-top: 10px;
    margin-bottom: 5px;
    line-height: 1.2;
}

.lab-chatbot-widget__message-content p {
    margin: 8px 0;
}

.lab-chatbot-widget__message--user .lab-chatbot-widget__message-content a,
.lab-chatbot-widget__message--user .lab-chatbot-widget__message-content code {
    color: rgba(255, 255, 255, 0.9);
}

.lab-chatbot-widget__conversation-list {
    max-height: 180px;
    overflow-y: auto;
    background-color: #f0f2f5;
    border-bottom: 1px solid #e0e0e0;
    padding: 10px 0;
}

.lab-chatbot-widget__conversation-item {
    padding: 8px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lab-chatbot-widget__conversation-item:hover {
    background-color: #e6e9f0;
}

.lab-chatbot-widget__conversation-item--active {
    background-color: #e3e7f1;
    border-left: 3px solid #5e72e4;
}

.lab-chatbot-widget__conversation-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 250px;
}

.lab-chatbot-widget__conversation-date {
    font-size: 11px;
    color: #888;
}

.lab-chatbot-widget__message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.lab-chatbot-widget__message--user {
    align-items: flex-end;
}

.lab-chatbot-widget__message--bot {
    align-items: flex-start;
}

.lab-chatbot-widget__message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    overflow-wrap: break-word;
}

.lab-chatbot-widget__message--user .lab-chatbot-widget__message-content {
    background-color: #5e72e4;
    color: white;
    border-bottom-right-radius: 4px;
}

.lab-chatbot-widget__message--bot .lab-chatbot-widget__message-content {
    background-color: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.lab-chatbot-widget__message-time {
    font-size: 11px;
    margin-top: 5px;
    color: #888;
}

.lab-chatbot-widget__input {
    padding: 15px;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
}

.lab-chatbot-widget__input-textarea {
    width: 100%;
    border: 1px solid #dce1eb;
    border-radius: 24px;
    padding: 12px 20px;
    resize: none;
    font-family: 'Almarai', sans-serif;
    font-size: 14px;
    outline: none !important;
    box-shadow: none !important;
    transition: border-color 0.3s ease;
    max-height: 120px;
    overflow-y: auto;
}

.lab-chatbot-widget__input-textarea:focus {
    border-color: #5e72e4;
}

.lab-chatbot-widget__input-button {
    background-color: transparent;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lab-chatbot-widget__input-button:hover {
    background-color: #f0f2f7;
}

.lab-chatbot-widget__typing-indicator {
    display: flex;
    padding: 10px 16px;
    background-color: white;
    border-radius: 18px;
    border: 1px solid #e0e0e0;
    align-self: flex-start;
    margin-bottom: 15px;
}

.lab-chatbot-widget__typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #b6b9c1;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: typing-dot 1.4s infinite ease-in-out both;
}

.lab-chatbot-widget__typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.lab-chatbot-widget__typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

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

.lab-chatbot-widget__controls {
    display: flex;
    justify-content: space-between;
    padding: 0 15px 5px;
}

.lab-chatbot-widget__control-button {
    background-color: transparent;
    border: none;
    color: #5e72e4;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 5px 10px;
    border-radius: 4px;
}

.lab-chatbot-widget__control-button:hover {
    color: #324cdd;
    background-color: #f0f2f7;
}

.lab-chatbot-widget__empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
    color: #888;
}

.lab-chatbot-widget__empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    color: #b6b9c1;
}

.lab-chatbot-widget__empty-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 5px;
    color: #444;
}

.lab-chatbot-widget__empty-text {
    font-size: 14px;
    max-width: 250px;
    line-height: 1.5;
}

/* Add styles for fullscreen backdrop */
.lab-chatbot-widget__backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998; /* Just below the fullscreen window */
    display: none;
}

.lab-chatbot-widget__backdrop--visible {
    display: block;
}

/* Style for the streaming message */
.lab-chatbot-widget__message-text {
    min-height: 20px;
}

/* Add a blinking cursor effect to the end of streaming messages */
.lab-chatbot-widget__message--streaming .lab-chatbot-widget__message-text::after {
    content: '|';
    display: inline-block;
    opacity: 1;
    animation: blink 0.7s infinite;
    font-weight: 400;
    color: #333;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}