/* ==========================================================================
   LEGION ARENA | AI CUSTOMER SUPPORT WIDGET (ELENA)
   Military-Grade Glassmorphism Dark UI
   ========================================================================== */

#legion-ai-widget-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
    user-select: none;
}

/* Floating Launcher Trigger */
.legion-ai-launcher {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 229, 255, 0.35), 0 0 15px rgba(245, 158, 11, 0.3);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: linear-gradient(135deg, #0f172a 0%, #030712 100%);
    border: 2px solid #00e5ff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legion-ai-launcher:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 229, 255, 0.5), 0 0 25px rgba(245, 158, 11, 0.45);
    border-color: #ffd700;
}

.legion-ai-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    pointer-events: none;
}

/* Status Indicator Dot */
.legion-ai-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 2.5px solid #0b0f19;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Proactive Speech Bubble */
.legion-ai-teaser {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 290px;
    background: rgba(13, 18, 30, 0.96);
    border: 1.5px solid rgba(0, 229, 255, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px 16px 4px 16px;
    padding: 14px 16px;
    color: #f1f5f9;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 229, 255, 0.15);
    display: none;
    animation: slideUpTeaser 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
    cursor: pointer;
}

@keyframes slideUpTeaser {
    from { opacity: 0; transform: translateY(12px) scale(0.92); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.legion-ai-teaser-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    color: #94a3b8;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.legion-ai-teaser-close:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

.legion-ai-teaser-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.legion-ai-teaser-name {
    font-weight: 800;
    font-size: 13px;
    color: #00e5ff;
    letter-spacing: 0.3px;
}

.legion-ai-teaser-body {
    font-size: 12.5px;
    color: #cbd5e1;
    line-height: 1.45;
}

.legion-ai-teaser-cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 700;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Chat Dialog Window */
.legion-ai-window {
    position: absolute;
    bottom: 84px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: rgba(10, 14, 23, 0.97);
    border: 1.5px solid rgba(0, 229, 255, 0.35);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 229, 255, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: windowPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

@keyframes windowPop {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Chat Header */
.legion-ai-header {
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.95) 0%, rgba(13, 18, 30, 0.9) 100%);
    border-bottom: 1px solid rgba(0, 229, 255, 0.2);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.legion-ai-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legion-ai-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid #00e5ff;
    object-fit: cover;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.legion-ai-header-title {
    font-weight: 800;
    font-size: 14px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.legion-ai-header-subtitle {
    font-size: 11px;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.legion-ai-header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legion-ai-btn-ctrl {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.legion-ai-btn-ctrl:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: #ef4444;
}

/* Suggestion Pills Bar */
.legion-ai-suggestions {
    background: rgba(15, 23, 42, 0.5);
    padding: 8px 14px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    scrollbar-width: none;
}

.legion-ai-suggestions::-webkit-scrollbar {
    display: none;
}

.legion-ai-pill {
    white-space: nowrap;
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.25);
    color: #00e5ff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.legion-ai-pill:hover {
    background: rgba(0, 229, 255, 0.2);
    border-color: #00e5ff;
    color: #fff;
    transform: translateY(-1px);
}

/* Chat Messages Container */
.legion-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    user-select: text;
}

.legion-ai-messages::-webkit-scrollbar {
    width: 5px;
}

.legion-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.legion-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Message Bubbles */
.legion-ai-msg {
    display: flex;
    gap: 8px;
    max-width: 90%;
    animation: fadeInMsg 0.2s ease-out;
}

@keyframes fadeInMsg {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.legion-ai-msg.bot {
    align-self: flex-start;
}

.legion-ai-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.legion-ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #00e5ff;
}

.legion-ai-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.legion-ai-msg.bot .legion-ai-msg-bubble {
    background: rgba(19, 27, 43, 0.95);
    border: 1px solid rgba(0, 229, 255, 0.2);
    color: #e2e8f0;
    border-top-left-radius: 2px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.legion-ai-msg.bot .legion-ai-msg-bubble a {
    color: #00e5ff;
    text-decoration: underline;
    font-weight: 700;
}

.legion-ai-msg.bot .legion-ai-msg-bubble code {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: #ffd700;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.legion-ai-msg.user .legion-ai-msg-bubble {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
    border-top-right-radius: 2px;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.25);
    font-weight: 500;
}

.legion-ai-msg-time {
    font-size: 9.5px;
    color: #64748b;
    margin-top: 4px;
    text-align: right;
}

/* Typing Indicator Animation */
.legion-ai-typing {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(19, 27, 43, 0.8);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: 12px;
    width: fit-content;
    border-top-left-radius: 2px;
}

.legion-ai-typing-dot {
    width: 6px;
    height: 6px;
    background: #00e5ff;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

/* Chat Input Bar */
.legion-ai-footer {
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 8px;
    align-items: center;
}

.legion-ai-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 10px 14px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.legion-ai-input:focus {
    border-color: #00e5ff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
    background: rgba(0, 0, 0, 0.55);
}

.legion-ai-btn-send {
    background: linear-gradient(135deg, #00e5ff 0%, #0284c7 100%);
    border: none;
    color: #000;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.3);
}

.legion-ai-btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(0, 229, 255, 0.5);
    background: linear-gradient(135deg, #ffd700 0%, #f59e0b 100%);
}

.legion-ai-btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #legion-ai-widget-root {
        bottom: 16px;
        right: 16px;
    }
    .legion-ai-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 85vh;
        max-width: 100vw;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
    }
    .legion-ai-teaser {
        width: calc(100vw - 32px);
        right: 0;
    }
}
