.autoia-widget-container {
    /* Vars defined inline by PHP */
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* Positioning handled by wrapper */
.autoia-pos-bottom-right {
    bottom: var(--autoia-offset-y, 24px);
    right: var(--autoia-offset-x, 24px);
}

.autoia-pos-bottom-left {
    bottom: var(--autoia-offset-y, 24px);
    left: var(--autoia-offset-x, 24px);
}

.autoia-widget-container.autoia-widget-hidden .autoia-window {
    pointer-events: none;
}

.autoia-trigger-btn {
    background-color: var(--autoia-primary, #5a32fa);
    color: #fff;
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    position: absolute;
    bottom: 0;
}

.autoia-pos-bottom-right .autoia-trigger-btn {
    right: 0;
}

.autoia-pos-bottom-left .autoia-trigger-btn {
    left: 0;
}

.autoia-trigger-btn:hover {
    transform: scale(1.05);
}

/* Launcher Shapes */
.autoia-trigger-btn.circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
}

.autoia-trigger-btn.square {
    width: 60px;
    height: 60px;
    border-radius: 12px;
}

.autoia-trigger-btn.pill {
    height: 52px;
    padding: 0 24px;
    border-radius: 26px;
}

.autoia-trigger-btn i {
    font-size: 24px;
}

/* Main Window */
.autoia-window {
    position: absolute;
    bottom: 80px;
    /* Offset from launcher */
    width: var(--autoia-window-width, 360px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--autoia-body-bg, #fafafa);
    border-radius: var(--autoia-radius-window, 16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.autoia-pos-bottom-right .autoia-window {
    right: 0;
    transform-origin: bottom right;
    transform: translateY(20px) scale(0.95);
}

.autoia-pos-bottom-left .autoia-window {
    left: 0;
    transform-origin: bottom left;
    transform: translateY(20px) scale(0.95);
}

/* Animations - Open State */
.autoia-window.open.autoia-anim-slide {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.autoia-window.open.autoia-anim-pop {
    opacity: 1;
    pointer-events: all;
    animation: autoiaPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.autoia-window.open.autoia-anim-none {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
    transition: none;
}

@keyframes autoiaPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Header */
.autoia-window-header {
    background: var(--autoia-header-bg, #5a32fa);
    color: var(--autoia-header-text, #ffffff);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.autoia-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: inherit;
}

.autoia-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.autoia-close-btn {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 24px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, background-color 0.2s;
}

.autoia-close-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Body / Messages */
.autoia-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: inherit;
}

.autoia-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--autoia-radius-bubble, 12px);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* animation handled by JS when injected */
}

.autoia-anim-pop-bubble {
    animation: popBubble 0.3s ease;
}

.autoia-anim-fade-bubble {
    animation: fadeBubble 0.3s ease;
}

@keyframes popBubble {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeBubble {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.autoia-system {
    background: var(--autoia-bot-bg, #e9e9eb);
    color: var(--autoia-bot-text, #2c3338);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.autoia-system a {
    color: var(--autoia-primary);
    font-weight: 500;
}

.autoia-user {
    background: var(--autoia-user-bg, #5a32fa);
    color: var(--autoia-user-text, #ffffff);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Footer / Input */
.autoia-input-area {
    padding: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

#autoia-chat-form {
    display: flex;
    gap: 8px;
    position: relative;
}

.autoia-input {
    flex: 1;
    padding: 12px 40px 12px 16px;
    border: 1px solid #dcdce0;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s;
}

.autoia-input:focus {
    border-color: var(--autoia-primary);
}

.autoia-send-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--autoia-primary);
    color: #fff;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: filter 0.2s, transform 0.2s;
}

.autoia-send-btn:hover,
.autoia-send-btn:focus {
    filter: brightness(1.1);
}

.autoia-send-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.autoia-footer {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #999;
}

/* Typing Indicator */
.autoia-typing .dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: currentColor;
    opacity: 0.6;
    border-radius: 50%;
    margin-right: 3px;
    animation: blink 1.4s infinite both;
}

.autoia-typing .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.autoia-typing .dot:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

@keyframes blink {
    0% {
        opacity: 0.2;
        transform: scale(0.8);
    }

    20% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.2;
        transform: scale(0.8);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .autoia-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        /* Mobile override - snap to full screen */
        transform-origin: bottom center;
    }

    .autoia-pos-bottom-left .autoia-window,
    .autoia-pos-bottom-right .autoia-window {
        bottom: 0;
        left: 0;
        right: 0;
    }

    .autoia-pos-bottom-right {
        bottom: 16px;
        right: 16px;
    }

    .autoia-pos-bottom-left {
        bottom: 16px;
        left: 16px;
    }
}