
/* --- THEME VARIABLES --- */
:root {
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --secondary: #10b981; /* Green for Syllabus */
    
    --bg-body: #f8fafc;
    --bg-sidebar: rgba(255, 255, 255, 0.85);
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-input: rgba(255, 255, 255, 0.5);
    
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --glass-blur: blur(12px);
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-glow: rgba(129, 140, 248, 0.3);
    --secondary: #34d399;
    
    --bg-body: linear-gradient(135deg, #020617 0%, #1e1b4b 50%, #172554 100%);
    --bg-sidebar: rgba(15, 23, 42, 0.6);
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-hover: rgba(51, 65, 85, 0.8);
    --bg-input: rgba(15, 23, 42, 0.6);
    --border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --glass-blur: blur(20px); 
}

/* --- RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; transition: background 0.4s ease, color 0.2s ease, border-color 0.3s ease; }
body { height: 100vh; display: flex; background: var(--bg-body); background-size: 200% 200%; color: var(--text-main); overflow: hidden; }

/* --- SIDEBAR --- */
.sidebar { width: 270px; background: var(--bg-sidebar); backdrop-filter: var(--glass-blur); border-right: 1px solid var(--border); padding: 24px 16px; display: flex; flex-direction: column; z-index: 20; flex-shrink: 0; overflow-y: auto; }
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.logo-container { display: flex; align-items: center; gap: 12px; padding: 0 12px 20px; }
.logo-icon { width: 34px; height: 34px; background: linear-gradient(135deg, var(--primary), #4f46e5); border-radius: 8px; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 15px var(--primary-glow); overflow: hidden; }
.logo-img { width: 100%; height: 100%; object-fit: cover; }
.logo-text { font-size: 1.3rem; font-weight: 700; color: var(--text-main); }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 8px 20px; }
.section-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; margin: 20px 12px 10px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; color: var(--text-muted); text-decoration: none; font-size: 0.95rem; font-weight: 500; margin-bottom: 4px; cursor: pointer; position: relative; overflow: hidden; z-index: 1; }
.nav-item::before { content: ''; position: absolute; top: 0; left: 0; bottom: 0; right: 0; background: var(--bg-hover); z-index: -1; border-radius: 12px; transform: scaleX(0); transform-origin: left; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-item.active::before { transform: scaleX(1); background: var(--bg-hover); opacity: 0.5; }
.nav-item.active i { color: var(--primary); }
.nav-item:hover { color: var(--text-main); transform: translateX(6px); }
.nav-item:hover::before { transform: scaleX(1); }
.nav-item i { width: 24px; text-align: center; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* --- HEADER --- */
.main-layout { flex: 1; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.top-bar { height: 72px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; background: var(--bg-sidebar); backdrop-filter: var(--glass-blur); border-bottom: 1px solid var(--border); z-index: 10; }
.search-wrapper { position: relative; width: 400px; }
.search-input { width: 100%; padding: 11px 16px 11px 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-main); font-size: 0.9rem; }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); background: var(--bg-card); }
.search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: 16px; }
.action-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.action-btn:hover { background: var(--bg-hover); color: var(--text-main); border-color: var(--primary); transform: translateY(-2px); }
.profile-avatar { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #6366f1, #d946ef); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; cursor: pointer; }
.mobile-menu-btn { display: none; margin-right: 15px; background: transparent; border: none; font-size: 1.4rem; color: var(--text-muted); cursor: pointer; }

/* --- SYLLABUS CONTENT --- */
.archive-container { flex: 1; padding: 32px; padding-bottom: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; }

/* Filter Bar */
.filter-bar { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; background: var(--bg-card); padding: 16px; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.search-large-wrapper { flex: 1; position: relative; min-width: 250px; }
.search-large { width: 100%; padding: 12px 16px 12px 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-main); font-size: 0.95rem; outline: none; }
.search-large:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.search-large-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.filter-select { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-main); cursor: pointer; font-size: 0.9rem; outline: none; min-width: 140px; }
.upload-btn { padding: 12px 24px; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border: none; border-radius: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 15px var(--primary-glow); transition: transform 0.2s; }
.upload-btn:hover { transform: translateY(-2px); }

