:root {
    --bg-main: #f0f4f8;
    --bg-sidebar: rgba(255, 255, 255, 0.7);
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-input: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-color: #8b5cf6;
    --msg-user: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    --msg-ai: #ffffff;
    --border-color: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --input-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-sidebar: rgba(15, 23, 42, 0.8);
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-input: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --accent-color: #7c3aed;
    --msg-user: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --msg-ai: #1e293b;
    --border-color: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --input-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Poppins', sans-serif; }
body { background: var(--bg-main); color: var(--text-primary); height: 100vh; overflow: hidden; transition: background 0.4s ease; }

.auth-page { display: flex; justify-content: center; align-items: center; background: var(--bg-main); background-image: radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%), radial-gradient(circle at 85% 30%, rgba(168, 85, 247, 0.15), transparent 25%); }
.auth-glass-card { background: var(--bg-card); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border-color); border-radius: 24px; padding: 3rem; width: 100%; max-width: 450px; box-shadow: var(--glass-shadow); text-align: center; }
.icon-circle { width: 60px; height: 60px; background: var(--accent-gradient); border-radius: 50%; display: flex; justify-content: center; align-items: center; color: white; font-size: 1.5rem; margin: 0 auto 1rem; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); }
.icon-circle.huge { width: 80px; height: 80px; font-size: 2.5rem; }
.auth-header h2 { margin-bottom: 0.5rem; font-weight: 600; }
.auth-header p { color: var(--text-secondary); margin-bottom: 2rem; font-size: 0.95rem; }
.input-group { position: relative; margin-bottom: 1.25rem; }
.input-group i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }
.input-group input { width: 100%; padding: 1rem 1rem 1rem 3rem; border-radius: 12px; border: 2px solid transparent; background: var(--bg-input); color: var(--text-primary); font-size: 1rem; transition: all 0.3s; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); }
.input-group input:focus { outline: none; border-color: var(--accent-color); background: transparent; }
.primary-btn { width: 100%; padding: 1rem; background: var(--accent-gradient); color: white; border: none; border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3); }
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5); }
.auth-link { margin-top: 1.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.auth-link a { color: var(--accent-color); text-decoration: none; font-weight: 600; }

.app-container { display: flex; width: 100%; height: 100%; background-image: radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.08), transparent 40%); }
.sidebar { width: 280px; background: var(--bg-sidebar); backdrop-filter: blur(20px); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 1.5rem; z-index: 10; }
.sidebar-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.logo-icon { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-size: 1.8rem; }
.sidebar-header h1 { font-size: 1.4rem; font-weight: 600; letter-spacing: 0.5px; }
.create-btn { display: flex; align-items: center; justify-content: center; gap: 0.5rem; border-radius: 100px; }
.chat-history { flex: 1; overflow-y: auto; margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.history-item { padding: 0.8rem 1rem; border-radius: 12px; cursor: pointer; color: var(--text-secondary); transition: all 0.2s; font-size: 0.9rem; display: flex; align-items: center; gap: 0.75rem; }
.history-item i { font-size: 0.8rem; opacity: 0.7; }
.history-item:hover, .history-item.active { background: var(--bg-input); color: var(--text-primary); box-shadow: var(--input-shadow); transform: translateX(4px); }
.sidebar-footer { display: flex; justify-content: space-around; margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.circle-btn { width: 45px; height: 45px; border-radius: 50%; background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-secondary); font-size: 1.1rem; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s; text-decoration: none; box-shadow: var(--input-shadow); }
.circle-btn:hover { color: var(--accent-color); transform: translateY(-3px); }
.circle-btn.danger:hover { color: #ef4444; }

.chat-area { flex: 1; display: flex; flex-direction: column; position: relative; }
.chat-messages { flex: 1; overflow-y: auto; padding: 2rem; display: flex; flex-direction: column; gap: 1.5rem; scroll-behavior: smooth; }
.welcome-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; opacity: 0.6; text-align: center; }
.welcome-screen h2 { margin-top: 1rem; font-weight: 400; }
.message { max-width: 80%; padding: 1.2rem 1.5rem; border-radius: 20px; line-height: 1.6; font-size: 0.95rem; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { 0% { opacity: 0; transform: translateY(10px) scale(0.95); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
.message p { margin-bottom: 0.75rem; }
.message p:last-child { margin-bottom: 0; }
.message pre { background: #1e1e2f; padding: 1rem; border-radius: 12px; overflow-x: auto; margin: 1rem 0; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.message code { font-family: monospace; font-size: 0.9rem; }
.message.user { align-self: flex-end; background: var(--msg-user); color: white; border-bottom-right-radius: 4px; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2); }
.message.user code { background: rgba(255,255,255,0.2); padding: 0.1rem 0.4rem; border-radius: 4px; }
.message.assistant { align-self: flex-start; background: var(--msg-ai); border: 1px solid var(--border-color); border-bottom-left-radius: 4px; box-shadow: var(--glass-shadow); }

.chat-input-container { padding: 1.5rem; display: flex; justify-content: center; background: transparent; }
.input-wrapper { position: relative; width: 100%; max-width: 850px; }
.input-wrapper textarea { width: 100%; padding: 1.2rem 4.5rem 1.2rem 1.5rem; border-radius: 24px; border: 1px solid var(--border-color); background: var(--bg-card); backdrop-filter: blur(10px); color: var(--text-primary); resize: none; box-shadow: var(--glass-shadow); font-size: 1rem; line-height: 1.5; transition: border 0.3s; }
.input-wrapper textarea:focus { outline: none; border-color: var(--accent-color); }
.send-circle { position: absolute; right: 0.5rem; bottom: 0.5rem; background: var(--accent-gradient); color: white; border: none; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; transition: all 0.3s; box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3); }
.send-circle:hover { transform: scale(1.1) rotate(10deg); }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: center; z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content { background: var(--bg-main); border: 1px solid var(--border-color); border-radius: 24px; width: 100%; max-width: 400px; padding: 2rem; box-shadow: var(--glass-shadow); transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-header h2 { font-size: 1.2rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.close-btn { background: transparent; border: none; color: var(--text-secondary); font-size: 1.5rem; cursor: pointer; transition: 0.2s; }
.close-btn:hover { color: #ef4444; transform: rotate(90deg); }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.5px; }
.modern-select { width: 100%; padding: 0.8rem; border-radius: 12px; border: 1px solid var(--border-color); background: var(--bg-input); color: var(--text-primary); font-size: 0.95rem; box-shadow: var(--input-shadow); appearance: none; outline: none; }
.error-msg { background: rgba(239, 68, 68, 0.1); color: #ef4444; padding: 0.8rem; border-radius: 12px; margin-bottom: 1.5rem; border: 1px solid rgba(239, 68, 68, 0.3); font-size: 0.9rem; }
.auth-divider { margin: 1.5rem 0; position: relative; color: var(--text-secondary); font-size: 0.9rem; display: flex; align-items: center; justify-content: center; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-color); margin: 0 10px; }
.secondary-btn { display: block; width: 100%; padding: 1rem; background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s; text-decoration: none; }
.secondary-btn:hover { background: var(--bg-input); border-color: var(--accent-color); color: var(--accent-color); }