:root {
    --bg-main: #0a0e1a;
    --bg-glass: rgba(20, 25, 45, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-primary: #8b5cf6;
    --accent-secondary: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #06b6d4);
    --danger: #ef4444;
    --success: #10b981;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

body { background: var(--bg-main); color: var(--text-main); height: 100vh; overflow: hidden; }

#app-container { display: flex; height: 100vh; width: 100vw; position: relative; }

.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
}

/* Sidebar */
#sidebar {
    width: 280px; height: 100%; display: flex; flex-direction: column;
    border-right: 1px solid var(--border-glass); z-index: 10;
    transition: transform 0.3s ease;
}

.sidebar-header { padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-glass); }

.session-list { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.session-item { padding: 0.75rem 1rem; border-radius: 0.5rem; cursor: pointer; transition: background 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.session-item:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
.session-item.active { background: rgba(139, 92, 246, 0.15); border-left: 3px solid var(--accent-primary); color: var(--text-main); }

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

#chat-header { padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-glass); z-index: 5; }
.header-right { display: flex; align-items: center; gap: 1rem; }

.status-indicator { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-indicator.connected { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-indicator.connecting { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }

.messages-area { flex: 1; overflow-y: auto; padding: 2rem; display: flex; flex-direction: column; gap: 1.5rem; scroll-behavior: smooth; }

.welcome-screen { margin: auto; text-align: center; color: var(--text-muted); animation: fadeIn 0.5s ease; }
.welcome-screen h1 { color: var(--text-main); margin-bottom: 0.5rem; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Messages */
.message { max-width: 80%; display: flex; flex-direction: column; animation: slideUp 0.3s ease; }
.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

.message-content { padding: 1rem; border-radius: 1rem; line-height: 1.5; word-break: break-word; }
.message.user .message-content { background: var(--accent-gradient); color: white; border-bottom-right-radius: 0.25rem; }
.message.assistant .message-content { background: rgba(255,255,255,0.05); border: 1px solid var(--border-glass); border-bottom-left-radius: 0.25rem; }

.message-image { max-width: 100%; border-radius: 0.5rem; margin-top: 0.5rem; display: block; }

/* Input Area */
.input-container { padding: 1.5rem; border-top: 1px solid var(--border-glass); }
.input-wrapper { display: flex; gap: 1rem; align-items: flex-end; background: rgba(0,0,0,0.2); border: 1px solid var(--border-glass); border-radius: 1rem; padding: 0.5rem; }
#message-input { flex: 1; background: transparent; border: none; color: var(--text-main); padding: 0.5rem; resize: none; max-height: 150px; outline: none; line-height: 1.5; }
#message-input::placeholder { color: var(--text-muted); }

/* Settings Panel */
#settings-panel { width: 320px; border-left: 1px solid var(--border-glass); display: flex; flex-direction: column; position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; transition: transform 0.3s ease; }
#settings-panel.hidden { transform: translateX(100%); }

.settings-header { padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-glass); }
.settings-content { padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.5rem; }

.setting-group { display: flex; flex-direction: column; gap: 0.5rem; }
.setting-group label { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }

/* Controls */
.primary-btn { background: var(--accent-gradient); color: white; border: none; padding: 0.5rem 1rem; border-radius: 0.5rem; cursor: pointer; font-weight: 600; transition: opacity 0.2s; }
.primary-btn:hover { opacity: 0.9; }
.icon-btn { background: transparent; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 0.5rem; border-radius: 0.5rem; transition: all 0.2s; }
.icon-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.1); }
#send-btn { border-radius: 0.5rem; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; padding: 0; }

.custom-select, .custom-input, .custom-file-input { width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--border-glass); color: var(--text-main); padding: 0.75rem; border-radius: 0.5rem; outline: none; }
.custom-select:focus, .custom-input:focus { border-color: var(--accent-primary); }

.hidden { display: none !important; }
.upload-preview-container, #image-preview-container { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.preview-thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 0.25rem; border: 1px solid var(--border-glass); position: relative; }
.preview-wrapper { position: relative; }
.remove-thumb-btn { position: absolute; top: -5px; right: -5px; background: var(--danger); color: white; border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

.mobile-only { display: none; }

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

/* Error & Retry */
.error-msg .message-content {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
}
.retry-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.retry-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.4);
}

@media (max-width: 768px) {
    .mobile-only { display: block; }
    #sidebar { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-100%); background: var(--bg-main); }
    #sidebar.show { transform: translateX(0); }
    #settings-panel { width: 100%; }
}
