/* Core Color Palette & Variables */
:root {
    --bg-gradient: linear-gradient(135deg, #0b0f19 0%, #111827 50%, #1e1b4b 100%);
    --panel-bg: rgba(17, 24, 39, 0.7);
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-border-focus: rgba(99, 102, 241, 0.4);
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Accent & Brand Colors */
    --accent-primary: #6366f1; /* Indigo */
    --accent-secondary: #8b5cf6; /* Violet */
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --glow-color: rgba(99, 102, 241, 0.3);
    
    /* Bubbles */
    --user-bubble: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --agent-bubble: rgba(30, 41, 59, 0.85);
    
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Layout */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    max-height: 850px;
    margin: 20px;
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 
                0 0 40px rgba(99, 102, 241, 0.05);
    overflow: hidden;
    animation: app-appear 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes app-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.app-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 15, 26, 0.3);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: float 3s ease-in-out infinite;
}

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

.header-logo h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981; /* Emerald green */
    position: relative;
}

.status-indicator.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #10b981;
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

.status-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Chat Messages Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-container::-webkit-scrollbar {
    width: 6px;
}
.chat-container::-webkit-scrollbar-track {
    background: transparent;
}
.chat-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}
.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Messages */
.message {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    animation: message-fade-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

/* User Message styling */
.message.user {
    align-self: flex-end;
}
.message.user .message-content {
    background: var(--user-bubble);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

/* Agent Message styling */
.message.agent {
    align-self: flex-start;
}
.message.agent .message-content {
    background: var(--agent-bubble);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* System Messages */
.message.system-message {
    align-self: center;
    max-width: 100%;
}
.message.system-message .message-content {
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    border: none;
    box-shadow: none;
}

/* Typing Indicator Animation */
.typing-indicator {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 24px;
    background: var(--agent-bubble);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

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

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.hidden {
    display: none !important;
}

/* Footer / Input Form */
.app-footer {
    padding: 24px 32px 32px 32px;
    border-top: 1px solid var(--glass-border);
    background: rgba(10, 15, 26, 0.3);
}

.chat-form {
    display: flex;
    gap: 16px;
    position: relative;
}

#user-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px 20px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-smooth);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

#user-input::placeholder {
    color: var(--text-muted);
}

#user-input:focus {
    border-color: var(--glass-border-focus);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15),
                inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Send Button */
#send-button {
    background: var(--accent-gradient);
    border: none;
    border-radius: 16px;
    width: 52px;
    height: 52px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    transition: var(--transition-fast);
}

#send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

#send-button:active {
    transform: translateY(1px);
}

.send-icon {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-container {
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        border: none;
    }
    
    .chat-container {
        padding: 20px;
    }
    
    .app-header {
        padding: 16px 20px;
    }
    
    .app-footer {
        padding: 16px;
    }
    
    .message {
        max-width: 85%;
    }
}