/* Stats */
.stats-row { display: flex; gap: 20px; margin-bottom: 8px; }
.stat-card { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; display: flex; align-items: center; gap: 20px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.stat-icon { width: 50px; height: 50px; border-radius: 12px; background: var(--bg-hover); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: var(--secondary); }
.stat-info h3 { font-size: 1.8rem; font-weight: 700; margin-bottom: 2px; }
.stat-info p { color: var(--text-muted); font-size: 0.9rem; }
.stat-bg-icon { position: absolute; right: -10px; bottom: -10px; font-size: 5rem; opacity: 0.05; transform: rotate(-15deg); }

/* Syllabus Grid */
.papers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding-bottom: 40px; }
.paper-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; position: relative; display: flex; flex-direction: column; gap: 12px; transition: all 0.3s; cursor: pointer; overflow: hidden; box-shadow: var(--shadow); }
.paper-card:hover { transform: translateY(-5px); border-color: var(--primary); box-shadow: 0 10px 30px -10px var(--primary-glow); }
.paper-header { display: flex; justify-content: space-between; align-items: flex-start; }
.file-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: rgba(16, 185, 129, 0.1); color: var(--secondary); }
.paper-code { font-size: 0.8rem; font-weight: 700; padding: 4px 10px; border-radius: 20px; background: var(--bg-hover); color: var(--text-muted); }
.paper-title { font-size: 1.1rem; font-weight: 600; line-height: 1.4; color: var(--text-main); margin-top: 4px; }
.paper-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.tag { font-size: 0.75rem; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); color: var(--text-muted); }
.paper-actions { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.update-date { font-size: 0.8rem; color: var(--text-muted); }
.download-btn { width: 32px; height: 32px; border-radius: 8px; background: var(--bg-hover); color: var(--text-main); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
.download-btn:hover { background: var(--primary); color: white; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.upload-modal { width: 500px; background: var(--bg-card); border-radius: 24px; border: 1px solid var(--border); padding: 30px; transform: translateY(20px); transition: transform 0.3s; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.modal-overlay.open .upload-modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 1.5rem; font-weight: 700; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.form-input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-main); outline: none; }
.file-drop-zone { border: 2px dashed var(--border); border-radius: 12px; padding: 30px; text-align: center; color: var(--text-muted); cursor: pointer; transition: border-color 0.2s; margin-bottom: 20px; }
.file-drop-zone:hover { border-color: var(--primary); background: rgba(59, 130, 246, 0.05); }

/* --- AI WIDGET (RE-DESIGNED) --- */
.ai-widget {
    position: absolute; bottom: 30px; right: 30px;
    width: auto; height: auto;
    z-index: 999;
}

/* Minimized Pill Button */
.ai-minimized {
    background: var(--bg-card); 
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 50px; padding: 12px 24px; box-shadow: var(--shadow);
    color: var(--text-main); font-weight: 600; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-minimized:hover { transform: translateY(-3px) scale(1.02); border-color: var(--primary); box-shadow: 0 10px 25px rgba(0,0,0,0.1); }
.widget-status { width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 10px #10b981; }

/* Expanded Chat Window (Best UI) */
.chat-interface {
    position: absolute; bottom: 0; right: 0;
    width: 380px; height: 550px;
    background: var(--bg-card);
    /* Glassmorphism Effect */
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex; flex-direction: column;
    overflow: hidden;
    
    /* Animation State: Hidden */
    opacity: 0; pointer-events: none; transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Expanded State */
.ai-widget.expanded .chat-interface {
    opacity: 1; pointer-events: auto; transform: translateY(0) scale(1);
}
.ai-widget.expanded .ai-minimized {
    opacity: 0; pointer-events: none; display: none;
}

/* Chat Header */
.chat-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
}
.ai-profile { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.95rem; }
.ai-avatar-small { 
    width: 32px; height: 32px; border-radius: 8px; 
    background: linear-gradient(135deg, #10b981, #059669);
    display: flex; align-items: center; justify-content: center; color: white;
}
.close-chat {
    background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem;
    transition: color 0.2s;
}
.close-chat:hover { color: var(--text-main); }

/* Chat Body */
.chat-body {
    flex: 1; padding: 20px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 16px;
    background: linear-gradient(to bottom, transparent, var(--bg-hover));
}

/* Messages */
.msg { padding: 12px 16px; font-size: 0.9rem; line-height: 1.5; max-width: 85%; position: relative; animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* User Bubble (Vibrant Gradient) */
.msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-radius: 18px 18px 0 18px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* AI Bubble (Soft Contextual) */
.msg-ai {
    align-self: flex-start;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 18px 18px 18px 0;
}

/* Floating Input Bar */
.chat-footer {
    padding: 16px;
    position: relative;
}
.chat-input-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 6px 6px 6px 16px;
    display: flex; align-items: center;
    box-shadow: 0 10px 20px -5px rgba(0,0,0,0.05);
}
.chat-input {
    flex: 1; border: none; background: transparent; outline: none;
    color: var(--text-main); font-size: 0.9rem;
}
.send-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: white; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.2s;
}
.send-btn:hover { transform: scale(1.1); }

/* Typing Indicator Animation */
.typing-indicator {
    display: flex; gap: 4px; padding: 12px 16px; align-self: flex-start;
    background: var(--bg-hover); border-radius: 18px; border: 1px solid var(--border);
    width: fit-content;
}
.dot {
    width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Toast */
#toast-container { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 1100; pointer-events: none; }
.toast { background: #0f172a; color: white; padding: 12px 24px; border-radius: 50px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); opacity: 0; transform: translateY(20px); transition: all 0.3s; display: flex; align-items: center; gap: 10px; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1024px) {
    .sidebar { position: fixed; transform: translateX(-100%); transition: transform 0.3s; z-index: 50; }
    .sidebar.open { transform: translateX(0); }
    .mobile-menu-btn { display: block; }
    .chat-interface { width: 90vw; bottom: 80px; right: 5vw; height: 60vh; }
}

/* --- Responsive fixes (small screens) --- */
.archive-container > * { flex-shrink: 0; }
@media (max-width: 600px) {
    .archive-container { padding: 20px 16px 120px; }
    .stats-row { flex-direction: column; gap: 12px; }
}

@media (max-width: 600px) {
    .top-bar { padding: 0 16px; gap: 10px; }
    .search-wrapper { width: auto; flex: 1; min-width: 0; }
    .header-actions { gap: 8px; flex-shrink: 0; }
    .action-btn { width: 38px; height: 38px; }
    .mobile-menu-btn { margin-right: 4px; }
}
