/* Root Variables */
:root {
    --primary-color: #3b82f6;
    --secondary-color: #1e40af;
    --accent-color: #d97706; 
    --text-color: #1f2937;
    --bg-color: #f3f4f6;
    --white: #ffffff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --border-color: #d1d5db;
    --transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

/* Dark Mode */
body.dark-mode {
    --text-color: #e5e7eb;
    --bg-color: #111827;
    --white: #1f2937;
    --border-color: #374151;
    --accent-color: #f59e0b; 
}

/* General Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; color: var(--text-color); background-color: var(--bg-color); transition: var(--transition); }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.d-none { display: none !important; }
.w-100 { width: 100%; }
.mt-3 { margin-top: 1.5rem; }

/* Navigation */
.navbar { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: var(--white); padding: 1.5rem 0; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; }
.nav-container { display: flex; justify-content: space-between; align-items: center; position: relative; }
.logo h1 { font-size: 1.8rem; margin-bottom: 0.2rem; }
.tagline { font-size: 0.9rem; opacity: 0.9; }

.nav-links { display: flex; gap: 2rem; align-items: center; }
.nav-links a { color: var(--white); text-decoration: none; font-weight: 600; transition: var(--transition); }
.nav-links a:hover { opacity: 0.8; }
.dark-mode-btn { background: none; border: 2px solid var(--white); color: var(--white); padding: 0.5rem 0.8rem; border-radius: 6px; cursor: pointer; font-size: 1rem; transition: var(--transition); }
.dark-mode-btn:hover { background-color: rgba(255, 255, 255, 0.1); }
.mobile-menu-btn { display: none; background: none; border: none; color: var(--white); font-size: 2rem; cursor: pointer; }

/* Hero Section */
.hero { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: var(--white); padding: 6rem 2rem; text-align: center; }
.hero-content h1 { font-size: 3rem; margin-bottom: 1rem; }
.hero-content p { font-size: 1.3rem; margin-bottom: 2rem; opacity: 0.9; }

/* Buttons */
.btn-primary { background-color: var(--accent-color); color: var(--white); border: none; padding: 1rem 2.5rem; font-size: 1rem; border-radius: 50px; cursor: pointer; font-weight: 600; transition: var(--transition); box-shadow: var(--shadow); display: inline-block; text-align: center; text-decoration: none; min-height: 44px; }
.btn-primary:hover { background-color: #d97706; transform: translateY(-2px); }

/* Search Section & Custom Dropdown */
.search-section { background: var(--white); padding: 3rem 0; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); }
.search-container { display: flex; max-width: 600px; margin: 0 auto; position: relative; }
.search-bar input { flex: 1; padding: 1rem; border: 2px solid var(--primary-color); border-radius: 8px; font-size: 1rem; color: var(--text-color); background-color: var(--bg-color); width: 100%; }
.search-bar input:focus { outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }

.custom-suggestions { position: absolute; top: 100%; left: 0; width: 100%; background: var(--white); border: 1px solid var(--border-color); border-top: none; border-radius: 0 0 8px 8px; z-index: 50; max-height: 250px; overflow-y: auto; box-shadow: var(--shadow); margin-top: 5px; }
.suggestion-item { padding: 12px 15px; cursor: pointer; border-bottom: 1px solid var(--border-color); font-size: 0.95rem; }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background-color: var(--bg-color); color: var(--primary-color); }

/* Papers Grid */
.papers-section { padding: 4rem 0; background-color: var(--white); }
.section-title { text-align: center; margin-bottom: 3rem; font-size: 2rem; color: var(--primary-color); }
.papers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2rem; }
.paper-card { background: var(--white); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); transition: var(--transition); display: flex; flex-direction: column; cursor: pointer; border: none; }
.paper-card:hover { transform: translateY(-10px); box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15); }

.paper-header { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: var(--white); padding: 1.5rem; }
.paper-tags { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.paper-subject { background-color: var(--accent-color); padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.8rem; font-weight: 600; }
.paper-level { background-color: rgba(255, 255, 255, 0.3); padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.8rem; }
.paper-header h3 { font-size: 1.3rem; margin-bottom: 0; }

.paper-body { padding: 1.5rem; flex-grow: 1; display: flex; flex-direction: column; }
.paper-description { color: var(--text-color); opacity: 0.8; margin-bottom: 1rem; font-size: 0.95rem; flex-grow: 1; }
.paper-meta { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-color); opacity: 0.6; margin-bottom: 1.5rem; }

.download-btn { background-color: var(--primary-color); color: var(--white); padding: 0.8rem; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; transition: var(--transition); min-height: 44px; }
.download-btn:hover { background-color: var(--secondary-color); }

/* Subjects Grid */
.subjects-section { padding: 4rem 0; background-color: var(--white); }
.subjects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2rem; }
.subject-card { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: var(--white); padding: 2rem; border-radius: 12px; cursor: pointer; transition: var(--transition); text-align: center; }
.subject-card:hover { transform: scale(1.05); box-shadow: var(--shadow); }

