#archon-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 30px;
    width: 380px;
    max-height: 600px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    z-index: 99999;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: none;
    /* Interactable only when active class added or logic changes display */
}

#archon-chat-widget.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

#archon-chat-launcher {
    position: fixed;
    bottom: 30px;
    right: 80px;
    width: 60px;
    height: 60px;
    background: #0073aa;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 115, 170, 0.4);
    cursor: pointer;
    z-index: 2147483647;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    bottom: 30px !important;
    right: 80px !important;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background-color 0.3s;
}

#archon-chat-launcher:hover {
    transform: scale(1.1);
    background-color: #005a87;
}

#archon-chat-launcher img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Or cover, depending on image shape */
    display: block;
    /* Removes inline gap */
}

#archon-chat-launcher svg {
    fill: #fff;
    cursor: pointer;
}

#archon-chat-header {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: #fff;
    padding: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.archon-chat-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    object-fit: cover;
}

.archon-chat-header-title {
    flex-grow: 1;
    font-size: 16px;
}

#archon-chat-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

#archon-chat-close:hover {
    color: #fff;
}

#archon-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fdfdfd;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.archon-message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
}

.archon-message-content ul,
.archon-message-content ol {
    margin: 10px 0 10px 20px;
    padding-left: 0;
}

.archon-message-content li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.archon-message-content a {
    color: #0073aa;
    text-decoration: underline;
    font-weight: 500;
}

.archon-message-content a:hover {
    color: #005a87;
}

.archon-message.bot {
    align-self: flex-start;
    display: flex;
    align-items: flex-end;
    /* Align avatar at bottom if we wrap it, or top? Let's assume standard bubble */
    max-width: 90%;
}

.archon-message.bot .archon-bot-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
    object-fit: cover;
}

.archon-message-content {
    background: #f0f2f5;
    color: #333;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 2px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.archon-message.user {
    background: #0073aa;
    color: #fff;
    align-self: flex-end;
    margin-left: auto;
    border-radius: 18px 18px 2px 18px;
    padding: 12px 16px;
    box-shadow: 0 2px 4px rgba(0, 115, 170, 0.2);
}

/* Typing Indicator */
#archon-typing-indicator {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
}

.archon-dot {
    width: 6px;
    height: 6px;
    background: #bbb;
    border-radius: 50%;
    animation: archonTyping 1.4s infinite ease-in-out both;
}

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

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

@keyframes archonTyping {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

#archon-chat-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
}

#archon-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    outline: none;
    font-size: 14px;
}

#archon-chat-send {
    background: #0073aa;
    color: #fff;
    border: none;
    padding: 8px 16px;
    margin-left: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

#archon-chat-send:disabled {
    background: #ccc;
}

.archon-loading {
    font-style: italic;
    color: #888;
    margin-bottom: 15px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #archon-chat-widget {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        bottom: 0px !important;
        right: 0px !important;
        top: 0px !important;
        border-radius: 0;
        z-index: 2147483648;
        /* Top of everything */
    }

    #archon-chat-launcher {
        bottom: 20px !important;
        right: 20px !important;
    }

    #archon-chat-messages {
        height: calc(100vh - 110px);
        /* fallback */
    }
}