#aicw-widget-root {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#aicw-widget-root.aicw-position-bottom-right { right: 20px; }
#aicw-widget-root.aicw-position-bottom-left { left: 20px; }

#aicw-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--aicw-primary, #2563eb);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}
#aicw-toggle-btn:hover { transform: scale(1.06); }
#aicw-toggle-btn .aicw-icon-close { display: none; }
#aicw-toggle-btn.aicw-open .aicw-icon-chat { display: none; }
#aicw-toggle-btn.aicw-open .aicw-icon-close { display: inline; }

#aicw-chat-panel {
    position: absolute;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: 70vh;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.aicw-position-bottom-right #aicw-chat-panel { right: 0; }
.aicw-position-bottom-left #aicw-chat-panel { left: 0; }

#aicw-chat-panel.aicw-hidden { display: none; }

.aicw-header {
    background: var(--aicw-primary, #2563eb);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}
.aicw-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.aicw-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.aicw-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.aicw-avatar-fallback {
    font-size: 16px;
    line-height: 1;
}
.aicw-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f59e0b; /* connecting = amber */
    display: inline-block;
}
.aicw-status-dot.aicw-connected { background: #22c55e; }
.aicw-status-dot.aicw-error { background: #ef4444; }

.aicw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

.aicw-msg {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.aicw-msg-bot {
    align-self: flex-start;
    background: #eef2f7;
    color: #111827;
    border-bottom-left-radius: 4px;
}
.aicw-msg-user {
    align-self: flex-end;
    background: var(--aicw-primary, #2563eb);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.aicw-msg-error {
    align-self: center;
    background: #fee2e2;
    color: #991b1b;
    font-size: 12px;
}

#aicw-typing-indicator {
    padding: 0 16px 6px;
    display: flex;
    gap: 4px;
}
#aicw-typing-indicator.aicw-hidden { display: none; }
#aicw-typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: aicw-bounce 1.2s infinite ease-in-out;
}
#aicw-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
#aicw-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aicw-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.aicw-input-row {
    display: flex;
    border-top: 1px solid #e5e7eb;
    padding: 10px;
    gap: 8px;
    background: #fff;
}
#aicw-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    outline: none;
}
#aicw-input:focus { border-color: var(--aicw-primary, #2563eb); }
#aicw-send-btn {
    background: var(--aicw-primary, #2563eb);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    font-size: 15px;
}
#aicw-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
    #aicw-chat-panel {
        width: calc(100vw - 24px);
        height: 70vh;
        bottom: 76px;
    }
}
