/* =========================================
   1. RESET & CORE LAYOUT
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html, body {
    height: 100%; 
}

body {
    background-color: #f4f4f9;
    color: #333;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    
    /* FIX 1: Push the whole site down so it doesn't hide behind the header */
    padding-top: 80px; 
}

.main-content {
    flex: 1; 
}

/* =========================================
   2. HEADER & NAVIGATION (LOCKED FIXED)
   ========================================= */
.header {
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    
    /* FIX 2: Lock it to the top */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    
    /* FIX 3: Set a specific height */
    height: 80px; 
    
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5%; /* Use 0 for top/bottom, height handles it */
    z-index: 1000;
}

/* Logo Button */
.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: #2c3e50;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.logo:hover { color: #3498db; }

/* Hamburger Button */
.menu-toggle { display: none; }

/* Navbar Links */
.navbar {
    display: flex;
    align-items: center;
    gap: 25px;
}

.navbar a {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    transition: color 0.3s;
}

.navbar a:hover, .navbar a.active {
    color: #3498db;
}

/* Login Button */
.btn-login {
    background-color: #3498db;
    color: white !important;
    padding: 8px 20px;
    border-radius: 5px;
}

.btn-login:hover { background-color: #2980b9; }

/* Dropdown Select */
.nav-select {
    appearance: none;
    background-color: #f8f9fa;
    border: 1px solid #e1e4e8;
    padding: 8px 35px 8px 15px;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    cursor: pointer;
    outline: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%232c3e50%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
}

.nav-select:hover { background-color: #fff; border-color: #3498db; }

/* =========================================
   3. HERO & COURSE GRID
   ========================================= */
.hero {
    background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url('https://shining3366dev-prog.github.io/Syllabusplus-Database/images/EIGT_Above-thumbnail.png');
    background-size: cover;
    background-position: center;
    height: 70vh;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

.hero h1 { font-size: 3rem; margin-bottom: 1rem; }

.cta-button {
    display: inline-block;
    padding: 12px 30px;
    background-color: #e74c3c;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: background 0.3s;
}

.cta-button:hover { background-color: #c0392b; }

.container { padding: 4rem 5%; }
.section-title { text-align: center; margin-bottom: 3rem; font-size: 2rem; color: #2c3e50; }

.course-grid {
    display: grid;
    /* Smart grid that fits as many 220px cards as possible */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 2rem;
}

.course-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
}

.course-card:hover { transform: translateY(-5px); }

.card-image { height: 150px; width: 100%; background-size: cover; background-position: center; }
.card-text { padding: 1.5rem; flex-grow: 1; display: flex; flex-direction: column; }
.course-card h3 { margin-bottom: 0.5rem; color: #2c3e50; }

.card-text button {
    margin-top: auto; /* Pushes button to bottom */
    padding: 8px 16px;
    border: 1px solid #3498db;
    background: transparent;
    color: #3498db;
    cursor: pointer;
    border-radius: 4px;
}
.card-text button:hover { background: #3498db; color: white; }

/* Disabled Card State */
.course-card.disabled { opacity: 0.6; pointer-events: none; background: #f9f9f9; }
.course-card.disabled button { border-color: #ccc; color: #ccc; }

/* =========================================
   4. VS CODE STYLE FILE EXPLORER
   ========================================= */
.explorer-wrapper {
    display: flex;
    height: calc(100vh - 140px); /* Fits between header/footer */
    background: white;
    border-top: 1px solid #ddd;
}

/* Sidebar */
.sidebar-vertical {
    width: 300px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.sidebar-top { padding: 15px; background: #fff; border-bottom: 1px solid #eee; }

.btn-back {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #555;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
}
.btn-back i { margin-right: 8px; }

/* Folder Tree */
.file-tree-content { padding: 10px; overflow-y: auto; flex: 1; }

.folder-details { margin-bottom: 5px; }
.folder-summary {
    list-style: none; cursor: pointer; padding: 6px 10px;
    display: flex; align-items: center; font-weight: 600; color: #444;
}
.folder-summary::-webkit-details-marker { display: none; }

/* Custom Arrow */
.folder-summary::before {
    content: '▶'; font-size: 0.7rem; margin-right: 8px; color: #999; transition: transform 0.2s;
}
.folder-details[open] > .folder-summary::before { transform: rotate(90deg); }

/* Vertical Guide Lines */
.folder-content {
    margin-left: 14px;
    padding-left: 10px;
    border-left: 1px solid #ccc; /* THE LINE */
    display: flex; flex-direction: column;
}

.file-item {
    padding: 6px 10px; cursor: pointer; display: flex; align-items: center; gap: 8px;
    color: #555; border-radius: 4px;
}
.file-item:hover { background: #e9ecef; }
.file-item.active { background: #e3f2fd; color: #1976d2; font-weight: bold; }

/* Preview Area */
.preview-area { flex: 1; position: relative; background: #fff; }
.pdf-viewer { width: 100%; height: 100%; border: none; }
.pdf-viewer.hidden { display: none; }

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; color: #aaa;
}
.empty-state i { font-size: 3rem; margin-bottom: 15px; }

/* =========================================
   5. FOOTER
   ========================================= */
footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: auto;
}

/* =========================================
   6. MOBILE RESPONSIVE (PHONES & TABLETS)
   ========================================= */
@media screen and (max-width: 768px) {
    
    /* --- A. HERO & GRID FIXES --- */
    .hero { height: 50vh; }
    .hero h1 { font-size: 2rem; }
    
    /* Keep CTA Button natural width */
    .cta-button {
        width: fit-content; 
        margin-top: 15px;
    }

    .container { padding: 2rem 3%; }

    /* 2-Column Mobile Grid */
    .course-grid {
        grid-template-columns: repeat(2, 1fr); /* Forces 2 columns */
        gap: 1rem;
    }
    
    /* Compact Card Style */
    .card-image { height: 100px; }
    .card-text { padding: 10px; }
    .course-card h3 { font-size: 1rem; }
    .card-text p { font-size: 0.8rem; line-height: 1.2; }

    /* BUTTON FIX: Keep them natural width (like computer) */
    .card-text button {
        width: fit-content; /* Don't stretch! */
        padding: 6px 12px;
        margin-top: 8px;
        font-size: 0.85rem;
    }
    .menu-toggle {
        display: block;
        background: none; border: none;
        font-size: 1.8rem; color: #2c3e50; cursor: pointer;
    }

    .header { 
        padding: 0 20px; /* Reset padding for fixed height */
    }
    
    /* Hidden Menu styling */
    .navbar {
        display: none; 
        width: 100%;
        flex-direction: column;
        align-items: center;
        background: white;
        position: absolute;
        
        /* FIX 4: Start the menu exactly where the header ends */
        top: 80px; 
        
        left: 0;
        border-top: 1px solid #eee;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        padding: 20px 0;
    }

    .navbar.nav-open { display: flex; }

    /* Links inside menu */
    .navbar a { 
        width: 100%; 
        text-align: center; 
        padding: 12px; 
        border-bottom: 1px solid #f9f9f9; 
    }

    /* Login Button inside menu - Natural Width */
    .btn-login { 
        width: fit-content !important; 
        margin-top: 15px; 
    }

    /* Dropdown inside menu - Natural Width */
    .nav-select { 
        width: fit-content; 
        margin: 15px 0; 
        text-align: center; 
    }

    /* --- C. FILE EXPLORER (STACK VERTICAL) --- */
    .explorer-wrapper { flex-direction: column; height: calc(100vh - 120px); }
    
    .sidebar-vertical {
        width: 100%; height: 40%;
        border-right: none; border-bottom: 2px solid #3498db;
    }
    .preview-area { height: 60%; }

    /* Back Button - Natural Width */
    .btn-back {
        width: fit-content;
        margin-bottom: 10px;
        background: #f0f0f0; /* Optional: adds a little bg to make it clickable */
        padding: 5px 10px;
        border-radius: 4px;
    }
}