/* --- Base Styles --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121212; /* Dark background */
    color: #e0e0e0; /* Light text */
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* General Link Color */
a {
    color: #4a90e2;
}

/* --- Typography and Headings --- */
h1, h2, h3 {
    color: #ffffff; /* White headings */
}

.section-title {
    text-align: center;
    margin-top: 30px;
    margin-bottom: 20px;
}

/* --- Header & Navigation --- */
header.main-header {
    background-color: #1f1f1f; /* Header background */
    color: white;
    padding: 15px 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: space-between; /* Pushes title left, navigation right */
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.site-title a {
    color: #00bcd4; /* Accent color for title */
    font-size: 1.6em; 
    font-weight: 600;
    text-decoration: none;
}

nav.main-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

nav.main-nav a {
    color: #e0e0e0; /* Light grey links */
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9em;
    padding: 5px 0;
}

nav.main-nav a:hover {
    color: #00bcd4; /* Accent hover */
}

.auth-links {
    margin-left: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* HIDE Admin Login Button on public view */
.auth-links .btn-primary { 
    display: none !important;
}

.admin-dashboard-link {
    background-color: #00bcd4;
    color: #1f1f1f !important;
    padding: 5px 10px !important;
    border-radius: 4px;
    font-weight: 700 !important;
    white-space: nowrap;
}


/* --- Mobile Hamburger Menu Styles --- */
.menu-toggle {
    display: none; /* Hidden on desktop */
    cursor: pointer;
    padding: 10px;
}
.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px 0;
    background-color: #e0e0e0;
    transition: 0.4s;
}
#menu-checkbox {
    display: none; /* Hidden input controls menu state */
}

/* State when menu is open on mobile */
#menu-checkbox:checked ~ nav.main-nav {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 55px; /* Position below the header */
    left: 0;
    width: 100%;
    background-color: #1f1f1f;
    box-shadow: 0 8px 10px rgba(0, 0, 0, 0.5);
}

#menu-checkbox:checked ~ nav.main-nav a,
#menu-checkbox:checked ~ nav.main-nav .auth-links {
    padding: 10px 20px;
    border-bottom: 1px solid #333;
    width: calc(100% - 40px);
}

/* --- Main Content Container (Layout) --- */
.container {
    width: 95%;
    max-width: 1200px;
    margin: 15px auto;
    padding: 0;
    flex-grow: 1;
}

/* --- App Layout: Forms & Cards --- */
.app-screen {
    background-color: #2c2c2c; 
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    margin: 50px auto 20px auto;
    text-align: center;
}

.app-screen h2 {
    color: #00bcd4;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #004d99, #0066cc);
    color: white;
    padding: 50px 20px;
    text-align: center;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.hero h2 {
    color: white;
}

/* Data Cards */
.data-card {
    background: #2c2c2c; 
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* --- Form Elements --- */
input[type="text"], input[type="email"], input[type="password"], input[type="file"], input[type="url"], select, textarea {
    background-color: #404040; /* Dark input fields */
    color: #e0e0e0; /* Light text */
    border: 1px solid #555;
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-sizing: border-box;
}

/* --- Buttons --- */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: block;
    width: 100%;
    margin-top: 10px;
}

.btn-primary {
    background-color: #4a90e2; /* Accent blue */
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.btn-secondary-inverted { 
    background-color: #1f1f1f;
    color: #00bcd4;
    border: 2px solid #00bcd4;
}

/* --- Button Group for Centering Buttons --- */
.btn-group-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 300px;
    margin: 0 auto;
}

/* --- Course/Semester Grid --- */
.semester-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.semester-card {
    background-color: #3a3a3a;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    color: #00bcd4; 
    padding: 25px 15px;
    text-decoration: none;
    text-align: center;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.3em;
    transition: transform 0.2s;
}

/* --- Dashboard Stat Cards (FIXED) --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #2c2c2c; 
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    text-align: center;
}
.stat-card h3 { color: #fff; } 
.stat-card p { color: #00bcd4; font-size: 2em; }


/* --- Table Styling --- */
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
    color: #e0e0e0;
}
th {
    background-color: #333;
    color: #00bcd4;
    padding: 15px 10px;
    font-weight: 600;
}
td {
    border-bottom: 1px solid #444;
    padding: 15px 10px;
    font-size: 0.9em;
}

/* --- Footer --- */
footer {
    background-color: #1f1f1f;
    color: #888;
    text-align: center;
    padding: 15px;
    margin-top: auto;
    font-size: 0.85em;
}

/* --- MEDIA QUERIES (Mobile Fixes) --- */
@media (min-width: 601px) {
    /* Desktop layout rules */
    header.main-header {
        flex-direction: row; 
        align-items: center;
    }
    nav.main-nav {
        display: flex !important; 
        flex-direction: row;
        width: auto;
        gap: 20px;
    }
    .auth-links {
        margin-left: 15px;
        flex-direction: row;
    }
    /* Stat Cards side-by-side on desktop */
    .dashboard-grid {
        grid-template-columns: 1fr 1fr; 
    }
    td .btn-primary, td .btn-danger {
        display: inline-block;
        width: auto;
    }
}

@media screen and (max-width: 600px) {
    /* Mobile Layout Rules */
    header.main-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    /* Hide desktop navigation and show hamburger icon */
    nav.main-nav {
        display: none;
    }
    .menu-toggle {
        display: block;
    }
    
    /* Stack Stat Cards vertically on mobile */
    .dashboard-grid {
        grid-template-columns: 1fr; 
    }
    
    /* Ensure links stack vertically when menu is open */
    nav.main-nav > a {
        padding: 5px 0;
        width: 100%;
        text-align: left;
    }
    .auth-links {
        margin-left: 0;
        margin-top: 10px;
        display: flex;
        flex-direction: row;
        gap: 10px;
        width: 100%;
        justify-content: space-between;
    }
    .auth-links .btn-secondary-inverted {
        width: 48%; 
    }
    
    /* Table Adjustments */
    .hide-on-mobile {
        display: none;
    }
}
/* --- New Styles for Mobile Card View --- */

/* Hide the table and show the cards by default */
.mobile-card-list {
    display: none;
}

/* By default, show the table wrapper */
.data-table-wrapper {
    display: block;
}


/* --- MOBILE MEDIA QUERY: Under 768px --- */
@media screen and (max-width: 768px) {

    /* 1. Hide the Standard HTML Table */
    .data-table-wrapper {
        display: none;
    }

    /* 2. Show the Stacked Card View */
    .mobile-card-list {
        display: flex;
        flex-direction: column;
        gap: 15px;
        margin-top: 15px;
    }

    .resource-card-item {
        background: #2c2c2c;
        padding: 15px;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    }

    .card-title {
        font-weight: 700;
        color: #00bcd4;
        font-size: 1.1em;
        margin-bottom: 5px;
        display: block;
    }

    .card-detail {
        font-size: 0.9em;
        padding: 4px 0;
    }

    .card-detail span {
        font-weight: 300;
        color: #b0b0b0;
    }

    .card-download-btn {
        margin-top: 10px;
        width: 100%;
    }
}