/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --accent: #f093fb;
    --accent-2: #f5576c;
    --success: #11998e;
    --warning: #fa709a;
    --bg-light: #f8f9fa;
    --text-dark: #2d3748;
    --text-light: #718096;
    --white: #ffffff;
    --shadow: 0 10px 30px rgba(0,0,0,0.1);
    --shadow-hover: 0 15px 40px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: white;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-screen p {
    margin-top: 20px;
    font-size: 1.2em;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex: 0 0 260px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    z-index: 100;
}

.app-container.sidebar-collapsed .sidebar {
    width: 0;
    flex: 0 0 0;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    border: none;
}

.app-container.sidebar-collapsed .sidebar .logo,
.app-container.sidebar-collapsed .sidebar .sidebar-nav,
.app-container.sidebar-collapsed .sidebar .sidebar-footer {
    display: none;
}

.sidebar-toggle {
    margin-right: 15px;
    padding: 8px 10px;
}

.logo {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.logo h2 {
    font-size: 1.5em;
    font-weight: 600;
}

.nav-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255,255,255,0.2);
    border-left-color: white;
    color: white;
}

.nav-item .icon {
    font-size: 1.5em;
    margin-right: 15px;
    width: 30px;
}

.nav-item .label {
    font-size: 0.95em;
    font-weight: 500;
}

.nav-section-label {
    padding: 15px 20px 8px 20px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
    margin-top: 10px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.current-week {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.current-week strong {
    display: block;
    font-size: 0.85em;
    opacity: 0.8;
    margin-bottom: 5px;
}

.current-week span {
    display: block;
    font-size: 1.2em;
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    background: white;
    padding: 25px 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.header-left h1 {
    font-size: 2em;
    color: var(--primary);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-light);
    font-size: 0.95em;
}

.search-box {
    position: relative;
}

.search-box input {
    padding: 12px 45px 12px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    width: 300px;
    font-size: 0.95em;
    transition: all 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
}

/* Global search results panel */
.search-results {
    position: absolute;
    right: 40px;
    top: 100%;
    margin-top: 8px;
    width: 380px;
    max-height: 360px;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 200;
    font-size: 0.9em;
}

.search-results.hidden {
    display: none;
}

.search-results-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 4px 10px;
    border-bottom: 1px solid #e2e8f0;
    background: #f9fafb;
    font-size: 0.8em;
    color: var(--text-light);
}

.search-filter-btn {
    border: none;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.8em;
    cursor: pointer;
    background: #edf2f7;
    color: #4a5568;
}

.search-filter-btn.active {
    background: var(--primary);
    color: #ffffff;
}

.search-results-section {
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.search-results-section:last-child {
    border-bottom: none;
}

.search-results-title {
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.search-result-item {
    padding: 6px 4px;
    cursor: pointer;
    border-radius: 6px;
}

.search-result-item:hover {
    background: #f7fafc;
}

.search-result-meta {
    font-size: 0.8em;
    color: var(--text-light);
}

/* Content Container */
.content-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: var(--bg-light);
}

/* Cards */
.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    transition: all 0.3s;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.card-title {
    font-size: 1.5em;
    color: var(--primary);
    font-weight: 600;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.stat-number {
    font-size: 3em;
    font-weight: bold;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 0.95em;
    opacity: 0.9;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: #cbd5e0;
}

/* Progress Bar */
.progress-bar {
    height: 30px;
    background: #e2e8f0;
    border-radius: 15px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9em;
    transition: width 0.5s ease;
}

/* Tags */
.tag {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
    margin: 5px;
}

.tag-secondary {
    background: #e0e0e0;
    color: #666;
}

.tag-ell {
    background: #c62828;
    color: white;
}

.tag-approaching {
    background: #ef6c00;
    color: white;
}

.tag-onlevel {
    background: #2e7d32;
    color: white;
}

.tag-beyond {
    background: #1565c0;
    color: white;
}

.tag-raz {
    background: #7c3aed;
    color: white;
}

.tag-lexile {
    background: #0891b2;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.data-table th,
.data-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    font-weight: 600;
}

.data-table tr:hover {
    background: #f7fafc;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    padding-top: 60px; /* Space for fixed close button */
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
}

@media (max-width: 768px) {
    .modal-content {
        padding: 24px;
        padding-top: 50px; /* Space for fixed close button */
        max-width: 95vw;
        max-height: 90vh;
        border-radius: 12px;
    }
}

.modal-close {
    position: sticky;
    top: 0;
    right: 0;
    float: right;
    font-size: 2em;
    cursor: pointer;
    color: var(--text-light);
    background: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: -20px -20px 0 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--accent-2);
    background: var(--bg-light);
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 1200px) {
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .sidebar {
        width: 80px;
    }
    
    .nav-item .label {
        display: none;
    }
    
    .logo h2 {
        font-size: 1.5em;
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        flex: 0 0 auto;
    }
    
    /* Turn the sidebar nav into a horizontal strip that can scroll on small screens */
    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 10px 0;
    }
    
    .sidebar-nav .nav-item {
        flex-direction: column;
        align-items: center;
        min-width: 80px;
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .top-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .search-box input {
        width: 100%;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 14px;
    }

    .content-container {
        padding: 20px 16px;
    }

    .top-header {
        padding: 15px 16px;
    }

    .header-left h1 {
        font-size: 1.6em;
    }

    .card {
        padding: 18px;
        margin-bottom: 18px;
    }

    .search-results {
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
    }

    .data-table th,
    .data-table td {
        padding: 10px;
        font-size: 0.85em;
    }

    .modal-content {
        padding: 24px;
        max-width: 95vw;
    }
}

/* Semester Divider */
.semester-divider {
    text-align: center;
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary);
    margin: 40px 0 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 15px;
    border: 2px solid var(--primary);
}

/* Wonders Level Tags - Already defined above, removed duplicate */

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}
