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

:root {
    --primary-color: #8E2DE2;
    --secondary-color: #4A00E0;
    --background-color: #121212;
    --surface-color: #1E1E1E;
    --text-color: #EAEAEA;
    --text-muted-color: #A0A0A0;
    --border-color: rgba(255, 255, 255, 0.1);
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    line-height: 1.7;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Specific padding for the subject page main content */
.subject-page-main {
    padding-top: 40px; /* Adjust as needed for spacing below header */
    padding-bottom: 60px;
}


/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Header and Navigation --- */
.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(18, 18, 18, 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-logo {
    font-size: 1.8rem;
    font-weight: 700;
    text-decoration: none;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 35px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted-color);
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
    padding-bottom: 5px;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
}

.nav-links a:hover {
    color: var(--text-color);
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background: var(--text-color);
    margin: 5px;
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}

/* --- Hero Section (Index Page Only) --- */
.hero-section {
    padding: 80px 0;
    text-align: center;
}

.header {
    margin-bottom: 40px;
}

.header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    background: linear-gradient(90deg, #ffffff, #b0b0b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: fadeIn 0.8s ease-out;
}

.header p {
    font-size: 1.2rem;
    color: var(--text-muted-color);
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.8s ease-out 0.2s;
    animation-fill-mode: backwards;
}

/* --- Global Search (Index Page Only) --- */
.global-search-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50px;
    padding: 15px;
    margin: 0 auto 60px auto;
    max-width: 700px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.8s ease-out 0.4s;
    animation-fill-mode: backwards;
}

.search-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.global-search-bar {
    flex: 1;
    padding: 15px 25px;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    background: transparent;
    color: var(--text-color);
}

.global-search-bar:focus {
    outline: none;
}

.search-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: grid;
    place-items: center;
}

.search-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(142, 45, 226, 0.4);
}

.global-search-results {
    display: none;
    background: var(--surface-color);
    border-radius: 15px;
    margin-top: 15px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
}

.global-search-results.show { display: block; }

.search-result-item {
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.search-result-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 5px;
}

.search-result-subject {
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 500;
}

/* --- Subjects Section (Index Page Only) --- */
.subjects-section {
    padding-bottom: 60px;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 40px;
    color: var(--text-color);
}

.subjects-grid, .notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.subject-card, .note-card {
    background: var(--surface-color);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.6s ease-out forwards;
}

.subject-card::before, .note-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transform: scaleX(0);
    transition: transform 0.4s ease;
    transform-origin: left;
}

.subject-card:hover, .note-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    border-color: rgba(142, 45, 226, 0.5);
}

.subject-card:hover::before, .note-card:hover::before {
    transform: scaleX(1);
}

.subject-icon { margin-bottom: 20px; }
.subject-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
}

.subject-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-color);
}

.subject-description { color: var(--text-muted-color); }

/* --- Subject Page Specifics --- */

/* Breadcrumb */
.breadcrumb {
    margin-top: 1px;
    margin-bottom: 20px;
}

.back-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-muted-color);
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none; /* Ensure it looks like a button, not a link */
}

.back-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Subject Header */
.subject-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 20px;
    margin-bottom: 40px;
    background: var(--surface-color);
    padding: 30px;
    border-radius: 15px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.8s ease-out;
}

.subject-header-content {
    flex: 2; /* Takes more space */
    min-width: 280px; /* Ensures it doesn't get too small */
}

.subject-page-title {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #ffffff, #b0b0b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subject-page-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted-color);
}

.subject-header-stats {
    display: flex;
    gap: 30px;
    flex: 1; /* Takes remaining space */
    justify-content: flex-end; /* Aligns stats to the right */
    min-width: 200px; /* Prevents stats from collapsing too much */
}

.header-stat {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted-color);
}


/* Search Section for Subject Page */
.search-section {
    margin-bottom: 40px;
    animation: fadeIn 0.8s ease-out 0.2s; /* Add animation */
    animation-fill-mode: backwards;
}

.search-container {
    background: var(--surface-color);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color); /* Add border to the input wrapper */
    border-radius: 30px; /* Match search bar radius */
    padding: 5px 15px; /* Adjust padding for icon and input */
    background: rgba(255, 255, 255, 0.05); /* Slightly different background */
}

.search-icon {
    color: var(--text-muted-color);
}

.search-bar {
    flex: 1;
    padding: 10px 0; /* Adjust padding as wrapper has padding */
    border: none;
    font-size: 1rem;
    background: transparent;
    color: var(--text-color);
}
.search-bar:focus {
    outline: none;
    /* Box shadow is now on the wrapper */
}

.search-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.filter-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-muted-color);
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.filter-btn:hover:not(.active) {
    background: rgba(142, 45, 226, 0.1);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.filter-btn.active {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: var(--primary-color);
    cursor: default;
}


/* Notes Grid */
.notes-section {
    padding-bottom: 60px;
}

.note-card {
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    animation-delay: var(--animation-delay, 0s); /* Ensure staggered animation works */
}
.note-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 20px;
}

.note-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    flex-wrap: wrap; /* Safety for very narrow screens */
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted-color);
    padding: 8px 12px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.download-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
}

.download-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(142, 45, 226, 0.4);
}

.no-results {
    text-align: center;
    color: var(--text-muted-color);
    background: var(--surface-color);
    padding: 40px;
    border-radius: 15px;
    font-size: 1.2rem;
    margin-top: 40px;
    border: 1px solid var(--border-color);
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

/* --- Footer --- */
.footer {
    background: #0A0A0A;
    color: white;
    padding: 40px 0 20px;
    margin-top: 60px;
    border-top: 1px solid var(--border-color);
}

.footer-content { /* Used for internal spacing if needed, but container class handles max-width */
    padding: 0 20px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.footer-section p, .footer-section li {
    color: var(--text-muted-color);
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.footer-section ul {
    list-style: none;
}

.footer-section a {
    color: var(--text-muted-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 15px;
}
.footer-links a {
    color: var(--text-muted-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}
.footer-links a:hover { color: white; }
.footer-bottom p {
    color: rgba(255, 255, 255, 0.5);
    margin: 5px 0 0;
    font-size: 0.9rem;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        background: var(--background-color);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: left 0.3s ease-in-out;
    }
    .nav-menu.active { left: 0; }
    .nav-links {
        flex-direction: column;
        text-align: center;
        gap: 40px;
    }
    .nav-links a { font-size: 1.5rem; }
    .nav-toggle { display: block; }
    .nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 6px); }
    .nav-toggle.active span:nth-child(2) { opacity: 0; }
    .nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -6px); }

    .header h1 { font-size: 2.5rem; }
    
    .subjects-grid, .notes-grid { grid-template-columns: 1fr; }

    /* Subject Page Responsiveness */
    .subject-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .subject-header-stats {
        justify-content: flex-start;
        margin-top: 20px;
    }
    .subject-page-title {
        font-size: 2rem;
    }
    .search-input-wrapper {
        border-radius: 15px; /* Smaller radius for mobile */
    }
    .filter-btn {
        padding: 8px 15px;
        font-size: 0.85rem;
    }
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .footer-section ul {
        padding-left: 0;
    }
    .footer-section li {
        margin-bottom: 5px;
    }
}

/* --- Dark Mode Styles --- */
@media (prefers-color-scheme: dark) {
    body {
        background: #121212;
        color: #EAEAEA;
    }
    .main-header {
        background: rgba(18, 18, 18, 0.9);
    }
    .global-search-container, .search-container { /* Apply to both search containers */
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.2);
    }
    .subject-card, .note-card {
        background: #1E1E1E;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
}
/* --- End of Global Styles --- */

