@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #007A4D;
    --primary-light: #e6f4ea;
    --primary-dark: #005c3a;
    --sidebar-bg: #1a202c;
    --sidebar-text: #a0aec0;
    --sidebar-text-hover: #ffffff;
    --content-bg: #f7fafc;
    --white-color: #ffffff;
    --dark-text: #2d3748;
    --light-text: #718096;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.05);
    --font-family: 'Poppins', sans-serif;
    --radius: 12px;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--content-bg);
    color: var(--dark-text);
}

/* --- AUTH PAGES (LOGIN/VERIFY) --- */
.auth-body {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--sidebar-bg) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.auth-box {
    width: 100%;
    max-width: 420px;
    background: var(--white-color);
    padding: 2.5rem 3rem;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
}
.auth-box .logo {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.auth-box p { color: var(--light-text); margin-bottom: 2rem; }
.auth-box label { display: block; text-align: left; font-weight: 600; margin-bottom: 0.5rem; }
.auth-box input {
    width: 100%; padding: 0.9rem; margin-bottom: 1.2rem;
    border: 1px solid var(--border-color); border-radius: 8px; font-size: 1rem;
}
.auth-box button {
    background: var(--primary-color); color: var(--white-color); width: 100%;
    padding: 0.9rem; border: none; border-radius: 8px; cursor: pointer;
    font-size: 1rem; font-weight: 600; transition: background-color 0.2s;
}
.auth-box button:hover { background: var(--primary-dark); }
.error-msg {
    color: #c53030; background: #fed7d7; padding: 0.8rem;
    border-radius: 8px; margin-top: 1rem; text-align: center; font-size: 0.9rem;
}


/* --- NEW LMS LAYOUT --- */
.lms-wrapper { display: flex; }
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}
.sidebar .logo {
    font-size: 2rem; font-weight: 700; color: var(--white-color);
    text-align: center; margin-bottom: 2rem; text-decoration: none;
}
.sidebar-nav { list-style: none; flex-grow: 1; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 0.8rem; padding: 0.9rem 1rem;
    margin: 0.5rem 0; border-radius: 8px; text-decoration: none;
    color: var(--sidebar-text); transition: background-color 0.2s, color 0.2s;
}
.sidebar-nav a:hover {
    background-color: #2d3748; /* Dark gray for hover */
    color: var(--white-color);
}
.sidebar-nav a.active {
    background-color: var(--primary-color); /* Qalam Green for active */
    color: var(--white-color);
}
.sidebar-nav a .icon { width: 20px; height: 20px; }
.sidebar-footer a {
    color: var(--light-text); font-size: 0.9rem; text-align: center;
    text-decoration: none; display: block; padding: 1rem 0;
}
.sidebar-footer a:hover { color: var(--white-color); }
.main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    padding: 2.5rem;
}


/* --- COMPONENTS --- */
.header-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.header-bar h1 { font-size: 2rem; font-weight: 600; }
.breadcrumb { font-size: 0.9rem; color: var(--light-text); margin-top: 0.25rem; }
.breadcrumb a { color: var(--primary-color); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 0.5rem; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}
.card {
    background: var(--white-color); border-radius: var(--radius); padding: 1.5rem;
    text-decoration: none; color: var(--dark-text); box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease; border: 1px solid var(--border-color);
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.card .icon-box {
    width: 50px; height: 50px; border-radius: 12px; display: grid;
    place-items: center; background: var(--primary-light); margin-bottom: 1rem;
}
.card .icon-box .icon { width: 24px; height: 24px; color: var(--primary-dark); }
.card h3 { font-size: 1.2rem; margin-bottom: 0.25rem; color: var(--dark-text); }
.card p { font-size: 0.9rem; color: var(--light-text); }

.chapter-accordion .chapter {
    background: var(--white-color); border-radius: var(--radius);
    margin-bottom: 1rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
}
.chapter-header {
    padding: 1.25rem 1.5rem; cursor: pointer; display: flex;
    justify-content: space-between; align-items: center;
    font-weight: 600; font-size: 1.1rem;
}
.chapter-header .chevron { width: 20px; height: 20px; transition: transform 0.3s ease; }
.chapter.open .chevron { transform: rotate(180deg); }
.chapter-content { display: none; padding: 0 1.5rem 1.5rem; border-top: 1px solid var(--border-color); }
.lesson-list { list-style: none; }
.lesson-list li { border-bottom: 1px solid var(--border-color); }
.lesson-list li:last-child { border-bottom: none; }
.lesson-list a {
    display: flex; align-items: center; gap: 1rem; padding: 1rem 0.5rem;
    text-decoration: none; color: var(--light-text); transition: color 0.2s ease;
}
.lesson-list a:hover { color: var(--primary-dark); }
.lesson-list .play-icon { width: 20px; height: 20px; color: var(--primary-color); }
.lesson-list .lesson-title { flex-grow: 1; font-weight: 500; color: var(--dark-text); }

/* --- Player --- */
.player-container {
    position: relative; /* This is crucial for positioning the video inside */
    width: 100%;
    padding-top: 56.25%; /* This creates a 16:9 aspect ratio */
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 1.5rem;
}

/* This rule targets BOTH the YouTube iframe AND the VdoCipher player div */
.player-container iframe,
.player-container #player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0; /* Removes the default border from iframes */
}

