
/* --- THEME VARIABLES --- */
:root {
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --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);
    --success: #10b981;
    --danger: #ef4444;
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-glow: rgba(129, 140, 248, 0.3);
    --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); }
.nav-item:hover i { transform: scale(1.15) rotate(5deg); color: var(--primary); }

/* --- 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; display: flex; align-items: center; gap: 15px; }
.menu-toggle { display: none; font-size: 1.2rem; color: var(--text-muted); background: none; border: none; cursor: pointer; }

.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 cubic-bezier(0.34, 1.56, 0.64, 1); }
.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; }

/* --- NOTES REPO STYLES --- */
.content-area { flex: 1; padding: 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 32px; }

.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; }
.page-title h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 5px; }
.page-title p { color: var(--text-muted); }

/* Hero Search */
.repo-search-container {
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    border-radius: 20px; padding: 40px; color: white; text-align: center;
    box-shadow: 0 10px 30px -5px rgba(139, 92, 246, 0.4);
    position: relative; overflow: hidden;
}
.repo-search-container::before {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: rotate 20s linear infinite;
}
@keyframes rotate { from {transform: rotate(0deg);} to {transform: rotate(360deg);} }

.hero-content { position: relative; z-index: 1; max-width: 600px; margin: 0 auto; }
.hero-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 20px; }
.big-search-box { position: relative; width: 100%; }
.big-search-input {
    width: 100%; padding: 16px 24px 16px 50px; border-radius: 14px;
    border: none; font-size: 1rem; box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    outline: none; color: #1e293b;
}
.big-search-icon { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: #64748b; font-size: 1.1rem; }

/* Notes Grid */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }

.note-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 20px;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex; flex-direction: column; gap: 15px;
    position: relative; overflow: hidden;
}
.note-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: var(--primary); }

.note-icon-box {
    width: 50px; height: 50px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; margin-bottom: 5px;
}
.icon-pdf { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.icon-doc { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.icon-img { background: rgba(16, 185, 129, 0.1); color: #10b981; }

.note-info h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 5px; color: var(--text-main); }
.note-course { font-size: 0.85rem; color: var(--primary); font-weight: 600; background: var(--bg-hover); padding: 4px 8px; border-radius: 6px; display: inline-block; margin-bottom: 8px; }
.note-desc { font-size: 0.9rem; color: var(--text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.note-footer {
    margin-top: auto; padding-top: 15px; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.8rem; color: var(--text-muted);
}
.author-info { display: flex; align-items: center; gap: 6px; }
.author-avatar { width: 24px; height: 24px; border-radius: 50%; background: #cbd5e1; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; color: #475569; }

.download-btn {
    padding: 6px 12px; border-radius: 8px; background: var(--bg-hover);
    color: var(--text-main); border: 1px solid var(--border); cursor: pointer;
    font-size: 0.8rem; font-weight: 600; display: flex; align-items: center; gap: 6px;
    justify-content: center;
}
.download-btn:hover { background: var(--bg-input); color: var(--primary); border-color: var(--primary); }

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(5px);
    display: none; align-items: center; justify-content: center; z-index: 2000;
}
.modal-content {
    background: var(--bg-card); padding: 30px; border-radius: 20px;
    width: 500px; border: 1px solid var(--border); box-shadow: var(--shadow);
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-content h3 { margin-bottom: 20px; font-size: 1.3rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; color: var(--text-main); }
.form-input, .form-textarea {
    width: 100%; padding: 12px 16px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text-main); font-size: 0.95rem; outline: none;
}
.form-input:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-textarea { resize: vertical; min-height: 80px; }

/* File Upload Box */
.file-upload-box {
    border: 2px dashed var(--border); border-radius: 12px;
    padding: 20px; text-align: center; cursor: pointer;
    transition: all 0.2s; position: relative;
}
.file-upload-box:hover { border-color: var(--primary); background: var(--bg-hover); }
.file-upload-box i { font-size: 2rem; color: var(--text-muted); margin-bottom: 10px; }
.file-upload-box p { font-size: 0.9rem; color: var(--text-muted); }
.file-input-hidden { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-name-display { font-weight: 600; color: var(--primary); margin-top: 5px; display: none; }

.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 25px; padding-top: 15px; border-top: 1px solid var(--border); }
.save-btn { 
    background: var(--primary); color: white; border: none; padding: 12px 24px; border-radius: 12px; cursor: pointer; font-weight: 600; 
    display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 12px var(--primary-glow); transition: all 0.2s;
}
.save-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px var(--primary-glow); }
.cancel-btn { 
    background: transparent; border: 1px solid var(--border); color: var(--text-muted); 
    padding: 12px 24px; border-radius: 12px; cursor: pointer; font-weight: 600; 
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.cancel-btn:hover { background: var(--bg-hover); color: var(--text-main); border-color: var(--text-muted); }

/* --- AI WIDGET --- */
.ai-widget { position: absolute; bottom: 30px; right: 30px; z-index: 999; }
.ai-minimized { background: var(--bg-card); 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: transform 0.3s; }
.ai-minimized:hover { transform: translateY(-3px) scale(1.02); }
.widget-status { width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 10px #10b981; }
.chat-interface { position: absolute; bottom: 0; right: 0; width: 380px; height: 550px; background: var(--bg-card); 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; opacity: 0; pointer-events: none; transform: translateY(20px) scale(0.95); transition: all 0.4s; }
.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 { 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; }
.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; }
.chat-body { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.msg { padding: 12px 16px; font-size: 0.9rem; line-height: 1.5; max-width: 85%; border-radius: 12px; 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); } }
.msg-user { align-self: flex-end; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; border-radius: 18px 18px 0 18px; }
.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; }
.chat-footer { padding: 16px; }
.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; }
.chat-input { flex: 1; border: none; background: transparent; outline: none; color: var(--text-main); }
.send-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: white; border: none; cursor: pointer; }

/* 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); } }

/* Mobile */
@media (max-width: 1024px) {
    .sidebar { position: fixed; transform: translateX(-100%); transition: transform 0.3s; box-shadow: var(--shadow); }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: block; }
}

/* --- Responsive fixes (small screens) --- */
.content-area > * { flex-shrink: 0; }
@media (max-width: 600px) {
    .content-area { padding: 20px 16px 120px; }
    .repo-search-container { padding: 28px 16px; }
}

@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; }
}
