/* Morgana Chat Styles */

:root {
    --primary-color: #8b5cf6;
    --primary-dark: #6d28d9;
    --secondary-color: #ec4899;
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    -webkit-font-smoothing: antialiased;
    background: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.chat-header {
    background: var(--surface-color);
    padding: 20px 24px;
    border-bottom: 1px solid var(--surface-light);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-avatar-wrapper {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
}

.header-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 2;
}

.header-avatar-wrapper.sending.morgana .header-avatar {
    animation: avatarPulseMorgana 1.5s ease-in-out infinite;
}

.header-avatar-wrapper.sending.agent .header-avatar {
    animation: avatarPulseAgent 1.5s ease-in-out infinite;
}

@keyframes avatarPulseMorgana {
    0%, 100% {
        transform: scale(1);
        box-shadow:
                0 0 40px rgba(139, 92, 246, 0.8),
                0 0 80px rgba(139, 92, 246, 0.4);
    }
    50% {
        transform: scale(1.08);
        box-shadow:
                0 0 60px rgba(167, 139, 250, 1),
                0 0 120px rgba(167, 139, 250, 0.6);
    }
}

@keyframes avatarPulseAgent {
    0%, 100% {
        transform: scale(1);
        box-shadow:
                0 0 40px rgba(236, 72, 153, 0.8),
                0 0 80px rgba(236, 72, 153, 0.4);
    }
    50% {
        transform: scale(1.08);
        box-shadow:
                0 0 60px rgba(244, 114, 182, 1),
                0 0 120px rgba(244, 114, 182, 0.6);
    }
}

.header-avatar-wrapper .magic-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 74px;
    height: 74px;
    border-radius: 50%;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
    filter: blur(6px);
    pointer-events: none;
}

.header-avatar-wrapper.sending.morgana .magic-glow {
    background: radial-gradient(circle,
    rgba(167, 139, 250, 0.6) 0%,
    rgba(139, 92, 246, 0.4) 40%,
    transparent 70%);
    opacity: 1;
    animation: glowPulseMorgana 1.5s ease-in-out infinite;
}

.header-avatar-wrapper.sending.agent .magic-glow {
    background: radial-gradient(circle,
    rgba(244, 114, 182, 0.6) 0%,
    rgba(236, 72, 153, 0.4) 40%,
    transparent 70%);
    opacity: 1;
    animation: glowPulseAgent 1.5s ease-in-out infinite;
}

@keyframes glowPulseMorgana {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.6);
        opacity: 1;
    }
}

@keyframes glowPulseAgent {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.6);
        opacity: 1;
    }
}

.header-avatar-wrapper .magic-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 84px;
    height: 84px;
    border: 2px solid transparent;
    border-radius: 50%;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
}

.header-avatar-wrapper.sending.morgana .magic-ring {
    opacity: 1;
    animation: ringExpandMorgana 2s ease-out infinite;
}

.header-avatar-wrapper.sending.agent .magic-ring {
    opacity: 1;
    animation: ringExpandAgent 2s ease-out infinite;
}

@keyframes ringExpandMorgana {
    0% {
        transform: translate(-50%, -50%) scale(0.8) rotate(0deg);
        opacity: 0;
        border-color: rgba(167, 139, 250, 0.8);
    }
    50% {
        opacity: 0.6;
        border-color: rgba(139, 92, 246, 0.6);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.4) rotate(180deg);
        opacity: 0;
        border-color: rgba(109, 40, 217, 0);
    }
}

@keyframes ringExpandAgent {
    0% {
        transform: translate(-50%, -50%) scale(0.8) rotate(0deg);
        opacity: 0;
        border-color: rgba(244, 114, 182, 0.8);
    }
    50% {
        opacity: 0.6;
        border-color: rgba(236, 72, 153, 0.6);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.4) rotate(180deg);
        opacity: 0;
        border-color: rgba(219, 39, 119, 0);
    }
}

.header-avatar-wrapper .sparkle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, #ffffff 0%, #e9d5ff 50%, transparent 100%);
    border-radius: 50%;
    opacity: 0;
    z-index: 3;
    pointer-events: none;
    box-shadow:
            0 0 8px rgba(255, 255, 255, 0.9),
            0 0 12px rgba(167, 139, 250, 0.6);
}

.header-avatar-wrapper .sparkle.s1 { top:  8%; left: 16%; }
.header-avatar-wrapper .sparkle.s2 { top: 12%; right: 12%; }
.header-avatar-wrapper .sparkle.s3 { bottom: 12%; left: 12%; }
.header-avatar-wrapper .sparkle.s4 { top: 28%; left: 44%; }
.header-avatar-wrapper .sparkle.s5 { bottom: 22%; right: 16%; }
.header-avatar-wrapper .sparkle.s6 { top: 38%; right:  8%; }

.header-avatar-wrapper.sending .sparkle    { animation: sparkleFloat 1.8s ease-out infinite; }
.header-avatar-wrapper.sending .sparkle.s1 { animation-delay: 0.0s; }
.header-avatar-wrapper.sending .sparkle.s2 { animation-delay: 0.3s; }
.header-avatar-wrapper.sending .sparkle.s3 { animation-delay: 0.6s; }
.header-avatar-wrapper.sending .sparkle.s4 { animation-delay: 0.9s; }
.header-avatar-wrapper.sending .sparkle.s5 { animation-delay: 1.2s; }
.header-avatar-wrapper.sending .sparkle.s6 { animation-delay: 1.5s; }

@keyframes sparkleFloat {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0) rotate(0deg);
    }
    20% {
        opacity: 1;
        transform: translate(0, 0) scale(1.2) rotate(90deg);
    }
    40% {
        opacity: 1;
        transform: translate(0, -12px) scale(1) rotate(180deg);
    }
    70% {
        opacity: 0.8;
        transform: translate(0, -28px) scale(0.8) rotate(270deg);
    }
    100% {
        opacity: 0;
        transform: translate(0, -40px) scale(0.3) rotate(360deg);
    }
}

.header-info h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.status {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status.online::before {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}
.status.offline::before {
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-color);
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
}

.welcome-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--primary-color);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-message h2 {
    font-size: 32px;
    margin: 20px 0;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: border-color 0.3s ease;
}

.message-bubble {
    max-width: 50%;
    padding: 12px 16px;
    border-radius: var(--border-radius);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.message.assistant .message-bubble {
    background: var(--surface-light);
}

.message-text.completion-text {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 14px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(236, 72, 153, 0.05));
    padding: 10px 14px;
    border-radius: 8px;
    border-left: 3px solid var(--secondary-color);
}

.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

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

.input-container {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    background: var(--surface-color);
}

.message-input {
    flex: 1;
    padding: 18px 18px;
    border: 2px solid var(--surface-light);
    border-radius: 24px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
}

.message-input.morgana:focus {
    border-color: var(--primary-color);
    outline: none;
}

.message-input.agent:focus {
    border-color: var(--secondary-color);
    outline: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.message-time {
    font-size: calc(1em - 4px);
    opacity: 0.6;
    margin-top: 8px;
    text-align: right;
}

@media (prefers-reduced-motion: reduce) {
    .message.assistant .message-bubble.streaming {
        animation: none;
    }
}