a.btn-secondary {
    display: inline-block; background: var(--border-color); color: var(--dark-text);
    padding: 0.75rem 1.5rem; text-decoration: none; border-radius: 8px; font-weight: 500;
    margin-top: 1.5rem; transition: background-color 0.2s ease;
}
a.btn-secondary:hover { background-color: #d8e0e8; }

/* --- NEW DASHBOARD COMPONENTS --- */
.welcome-header {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white-color);
    padding: 2rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}
.welcome-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
}
.welcome-header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.continue-watching-card, .announcements-card {
    background-color: var(--white-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.continue-watching-card h4, .announcements-card h4 {
    font-size: 0.9rem;
    color: var(--light-text);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}
.continue-watching-card .video-info {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}
.continue-watching-card .thumbnail {
    width: 120px;
    height: 70px;
    background-color: var(--sidebar-bg);
    border-radius: 8px;
    flex-shrink: 0;
}
.continue-watching-card .lesson-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}
.continue-watching-card .resume-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.announcements-card ul {
    list-style: none;
}
.announcements-card ul li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}
.announcements-card ul li:last-child {
    border-bottom: none;
}

.section-header {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.course-progress-card {
    background-color: var(--white-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: var(--dark-text);
    transition: box-shadow 0.2s;
}
.course-progress-card:hover {
    box-shadow: var(--shadow-md);
}
.progress-bar {
    width: 150px;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar div {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 4px;
}
/* --- NEW STYLES FOR PLAYER PAGE BUTTONS --- */

.lesson-actions {
    /* This makes the container for the buttons more robust */
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
    padding-top: 1.5rem;
}

/* This targets the "Mark as Complete" and "Completed" buttons specifically */
.lesson-actions .btn-primary {
    padding: 0.9rem 1.5rem; /* Makes the button taller and wider */
    font-size: 1.1rem;   /* Makes the text bigger */
    font-weight: 700;    /* Bolder text */
    text-transform: uppercase; /* All caps for emphasis */
    letter-spacing: 0.5px;

    /* A subtle shadow in your brand color to make it pop */
    box-shadow: 0 4px 14px 0 rgba(0, 122, 77, 0.35);

    /* Ensures it uses your brand's green color */
    background-color: var(--primary-color);

    /* Smooth transition for hover effects */
    transition: all 0.3s ease;
    margin-top: 0; /* Resets margin */
}

/* A nice lifting effect when the user hovers over the button */
.lesson-actions .btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px 0 rgba(0, 122, 77, 0.4);
}

/* Styles for the button when it is in the "Completed" state */
.lesson-actions .btn-primary:disabled {
    background-color: #38A169; /* A slightly different green for success */
    color: var(--white-color);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 1; /* Ensure it's fully visible */
}
/* --- NEW STYLES FOR USER DROPDOWN --- */
.user-dropdown {
    position: relative;
    display: inline-block;
}

.user-btn {
    background-color: var(--white-color);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}
.user-btn:hover {
    background-color: var(--content-bg);
}
.user-btn .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: var(--white-color);
    display: grid;
    place-items: center;
    font-weight: 600;
    margin-right: 0.75rem;
}
.user-btn .user-name {
    font-weight: 600;
    color: var(--dark-text);
    margin-right: 0.5rem;
}
.user-btn .chevron-icon {
    width: 16px;
    height: 16px;
    color: var(--light-text);
}

.dropdown-content {
    display: none; /* Hidden by default */
    position: absolute; /* This makes it float over other content */
    right: 0;
    top: calc(100% + 10px); /* Position it below the button */
    background-color: var(--white-color);
    min-width: 200px;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius);
    padding: 0.5rem 0;
    z-index: 100;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
/* This class is added by JavaScript to show the menu */
.dropdown-content.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}
.dropdown-content a {
    color: var(--dark-text);
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    display: block;
    font-weight: 500;
}
.dropdown-content a:hover {
    background-color: var(--content-bg);
}
.dropdown-divider {
    height: 1px;
    margin: 0.5rem 0;
    overflow: hidden;
    background-color: var(--border-color);
}

