:root {
    --bg-color: #F8F9FA;
    --text-color: #2D3436;
    --primary-color: #6C5CE7;
    --primary-hover: #5A4FCF;
    --card-bg: #FFFFFF;
    --accent: #FDCB6E;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --border-radius: 16px;
    --transition: all 0.3s ease;
    --font-family: 'Outfit', sans-serif;
}

body.dark-mode {
    --bg-color: #1E272E;
    --text-color: #F1F2F6;
    --card-bg: #2F3640;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    line-height: 1.6;
    font-size: 18px;
    transition: var(--transition);
}

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

/* Typography */
h1, h2, h3 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

/* Navigation */
.navbar {
    background: var(--card-bg);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 0;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-color);
    cursor: pointer;
}

.logo h1 {
    font-size: 1.8rem;
    margin: 0;
}

.nav-menus {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
    flex-grow: 1;
}

.search-container {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    flex-grow: 1;
    max-width: 350px;
    margin: 0 1rem;
    border: 1px solid rgba(0,0,0,0.1);
}

body.dark-mode .search-container {
    background: var(--bg-color);
    border-color: rgba(255,255,255,0.1);
}

.search-container i {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.search-container input {
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    margin-left: 0.5rem;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
}

nav#year-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
    max-width: 100%;
}

.nav-link {
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
    background: var(--primary-color);
    color: white;
}

/* Dropdown styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--card-bg);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 101;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-top: 0.5rem;
}

body.dark-mode .dropdown-content {
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.5);
}

.dropdown-content button {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.dropdown-content button:hover, .dropdown-content button.active {
    background-color: var(--primary-color);
    color: white;
}

.dropdown:hover .dropdown-content, .dropdown.active .dropdown-content {
    display: block;
}

.dropbtn {
    display: flex;   
    align-items: center;
    gap: 0.5rem;
}


/* Main Layout */
main {
    padding: 3rem 0;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.section-header::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--accent);
    margin: 10px auto 0;
    border-radius: 4px;
}

/* Grid layout for Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 2px solid transparent;
    text-align: center;
    animation: fadeInUp 0.5s ease backwards;
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.card-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-category {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.views-badge {
    background: var(--accent);
    color: #2D3436;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-block;
    margin-top: 1rem;
}

/* Discipline subjects wrapper */
.subject-group {
    margin-bottom: 3rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--card-bg);
    width: 90%;
    max-width: 900px;
    height: 85vh;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    position: relative;
    display: flex;
    flex-direction: column;
    transform: scale(1);
    transition: transform 0.3s ease;
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.95);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-color);
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #E74C3C;
}

.modal-content h2 {
    margin-right: 3rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.iframe-container {
    flex-grow: 1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 2px solid var(--bg-color);
}

.iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 1024px) {
    h1 { font-size: 1.6rem; }
    
    .logo { width: auto; }
    
    .search-container {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin: 1rem 0 0 0;
    }

    .nav-content { 
        justify-content: space-between; 
        align-items: center; 
    }
    
    .mobile-menu-btn { 
        display: block; 
    }
    
    .nav-menus { 
        display: none; 
        flex-direction: column; 
        width: 100%; 
        padding-top: 1rem;
        border-top: 1px solid rgba(0,0,0,0.1);
        margin-top: 1rem;
    }
    
    .nav-menus.active {
        display: flex;
    }

    body.dark-mode .nav-menus {
        border-top-color: rgba(255,255,255,0.1);
    }
    
    nav#year-nav { 
        justify-content: center; 
        flex-direction: column; 
        width: 100%; 
        gap: 0.5rem; 
    }
    
    nav#year-nav {
        border-bottom: none;
        padding-bottom: 0;
    }

    .nav-link {
        width: 100%;
        text-align: center;
    }

    .dropdown {
        width: 100%;
        text-align: center;
    }

    .dropbtn {
        justify-content: center;
    }

    .dropdown-content {
        position: static;
        box-shadow: none;
        background-color: rgba(0,0,0,0.02);
        display: none;
        flex-direction: column;
        margin-top: 0;
        border-radius: 0;
    }

    body.dark-mode .dropdown-content {
        background-color: rgba(255,255,255,0.02);
        box-shadow: none;
    }

    .dropdown.active .dropdown-content {
        display: flex;
    }

    .dropdown-content button {
        text-align: center;
    }

    .modal-content { width: 95%; height: 90vh; padding: 1.5rem; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.ph-spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* Flashcards Styling */
.flashcards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
}

.flashcard {
    width: 320px;
    height: 220px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: var(--shadow);
}

.flashcard-front {
    background: var(--card-bg);
    color: var(--text-color);
    border: 2px solid var(--primary-color);
}

.flashcard-back {
    background: var(--primary-color);
    color: white;
    transform: rotateY(180deg);
}

.flashcard p {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Stacks Layout */
.flashcards-stacks-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3rem;
    justify-content: center;
}

.flashcard-stack-wrapper {
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 400px;
    width: 100%;
}

.stack-title {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.stack-counter {
    font-size: 0.9rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-weight: 700;
}

.flashcard-container-single {
    position: relative;
    width: 320px;
    height: 220px;
    margin: 0 auto 2.5rem;
}

/* Fake cards under the top one to appear as a stack */
.flashcard-container-single::before,
.flashcard-container-single::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.flashcard-container-single::before {
    top: 5px;
    left: 4px;
    transform: rotate(2deg);
    z-index: 1;
}

.flashcard-container-single::after {
    top: 10px;
    left: 8px;
    transform: rotate(-1.5deg);
    z-index: 0;
}

.flashcard-container-single .flashcard {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

.stack-controls {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.stack-controls button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem;
    font-size: 1rem;
    border-radius: var(--border-radius);
}

.stack-controls button:disabled {
    opacity: 0.5;
    background: transparent;
    color: var(--text-color);
    border: 1px solid #ccc;
    cursor: not-allowed;
}
