:root {
    --bg-color: #050508;
    --navy: #0a0f1c;
    --neon-blue: #00f3ff;
    --cyan: #00bc8c;
    --purple-glow: #bc13fe;
    --text-primary: #ffffff;
    --text-secondary: #b0b8c4;
    --glass-bg: rgba(16, 20, 30, 0.6);
    --border-color: rgba(255, 255, 255, 0.1);
    --danger: #ff3232;
    --warning: #ffaa00;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background: var(--bg-color); color: var(--text-primary); overflow: hidden; height: 100vh; }

body::before {
    content: '';
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 10% 20%, rgba(188, 19, 254, 0.15), transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(0, 243, 255, 0.1), transparent 40%);
    z-index: -1;
}

.app-container { display: flex; height: 100vh; }

.glassmorphism {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
}

.sidebar { width: 320px; display: flex; flex-direction: column; border-right: 1px solid var(--border-color); padding: 20px; }
.sidebar-header h1 { font-size: 1.5rem; margin-bottom: 20px; text-transform: uppercase; letter-spacing: 1px; }
.glow { color: var(--neon-blue); text-shadow: 0 0 10px var(--neon-blue); }

.btn-primary {
    background: linear-gradient(45deg, var(--purple-glow), var(--neon-blue));
    color: white; border: none; padding: 10px 15px; border-radius: 8px; cursor: pointer;
    font-weight: bold; transition: transform 0.2s, box-shadow 0.2s; width: 100%; margin-bottom: 20px;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0, 243, 255, 0.3); }

.search-box input {
    width: 100%; padding: 10px; background: rgba(0,0,0,0.3); border: 1px solid var(--border-color);
    border-radius: 8px; color: var(--text-primary); margin-bottom: 20px; outline: none;
}
.search-box input:focus { border-color: var(--neon-blue); }

.history-list { flex-grow: 1; overflow-y: auto; }
.history-item { padding: 12px; border-radius: 8px; cursor: pointer; margin-bottom: 5px; color: var(--text-secondary); transition: background 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item:hover, .history-item.active { background: rgba(0, 243, 255, 0.1); color: var(--text-primary); }

.sidebar-footer { margin-top: auto; }
.nav-tabs { display: flex; gap: 10px; }
.tab-btn { flex: 1; background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); padding: 10px; border-radius: 8px; cursor: pointer; transition: all 0.3s; }
.tab-btn.active, .tab-btn:hover { border-color: var(--neon-blue); color: var(--neon-blue); background: rgba(0, 243, 255, 0.05); }

.mobile-menu-toggle { display: none; position: fixed; top: 15px; right: 15px; z-index: 100; background: var(--glass-bg); border: 1px solid var(--border-color); color: var(--neon-blue); padding: 10px; border-radius: 8px; cursor: pointer; }

.main-content { flex: 1; display: flex; flex-direction: column; position: relative; }
.view { display: none; flex-direction: column; height: 100%; padding: 20px; }
.view.active { display: flex; }

.chat-header, .view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--border-color); }

.chat-container { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.message { max-width: 80%; padding: 15px; border-radius: 12px; animation: fadeIn 0.5s ease; }
.user-message { align-self: flex-end; background: linear-gradient(135deg, var(--purple-glow), #4a0080); box-shadow: 0 4px 15px rgba(188, 19, 254, 0.2); }
.ai-message { align-self: flex-start; background: var(--navy); border: 1px solid var(--border-color); }
.ai-message.warning { border-color: var(--warning); background: rgba(255, 170, 0, 0.1); }
.ai-message.error { border-color: var(--danger); background: rgba(255, 50, 50, 0.1); }

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

.message-content p { margin-bottom: 10px; line-height: 1.6; }
.message-content pre { background: #0d1117; padding: 15px; border-radius: 8px; margin: 10px 0; border-left: 3px solid var(--neon-blue); overflow-x: auto; }
.message-content code { font-family: 'Courier New', monospace; color: var(--neon-blue); }
.message-content h1, .message-content h2, .message-content h3 { color: var(--neon-blue); margin: 15px 0 10px; }

.chat-input-area { padding: 20px 0; }
.input-wrapper { display: flex; align-items: center; padding: 10px; border-radius: 12px; }
#userInput { flex: 1; background: transparent; border: none; color: white; resize: none; outline: none; padding: 10px; font-size: 1rem; max-height: 150px; }
.btn-send { background: var(--neon-blue); color: black; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: bold; }
.btn-send:disabled { background: #555; cursor: not-allowed; }

.thinking-indicator { display: flex; gap: 5px; align-items: center; }
.thinking-indicator span { width: 8px; height: 8px; background: var(--neon-blue); border-radius: 50%; animation: bounce 1s infinite; }
.thinking-indicator span:nth-child(2) { animation-delay: 0.2s; }
.thinking-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.cards-container, .quiz-container { display: flex; flex-direction: column; gap: 20px; overflow-y: auto; padding-bottom: 20px; }
.card { background: var(--navy); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; transition: transform 0.2s, border-color 0.2s; }
.card:hover { transform: translateY(-3px); border-color: var(--purple-glow); }
.card-category { color: var(--cyan); font-size: 0.9rem; text-transform: uppercase; font-weight: bold; margin-bottom: 10px; }
.card-title { font-size: 1.2rem; margin-bottom: 10px; }
.card-summary { color: var(--text-secondary); line-height: 1.5; }

.quiz-question { font-size: 1.2rem; font-weight: bold; margin-bottom: 20px; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option { background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); padding: 15px; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.quiz-option:hover { border-color: var(--neon-blue); background: rgba(0, 243, 255, 0.1); }
.quiz-option.correct { background: rgba(0, 188, 140, 0.2); border-color: var(--cyan); }
.quiz-option.wrong { background: rgba(255, 50, 50, 0.2); border-color: var(--danger); }
.quiz-option.disabled { pointer-events: none; opacity: 0.7; }

.quiz-explanation { margin-top: 15px; padding: 15px; background: rgba(0,0,0,0.3); border-radius: 8px; border-left: 3px solid var(--neon-blue); display: none; }
.quiz-explanation.show { display: block; }

.loading-text { color: var(--text-secondary); text-align: center; margin-top: 50px; }
.error-text { color: var(--danger); text-align: center; margin-top: 50px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-blue); }

@media (max-width: 768px) {
    .mobile-menu-toggle { display: block; }
    .sidebar { position: absolute; right: -320px; z-index: 10; height: 100%; transition: right 0.3s; background: var(--bg-color); }
    .sidebar.open { right: 0; }
    .message { max-width: 95%; }
    .main-content { padding: 10px; }
    .chat-header h2, .view-header h2 { font-size: 1rem; }
}