:root {
    --bg-dark: #0f111a;
    --bg-surface: rgba(25, 28, 41, 0.65);
    --bg-surface-hover: rgba(35, 39, 58, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.5);
    --secondary: #3b82f6;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    
    --success: #10b981;
    --error: #ef4444;
    
    --glass-blur: blur(16px);
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    
    /* Dynamic background gradient */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(139, 92, 246, 0.12), transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.12), transparent 40%);
    background-attachment: fixed;
}

/* Glassmorphism Container */
.app-container {
    width: 95vw;
    height: 95vh;
    max-width: 1400px;
    display: flex;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    position: relative;
    z-index: 10;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: rgba(15, 17, 26, 0.4);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.brand h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #e2e8f0, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-panel h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: -16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--text-tertiary);
}

input, select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

input::placeholder {
    color: var(--text-tertiary);
}

select:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.info-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
}

.info-box svg {
    color: var(--secondary);
    flex-shrink: 0;
    margin-top: 2px;
}

.info-box span {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Main Chat Area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    height: 70px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 17, 26, 0.2);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-tertiary);
    transition: var(--transition);
}

.status-dot.active {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.error {
    background-color: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.chat-history {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-history::-webkit-scrollbar {
    width: 6px;
}
.chat-history::-webkit-scrollbar-track {
    background: transparent;
}
.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages */
.message {
    display: flex;
    width: 100%;
    animation: fadeIn 0.4s ease-out forwards;
}

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

.message-content {
    display: flex;
    gap: 16px;
    max-width: 80%;
}

.user-message {
    justify-content: flex-end;
}

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

.system-message .avatar {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.user-message .avatar {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
}

.bubble {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

.system-message .bubble {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

.user-message .bubble {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-top-right-radius: 4px;
}

.bubble p {
    margin-bottom: 12px;
}

.bubble p:last-child {
    margin-bottom: 0;
}

.bubble pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
    font-family: monospace;
    font-size: 13px;
}

.bubble code {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Chat Input Area */
.chat-input-area {
    padding: 24px 32px;
    background: linear-gradient(to top, rgba(15, 17, 26, 0.8) 0%, rgba(15, 17, 26, 0) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.input-wrapper {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: var(--transition);
    display: flex;
    align-items: flex-end;
    padding: 10px 16px;
}

.input-wrapper:focus-within {
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    padding: 8px 0;
    outline: none;
    max-height: 150px;
    min-height: 24px;
}

textarea::placeholder {
    color: var(--text-tertiary);
}

textarea:disabled {
    cursor: not-allowed;
}

#send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    margin-left: 12px;
    margin-bottom: 2px;
}

#send-btn:hover:not(:disabled) {
    background: #9333ea;
    box-shadow: 0 0 15px var(--primary-glow);
    transform: scale(1.05);
}

#send-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.footer-text {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 16px;
    letter-spacing: 0.02em;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
}

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

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

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

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .brand {
        margin-bottom: 16px;
    }
    
    .chat-header, .chat-input-area, .chat-history {
        padding-left: 16px;
        padding-right: 16px;
    }
}