/* Upload & Contact Forms (Replaced Inline Styles) */
.upload-section { margin: 3rem auto; }
.upload-card { background: var(--white); border: 2px dashed var(--primary-color); border-radius: 12px; padding: 3rem 1.5rem; text-align: center; box-shadow: var(--shadow); transition: var(--transition); }
.upload-card.success { border-color: var(--accent-color); }
.upload-card h2 { color: var(--primary-color); margin-bottom: 1rem; }
.upload-desc { color: var(--text-color); opacity: 0.9; max-width: 600px; margin: 0 auto 2rem auto; font-size: 1.1rem; }
.btn-inline { width: auto; font-size: 1.1rem; }
.success-icon { font-size: 3rem; margin-bottom: 1rem; }
.text-btn { background: none; border: none; color: var(--primary-color); cursor: pointer; text-decoration: underline; font-weight: bold; font-size: 1rem; }

.contact-section { max-width: 700px; padding: 4rem 20px; }
.contact-form { background: var(--white); padding: 2rem; border-radius: 12px; box-shadow: var(--shadow); }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-weight: bold; margin-bottom: 0.5rem; color: var(--text-color); }
.form-control { width: 100%; padding: 0.8rem; border-radius: 6px; border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-color); font-family: inherit; font-size: 1rem; }
.form-control:focus { outline: none; border-color: var(--primary-color); }

/* Modal & PDF Viewer */
.modal { position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-content { background-color: var(--white); padding: 2rem; border-radius: 12px; width: 90%; max-width: 700px; max-height: 85vh; overflow-y: auto; position: relative; display: flex; flex-direction: column; }
.close-modal { position: absolute; top: 1rem; right: 1rem; font-size: 2rem; cursor: pointer; color: var(--text-color); background: var(--bg-color); border: none; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; z-index: 10; }
.close-modal:hover { color: var(--white); background: var(--primary-color); }

.preview-header { border-bottom: 2px solid var(--border-color); padding-bottom: 1rem; margin-bottom: 1rem; padding-right: 30px; }
.preview-header h3 { color: var(--primary-color); margin-bottom: 0.5rem; font-size: 1.4rem; }
.preview-meta { display: flex; gap: 1rem; flex-wrap: wrap; font-weight: bold; }
.preview-body { margin-bottom: 1rem; opacity: 0.8; }

.pdf-controls { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-bottom: 1rem; background: var(--bg-color); padding: 10px; border-radius: 8px; }
.pdf-btn { padding: 0.6rem 1rem; background-color: var(--primary-color); color: var(--white); border: none; border-radius: 6px; cursor: pointer; font-weight: 600; min-height: 44px; min-width: 80px; }
.pdf-btn:hover { background-color: var(--secondary-color); }
#pageInfo { font-weight: bold; }

.pdf-canvas-wrapper { max-height: 50vh; overflow-y: auto; text-align: center; background-color: #e5e7eb; padding: 1rem; border-radius: 6px; border: 1px solid var(--border-color); }
#pdfCanvas { max-width: 100%; height: auto; margin: 0 auto; display: block; }

/* Loading Spinner */
.pdf-loading { text-align: center; padding: 3rem 0; color: var(--primary-color); font-weight: bold; }
.spinner { border: 4px solid rgba(0, 0, 0, 0.1); width: 40px; height: 40px; border-radius: 50%; border-left-color: var(--primary-color); animation: spin 1s linear infinite; margin: 0 auto 1rem auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Footer */
.footer { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: var(--white); text-align: center; padding: 2rem; margin-top: 4rem; }
.footer a { color: var(--accent-color); text-decoration: none; font-weight: 600; }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .hero-content h1 { font-size: 2.2rem; }
    
    /* Mobile Menu Implementation */
    .mobile-menu-btn { display: block; }
    .nav-links { display: none; position: absolute; top: 100%; left: 0; width: 100%; background: var(--secondary-color); flex-direction: column; padding: 1rem 0; box-shadow: var(--shadow); }
    .nav-links.active { display: flex; }
    .nav-links a { padding: 0.5rem 2rem; width: 100%; }
    
    .subjects-grid { grid-template-columns: 1fr 1fr; }
    
    /* Full screen modal for mobile */
    .modal-content { width: 100%; height: 100%; max-height: 100vh; border-radius: 0; padding: 1rem; padding-top: 3.5rem; }
    .close-modal { top: 10px; right: 10px; background: rgba(0,0,0,0.1); }
    .pdf-canvas-wrapper { max-height: 60vh; padding: 0.5rem; }
}

@media (max-width: 480px) {
    .subjects-grid { grid-template-columns: 1fr; } /* Stack subjects on very narrow phones */
    .hero-content h1 { font-size: 1.8rem; }
}
