/* --- Floating Container --- */
.wpllm-floating-container {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* Force container size to button size, but allow overflow for the chatbox */
    width: 60px;
    height: 60px;
    overflow: visible; 
}

/* --- Toggle Button Fixes --- */
#wpllm-toggle-btn {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    border-radius: 50% !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #0073aa; /* Fallback */
    color: white; /* Fallback */
}

#wpllm-toggle-btn:hover {
    transform: scale(1.05);
}

#wpllm-toggle-btn svg {
    width: 30px;
    height: 30px;
    display: block;
    fill: currentColor; /* Inherits text color */
}

/* --- Chat Box (Floating) --- */
.wpllm-floating-container .wpllm-chat-box {
    position: absolute;
    bottom: 75px; /* Sits above the button */
    right: 0; /* Anchors to the right edge of the container */
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

/* If position is left, we override via JS/Inline style, but here is default behavior */

.wpllm-floating-container .wpllm-chat-box:not(.wpllm-hidden) {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

/* --- Header & Content --- */
.wpllm-header {
    background: #f1f1f1;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
    color: #333;
}

.wpllm-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #666;
}

.wpllm-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #fff;
    font-size: 14px;
    line-height: 1.5;
}

/* Messages Bubbles */
.wpllm-msg {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
}
.wpllm-msg.user {
    background: #0073aa; 
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 2px;
}
.wpllm-msg.bot {
    background: #f0f0f0;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 2px;
}
.wpllm-msg.bot a {
    color: #0073aa;
    font-weight: bold;
    text-decoration: underline;
}
.wpllm-msg.bot ul { margin: 5px 0 5px 20px; padding: 0; }

/* Input Area */
.wpllm-input-area {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    background: #fff;
}
.wpllm-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 20px;
    outline: none;
}
.wpllm-send {
    background: #0073aa;
    color: white;
    border: none;
    padding: 0 20px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Spinner */
.wpllm-btn-loading { opacity: 0.8; pointer-events: none; }
.wpllm-btn-loading::after {
    content: "";
    width: 16px; height: 16px;
    border: 2px solid #ffffff; border-top-color: transparent;
    border-radius: 50%;
    animation: wpllm-spin 0.8s linear infinite;
    display: block;
}
.wpllm-btn-loading span { display: none; }
@keyframes wpllm-spin { to { transform: rotate(360deg); } }

/* Typing Bubbles */
.wpllm-typing {
    display: inline-flex; gap: 6px; padding: 12px 18px;
    background: #f0f0f0; border-radius: 12px;
}
.wpllm-dot {
    width: 8px; height: 8px; background: #999; border-radius: 50%;
    animation: wpllm-bounce 1.4s infinite ease-in-out both;
}
.wpllm-dot:nth-child(1) { animation-delay: -0.32s; }
.wpllm-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes wpllm-bounce { 0%,80%,100% {transform:scale(0);opacity:0.5;} 40% {transform:scale(1);opacity:1;} }

/* --- Inline Shortcode Mode --- */
.wpllm-inline-container .wpllm-chat-box {
    position: relative;
    width: 100%;
    height: 500px;
    box-shadow: none;
    opacity: 1;
    pointer-events: all;
    transform: none;
}
.wpllm-inline-mode .wpllm-close { display: none; }