/* --- RESET & VARIABLES --- */
:root {
    --primary: #6366f1;       /* Indigo 500 */
    --primary-dark: #4338ca;  /* Indigo 700 */
    --accent: #ec4899;        /* Pink 500 */
    --bg-dark: #0f172a;       /* Slate 900 */
    --bg-card: rgba(30, 41, 59, 0.7); /* Glassy Card */
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at top center, #1e1b4b, var(--bg-dark));
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- ANIMATIONS --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-5px); } 100% { transform: translateY(0px); } }

/* --- HEADER --- */
header {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 0;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    color: #a5b4fc;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* --- BUTTONS --- */
.btn-contribute {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
}

.btn-contribute:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(236, 72, 153, 0.5);
}

.btn-back {
    background: transparent;
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-back:hover { background: rgba(255,255,255,0.05); color: white; border-color: rgba(255,255,255,0.2); }

/* --- LAYOUT --- */
.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

.section-header { text-align: left; margin-bottom: 40px; animation: fadeIn 0.6s ease; }
.section-header h2 { font-size: 2.2rem; margin-bottom: 10px; background: linear-gradient(to right, #fff, #cbd5e1);background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.section-header p { color: var(--text-muted); font-size: 1.1rem; }

/* --- FACULTY GRID --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    animation: fadeIn 0.8s ease;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 35px 25px;
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-8px);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 15px 35px -10px rgba(99, 102, 241, 0.2);
}
.card i { font-size: 2.5rem; margin-bottom: 20px; color: #a5b4fc; transition: 0.3s; }
.card:hover i { color: #fff; transform: scale(1.1); }
.card h3 { font-size: 1.2rem; font-weight: 600; color: #e2e8f0; }

/* --- SEMESTER NAV --- */
.hidden { display: none; }

.navigation-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.semester-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 5px 15px 5px;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}
.semester-scroll::-webkit-scrollbar { height: 6px; }
.semester-scroll::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 10px; }

.sem-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    padding: 8px 20px;
    border-radius: 50px;
    white-space: nowrap;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.sem-btn:hover { background: rgba(255,255,255,0.08); color: white; }
.sem-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

/* --- SUBJECT ACCORDION --- */
.subject-item {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: border 0.3s;
}
.subject-item:hover { border-color: rgba(255,255,255,0.15); }

.subject-header {
    padding: 18px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #f8fafc;
    background: transparent;
    transition: background 0.2s;
}
.subject-header:hover { background: rgba(255,255,255,0.02); }

.subject-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s;
    background: rgba(15, 23, 42, 0.3);
}
.subject-content.open { max-height: 1200px; border-top: 1px solid var(--glass-border); }

/* --- RESOURCES --- */
.resource-category { padding: 15px 20px 0 20px; }
.category-label { display: block; font-size: 0.75rem; color: #a5b4fc; margin-bottom: 10px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.8px; }
.resource-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

.resource-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(30, 41, 59, 0.6);
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid var(--glass-border);
    transition: all 0.2s;
}
.resource-link:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    border-color: var(--primary);
}

/* --- MOBILE & MODAL FIXES --- */
.modal {
    display: none; 
    position: fixed;
    z-index: 2000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
    
    /* FIX: Enable scrolling for entire modal container */
    overflow-y: auto; 
    padding: 20px 0;
}

.modal-content {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    /* FIX: Remove fixed margins, use auto to center horizontally */
    margin: 40px auto; 
    width: 90%;
    max-width: 500px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: white;
    /* FIX: Don't set fixed height, let content grow */
}

/* --- FORM & CONTRIBUTORS --- */
.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 1.3rem; display: flex; align-items: center; gap: 10px; }
.close-btn { font-size: 24px; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.close-btn:hover { color: #fff; transform: rotate(90deg); }

#uploadForm { padding: 25px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 0.85rem; color: #cbd5e1; }

.form-group input, .form-group select {
    width: 100%;
    padding: 12px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: 0.3s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); background: rgba(0,0,0,0.5); }

/* File Area */
.file-upload-wrapper { position: relative; height: 110px; margin-bottom: 20px; }
.file-upload-wrapper input { position: absolute; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; }
.file-upload-box {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.02);
    transition: 0.3s;
}
.file-upload-wrapper input:hover + .file-upload-box { border-color: var(--primary); background: rgba(99, 102, 241, 0.1); }

/* Submit Button */
.btn-submit {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}
.btn-submit:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(99, 102, 241, 0.3); }

/* Success Modal */
.success-content { text-align: center; padding: 40px; }
.success-icon { font-size: 4rem; color: #10b981; margin-bottom: 20px; animation: float 2s infinite ease-in-out; }
.success-btn { background: #10b981; color: white; border: none; padding: 10px 30px; border-radius: 50px; font-weight: bold; margin-top: 20px; cursor: pointer; transition: 0.2s; }
.success-btn:hover { background: #059669; transform: scale(1.05); }

/* --- CONTRIBUTORS LIST --- */
.contributor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
}
.contributor-item:last-child { border-bottom: none; }
.contributor-name { font-weight: 500; color: #e2e8f0; display: flex; align-items: center; gap: 10px; }
.contributor-count { background: var(--primary); padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; font-weight: bold; }

/* --- FOOTER --- */
footer {
    text-align: center;
    padding: 30px;
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
    position: relative;
}

/* Floating Contributors Button in Footer */
.contributors-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: #cbd5e1;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.contributors-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .header-content { flex-direction: column; gap: 15px; text-align: center; }
    .section-header h2 { font-size: 1.8rem; }
    .grid-container { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .navigation-bar { flex-direction: column-reverse; align-items: stretch; gap: 20px; }
    
    /* Ensure modal doesn't touch edges on mobile */
    .modal-content { width: 95%; margin: 20px auto; }
}