/* Chatbase Modal CSS */
.chatbase-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbase-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3); /* Dark backdrop */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1;
    /* Fix for Chrome rendering glitch on reopen */
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    will-change: backdrop-filter;
    display: flex;
    justify-content: flex-end; /* Align close button to right */
    align-items: flex-start; /* Align close button to top */
    padding: 20px;
    box-sizing: border-box;
}
.chatbase-disclaimer-text {
    color: black;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.5rem;
    margin: 1rem auto;
    font-size: 1rem;
    border-radius: 10px;
}


.chatbase-modal-content {
    position: relative;
    z-index: 2;
    width: 90%;
    max-width: 800px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    /* content background is transparent, but we need visible overflow for the button */
    background: transparent;
    overflow: visible;
}

.chatbase-close {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 40px;
    height: 40px;
    background: white; /* Or use main color? White is safe on dark backdrop, but maybe we want main color circle? */
    /* User said "circle half outside", implies a background. Let's try main color circle with white X? */
    /* Or White circle with main color X? */
    /* Or just White circle with dark X. */
    /* User manual edit had color:white. */
    /* Let's try White background, black X. Common pattern. */
    background-color: var(--chatbase-main-color, #007bff); 
    color: white;
    border: 2px solid white; /* Optional border to separate from backdrop? */
    border-radius: 50%;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    z-index: 10; /* Above modal content */
    padding: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.chatbase-close:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    .chatbase-close {
        width: 30px;
        height: 30px;
        font-size: 1.2rem;
        top: -15px;
        right: -15px;
    }
}

.chatbase-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center input initially */
    transition: all 0.5s ease;
}

.chatbase-messages {
    flex: 1;
    height: 100%;
    max-height: 80vh;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 20px;
    display: none; /* Hidden initially until first message */
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    font-size: 1rem;
}
.chatbase-messages ul {
    margin: 0.5rem auto;
    padding: 0 0 0 1rem;
}

.chatbase-messages.active {
    display: block;
}

.chatbase-message {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 8px;
    max-width: 80%;
    line-height: 1.2;
}

.chatbase-message.user {
    background-color: var(--chatbase-chat-color, #007bff);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.chatbase-message.assistant {
    background-color: #f1f1f1;
    color: #333;
    align-self: flex-start;
    margin-right: auto;
}

.chatbase-input-wrapper {
    width: 100%;
    transition: all 0.5s ease;
}

.chatbase-modal .chatbase-input-wrapper input#chatbase-input {
    width: 100%;
    padding: 20px;
    font-size: 1.1rem;
    border: 2px solid #ddd;
    border-radius: 50px;
    outline: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: border-color 0.3s;
    background: rgba(255, 255, 255, 0.9);
    margin: 0;
    box-sizing: border-box;
    line-height: normal;
    color: #333;
    height: auto; /* Prevent fixed height from themes */
    appearance: none;
    -webkit-appearance: none;
}

.chatbase-modal .chatbase-input-wrapper input#chatbase-input:focus {
    border-color: var(--chatbase-main-color, #007bff);
}

/* Animation State: When chat is active, move input to bottom */
.chatbase-chat-container.has-messages {
    justify-content: flex-end;
}

.chatbase-modal .chatbase-chat-container.has-messages .chatbase-input-wrapper input#chatbase-input {
    font-size: 1rem;
    padding: 15px;
}

.chatbase-no-scroll {
    overflow: hidden !important;
}

/* Chatbubble */
.chatbase-bubble {
    position: fixed;
    width: 60px;
    height: 60px;
    background-color: var(--chatbase-main-color, #007bff);
    border-radius: 50%;
    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: 99998; /* Just below modal */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chatbase-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.chatbase-bubble svg {
    width: 30px;
    height: 30px;
    fill: white;
}

/* Animation for loading state */
@keyframes chatbase-siri-glow {
    0% {
        box-shadow: 0 0 8px rgba(255, 0, 0, 0.6), inset 0 0 8px rgba(255, 0, 0, 0.1);
        border: 2px solid rgba(255, 0, 0, 0.6);
    }
    20% {
        box-shadow: 0 0 8px rgba(255, 165, 0, 0.6), inset 0 0 8px rgba(255, 165, 0, 0.1);
        border: 2px solid rgba(255, 165, 0, 0.6);
    }
    40% {
        box-shadow: 0 0 8px rgba(255, 255, 0, 0.6), inset 0 0 8px rgba(255, 255, 0, 0.1);
        border: 2px solid rgba(255, 255, 0, 0.6);
    }
    60% {
        box-shadow: 0 0 8px rgba(0, 128, 0, 0.6), inset 0 0 8px rgba(0, 128, 0, 0.1);
        border: 2px solid rgba(0, 128, 0, 0.6);
    }
    80% {
        box-shadow: 0 0 8px rgba(0, 0, 255, 0.6), inset 0 0 8px rgba(0, 0, 255, 0.1);
        border: 2px solid rgba(0, 0, 255, 0.6);
    }
    100% {
        box-shadow: 0 0 8px rgba(238, 130, 238, 0.6), inset 0 0 8px rgba(238, 130, 238, 0.1);
        border: 2px solid rgba(238, 130, 238, 0.6);
    }
}

.chatbase-messages.loading-response {
    animation: chatbase-siri-glow 2s linear infinite alternate;
    transition: all 0.3s ease;
}