#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: 64px;
    height: 62px;
    border-radius: 75%;
    background: var(--aicw-primary, #b3bfda);
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
    align-items: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    animation: aicw-pop-in 0.35s ease;
    padding: 10px;
}
#aicw-toggle-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 28px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.25);
}
@keyframes aicw-pop-in {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
#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: block; }

/* Use these rules for an inline <svg> icon. CSS cannot set an <img> `src`.
   If your icon in the DOM is an inline <svg class="aicw-icon-chat">,
   this will size it and apply the fill color. */
svg.aicw-icon-chat,
#aicw-toggle-btn .aicw-icon-chat svg {
    width: 40px;
    height: 38px;
    fill: #fff;
    align-self: center;
}

/* If you use an <img> element instead of inline SVG, set its `src` in HTML or JS.
   Keep sizing here as a fallback for <img>. */
#aicw-toggle-btn .aicw-icon-chat img {
    width: 40px;
    height: 38px;
    align-self: center;
}
img.aicw-icon-chat{
    width: 48px;
    height: 48px;
    align-self: center;
}
svg.aicw-icon-close {
    width: 40px;
    height: 45px;
    fill: #fff;
    align-self: center;
}

svg {
    width: 25px;
    height: 25px;
    fill: #fff;
    align-self: center;
}

#aicw-chat-panel {
    position: absolute;
    bottom: 76px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: 68vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aicw-panel-in 0.2s ease;
}
@keyframes aicw-panel-in {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.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);
    background-image: linear-gradient(135deg, var(--aicw-primary, #2563eb), color-mix(in srgb, var(--aicw-primary, #2563eb) 70%, #7c3aed));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    position: relative;
}
.aicw-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.aicw-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,0.35);
}
.aicw-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.aicw-avatar-fallback {
    display: block;
}
.aicw-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f59e0b;
    display: inline-block;
    box-shadow: 0 0 0 2.5px rgba(255,255,255,0.5);
}
.aicw-status-dot.aicw-connected { background: #22c55e; }
.aicw-status-dot.aicw-error { background: #ef4444; }

.aicw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(180deg, #f8fafc 0%, #fbfcfe 100%);
}

.aicw-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.aicw-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e8ecf1;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.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;
    }
}
