/* ============================================
   CSS Variables for Theme Management
   ============================================ */

:root {
    /* Dark Theme (Default) */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-heading: #ffffff;
    --accent-primary: #4a9eff;
    --accent-secondary: #3d7fc9;
    --link-color: #78b8ff;
    --link-visited: #8fb8f0;
    --border-color: #4a4a4a;
    --shadow: rgba(0, 0, 0, 0.3);
    --link-hover: #6bb4ff;
    --table-header-bg: #3a3a3a;
    --table-row-hover: #404040;
}

/* Light Theme Variables */
body.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e8e8e8;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-heading: #1a1a1a;
    --accent-primary: #0066cc;
    --accent-secondary: #0052a3;
    --link-color: #005bb8;
    --link-visited: #3a5fa3;
    --border-color: #d0d0d0;
    --shadow: rgba(0, 0, 0, 0.1);
    --link-hover: #3385d6;
    --table-header-bg: #e0e0e0;
    --table-row-hover: #f0f0f0;
}

/* ============================================
   Global Styles
   ============================================ */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-bottom: 50px; /* Space for fixed footer */
}

/* Prevent body scroll when nav is open */
body.nav-open {
    overflow: hidden;
}

/* Keep link colors consistent in rendered markdown/content sections */
main :where(a) {
    color: var(--link-color);
    text-decoration-color: color-mix(in srgb, var(--link-color) 65%, transparent);
    text-underline-offset: 0.12em;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

main :where(a:visited) {
    color: var(--link-visited);
}

main :where(a:hover, a:focus-visible) {
    color: var(--link-hover);
    text-decoration-color: var(--link-hover);
}

/* ============================================
   Header Styles
   ============================================ */

header {
    background-color: var(--bg-secondary);
    padding: 2rem 1rem;
    text-align: center;
    border-bottom: 3px solid var(--accent-primary);
    position: relative;
}

.header-content h1 {
    color: var(--text-heading);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

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

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

/* ============================================
   Hamburger Menu Button
   ============================================ */

.nav-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background-color: var(--accent-primary);
    border: none;
    border-radius: 4px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: visible;
}

.nav-toggle:hover {
    background-color: var(--accent-secondary);
    transform: scale(1.05);
}

.hamburger {
    width: 25px;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s ease;
    position: relative;
}

/* Hamburger remains as 3 bars when nav is open */

/* ============================================
   Navigation Sidebar
   ============================================ */

.nav-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background-color: var(--bg-secondary);
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px var(--shadow);
}

.nav-sidebar.open {
    left: 0;
}

/* Overlay for mobile */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.nav-list {
    list-style: none;
    padding: 80px 0 20px 0;
    margin: 0;
}

.nav-list li {
    width: 100%;
}

.nav-link {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.nav-link:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

.nav-link.active {
    background-color: var(--bg-tertiary);
    border-left-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ============================================
   Main Content Area
   ============================================ */

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 200px);
}

/* Section Styling */
.section {
    margin-bottom: 2rem;
}

.section h2 {
    color: var(--text-heading);
    font-size: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-primary);
}

.section h3 {
    color: var(--text-heading);
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.section p {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-info {
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-left: 4px solid var(--accent-primary);
    margin-bottom: 1.5rem;
    border-radius: 4px;
}

/* ============================================
   Table Styles
   ============================================ */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background-color: var(--bg-secondary);
    box-shadow: 0 2px 4px var(--shadow);
    border-radius: 4px;
    overflow: hidden;
}

thead {
    background-color: var(--table-header-bg);
}

th {
    padding: 1rem;
    text-align: left;
    color: var(--text-heading);
    font-weight: 600;
    border-bottom: 2px solid var(--accent-primary);
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

tbody tr:hover {
    background-color: var(--table-row-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Links in tables */
table a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

table a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* ============================================
   Staff Grid (for Instructors and TAs)
   ============================================ */

.staff-container {
    margin-bottom: 3rem;
}

.staff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.staff-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px var(--shadow);
}

.staff-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px var(--shadow);
    border-color: var(--accent-primary);
}

.staff-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1rem;
    border: 3px solid var(--accent-primary);
    display: block;
    background-color: var(--bg-tertiary);
}

/* Placeholder for missing images */
.staff-photo.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-secondary);
}

.staff-card h3 {
    color: var(--text-heading);
    margin: 0.5rem 0;
    font-size: 1.25rem;
}

.staff-card p {
    color: var(--text-secondary);
    margin: 0.5rem 0;
    font-size: 0.95rem;
}

.staff-card a {
    color: var(--accent-primary);
    text-decoration: none;
    word-break: break-all;
}

.staff-card a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.staff-note {
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-left: 4px solid var(--accent-secondary);
    margin-top: 2rem;
    border-radius: 4px;
    font-style: italic;
    color: var(--text-secondary);
}

/* ============================================
   Lists and Formatted Content
   ============================================ */

ul, ol {
    margin: 1rem 0 1rem 2rem;
    color: var(--text-primary);
}

li {
    margin: 0.5rem 0;
}

code {
    background-color: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: var(--accent-primary);
}

pre {
    background-color: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1rem 0;
}

pre code {
    background-color: transparent;
    padding: 0;
}

/* ============================================
   Footer
   ============================================ */

footer {
    background-color: var(--bg-secondary);
    padding: 0.75rem 1rem;
    text-align: center;
    border-top: 2px solid var(--accent-primary);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 -2px 5px var(--shadow);
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.footer-separator {
    color: var(--border-color);
}

.footer-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* ============================================
   Utility Classes
   ============================================ */

.tba {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.note {
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-left: 4px solid var(--accent-secondary);
    margin: 1rem 0;
    border-radius: 4px;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    body {
        padding-bottom: 60px; /* More space for footer on mobile */
    }

    .header-content h1 {
        font-size: 1.75rem;
        padding: 0 60px; /* Space for hamburger and theme buttons */
    }
    
    .subtitle {
        font-size: 0.95rem;
        padding: 0 60px;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        top: 0.75rem;
        right: 0.75rem;
    }

    .nav-toggle {
        top: 0.75rem;
        left: 0.75rem;
        width: 45px;
        height: 45px;
    }

    .hamburger {
        width: 22px;
    }
    
    main {
        padding: 1rem;
    }
    
    .section h2 {
        font-size: 1.5rem;
    }
    
    table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    th, td {
        padding: 0.5rem;
    }
    
    .staff-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        font-size: 0.75rem;
        gap: 0.5rem;
        padding: 0 0.5rem;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.4rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: 0.4rem;
    }

    .footer-content {
        font-size: 0.7rem;
        flex-direction: column;
        gap: 0.25rem;
    }

    .footer-separator {
        display: none;
    }

    .nav-sidebar {
        width: 260px;
        left: -260px;
    }
}
