/* --- Theme Variables --- */
:root {
    --primary: #0ea5e9; /* Sky Blue */
    --primary-hover: #0284c7;
    --bg-main: #ffffff;
    --bg-chat: #f8fafc;
    --text-dark: #0f172a;
    --text-light: #ffffff;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

#ai-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Floating Action Button --- */
#ai-widget-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    box-shadow: 0 10px 25px rgba(14, 165, 233, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#ai-widget-toggle:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 14px 30px rgba(14, 165, 233, 0.5);
}

#ai-widget-toggle svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

#ai-widget-container.open #ai-widget-toggle {
    transform: scale(0.8) rotate(90deg);
    opacity: 0;
    pointer-events: none;
}

/* --- The Chat Window --- */
#ai-widget-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    height: 550px;
    background: var(--bg-main);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#ai-widget-window.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* --- Chat Header --- */
.ai-widget-header {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    color: var(--text-light);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 2;
}

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

.ai-header-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.ai-header-status {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    margin-top: 4px;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.ai-widget-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-widget-close:hover {
    background: rgba(255,255,255,0.2);
}

/* --- Chat Messages Area --- */
.ai-widget-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-chat);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.ai-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.ai-msg.user {
    background: var(--primary);
    color: var(--text-light);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-msg.bot {
    background: var(--bg-main);
    color: var(--text-dark);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

/* --- Typing Indicator --- */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
    background: var(--bg-main);
    align-self: flex-start;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

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

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* --- Input Area --- */
.ai-widget-input-area {
    padding: 16px;
    background: var(--bg-main);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
}

#ai-widget-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: var(--bg-chat);
}

#ai-widget-input:focus {
    border-color: var(--primary);
    background: var(--bg-main);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

#ai-widget-submit {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

#ai-widget-submit svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    margin-left: 2px; /* Visual center adjustment */
}

#ai-widget-submit:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: scale(1.05);
}

#ai-widget-submit:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}