/* --- NEW STYLES FOR QUIZ AND RESULTS --- */

/* This will be the new container for the quiz and results panel */
.quiz-wrapper {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

/* The main quiz form will now take up the left side */
.quiz-form-container {
    flex: 2; /* Takes up 2/3 of the space */
}

/* The new results panel on the right */
.quiz-results-panel {
    flex: 1; /* Takes up 1/3 of the space */
    background-color: var(--white-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    position: sticky; /* Keeps it in view as you scroll */
    top: 2.5rem;
}
.quiz-results-panel h3 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
    color: var(--dark-text);
}

.quiz-results-panel .score-summary {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.quiz-results-panel .score-percentage {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}
.quiz-results-panel .score-details {
    font-weight: 500;
    color: var(--light-text);
}

.quiz-results-panel .question-feedback-list {
    list-style: none;
    padding: 0;
    max-height: 40vh; /* Make the list scrollable if it's too long */
    overflow-y: auto;
}
.question-feedback-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}
.question-feedback-list li:last-child {
    border-bottom: none;
}
.question-feedback-list .q-number {
    font-weight: 600;
    color: var(--light-text);
}
.question-feedback-list .q-status-icon {
    width: 20px;
    height: 20px;
}

/*
========================================
--- RESPONSIVE DESIGN FOR MOBILE ---
========================================
*/

/* We'll use 800px as the breakpoint for switching to the mobile layout */
@media (max-width: 800px) {

    /* --- Main Layout & Sidebar --- */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        width: 260px;
        transform: translateX(-100%); /* Hide sidebar off-screen by default */
        transition: transform 0.3s ease-in-out;
        z-index: 1000; /* Ensure sidebar is on top of content */
    }

    .sidebar.is-open {
        transform: translateX(0); /* Slide sidebar into view */
        box-shadow: 0 0 40px rgba(0,0,0,0.2);
    }

    .main-content {
        margin-left: 0; /* Main content takes full width */
        width: 100%;
        padding: 1.5rem; /* Reduce padding on mobile */
    }

    /* --- Header Bar --- */
    .header-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-bottom: 2rem;
        gap: 1rem;
    }
    .header-zone {
        display: flex;
        align-items: center;
    }
    .header-left {
        flex: 0 0 auto; /* Don't grow, don't shrink, base size on content */
    }
    .header-center {
        flex: 1 1 auto; /* Grow and shrink as needed */
        flex-direction: column;
        align-items: flex-start;
    }
    .header-right {
        flex: 0 0 auto; /* Don't grow, don't shrink */
        justify-content: flex-end;
    }
    .header-bar h1 {
        font-size: 1.2rem; /* Smaller heading on mobile */
    }
    .breadcrumb {
        display: none; /* Hide breadcrumbs on mobile to save space */
    }
    /* end of header 8 */

    /* Hide the user's name in the dropdown button, show only avatar */
    .user-btn .user-name {
        display: none;
    }

    /* --- Mobile Navigation Toggle ("Hamburger" Button) --- */
    .mobile-nav-toggle {
        display: block; /* Show the button on mobile */
        background: none;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
        margin-right: 0.5rem;
    }
    .mobile-nav-toggle .icon {
        width: 28px;
        height: 28px;
        color: var(--dark-text);
    }

    /* --- Page-Specific Layouts --- */
    .welcome-header {
        padding: 1.5rem;
        text-align: center;
    }
    .welcome-header h1 {
        font-size: 1.8rem;
    }

    /* Make dashboard widgets a single column */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Make the quiz layout stack vertically */
    .quiz-wrapper {
        flex-direction: column;
    }
    .quiz-results-panel {
        position: static; /* Let it flow in the document */
        margin-top: 2rem;
    }
}

/* On desktop, the hamburger button is not needed */
.mobile-nav-toggle {
    display: none;
}

.sidebar-close {
    display: none; /* hidden on desktop */
    position: absolute;
    top: 1rem;
    right: 1rem;
    cursor: pointer;
    background: var(--primary-dark);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    z-index: 1100;
}

@media (max-width: 800px) {
    .sidebar-close {
        display: grid; /* show on mobile */
    }
}
/* Show burger on mobile */
@media (max-width: 800px) {
    .mobile-nav-toggle {
        display: block;
    }
}
