/* Variables */
:root {
    --primary-green: #0a486ff7;
    --primary-dark: #073454;
    --primary-light: #0d5a94;
    --primary-green-rgb: 10, 72, 111;
    --primary-green-hex: #0a486f;
    --dark-grey: #343a40;
    --white: #ffffff;
    --light-grey: #f8f9fa;
    --hover-green: #000000;
    --sidebar-width: 70px;
    --sidebar-width-expanded: 240px;
    --topbar-height: 60px;
    --transition-speed: 0.3s;
}

/* External User Primary Colors - Green */
body.user-external {
    --primary-green: #2E9D62;
    --primary-dark: #247a4d;
    --primary-light: #3dbd7a;
    --primary-green-rgb: 46, 157, 98;
    --primary-green-hex: #2E9D62;
}

/* Global Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--light-grey);
    margin: 0;
    padding: 0;
}

.footer {
    margin-top: auto;
}

/* Navbar Styles */
.navbar {
    background-color: var(--light-grey);
    box-shadow: none;
    padding: 0.75rem 0;
}

.navbar-dark .navbar-nav .nav-link {
    color: var(--dark-grey);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: color 0.3s ease;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: var(--primary-green);
}

.navbar-dark .navbar-toggler {
    border-color: transparent;
}

.navbar-dark .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(40, 167, 69, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.dropdown-item:hover {
    background-color: var(--light-grey);
    color: var(--primary-green);
}

/* Auth Form Styles */
/* .auth-form {
    max-width: 450px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--white);
    border-radius: 0 15px 0 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--dark-grey);
    font-weight: 600;
    font-size: 1.75rem;
}

.auth-form .form-control {
    border: 1.5px solid #e9ecef;
    padding: 0.75rem;
    border-radius: 0 8px 0 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background-color: var(--light-grey);
}

.auth-form .form-control:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.1);
    background-color: var(--white);
}

.auth-form .form-label {
    font-weight: 500;
    color: var(--dark-grey);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.auth-form .btn-primary {
    width: 100%;
    padding: 0.75rem;
    margin-top: 1.25rem;
    background-color: var(--primary-green);
    border-color: var(--primary-green);
    border-radius: 0 8px 0 8px;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.auth-form .btn-primary:hover {
    background-color: var(--hover-green);
    border-color: var(--hover-green);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(40, 167, 69, 0.15);
}

.auth-form .form-check {
    margin: 0.75rem 0;
}

.auth-form .form-check-label {
    color: var(--dark-grey);
    font-weight: 400;
    font-size: 0.9rem;
}

.auth-form .form-check-input:checked {
    background-color: var(--primary-green);
    border-color: var(--primary-green);
}

.auth-form a {
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.auth-form a:hover {
    color: var(--hover-green);
    text-decoration: underline;
}

.auth-form .invalid-feedback {
    font-size: 0.8rem;
    margin-top: 0.4rem;
}

.auth-form .alert {
    margin-bottom: 1.25rem;
    border-radius: 0 8px 0 8px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
} */

/* Alert Styles */
.alert {
    border: none;
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--primary-green);
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Dashboard Styles */
.dashboard-header {
    background-color: #f8f9fa;
    padding: 2rem 0;
    margin-bottom: 2rem;
    border-radius: 8px;
}

.dashboard-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0 2rem;
}

.stat-card {
    flex: 1;
    min-width: 200px;
    padding: 1.5rem;
    border-radius: 0 15px 0 15px;
    background-color: var(--white);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform var(--transition-speed) ease;
    position: relative;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.stat-card .stat-title {
    font-size: 0.9rem;
    color: var(--dark-grey);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-green);
}

.stat-card .stat-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: var(--primary-green);
    opacity: 0.3;
}

/* Card Styles */
.card {
    border: none;
    border-radius: 0 15px 0 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: var(--white);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem 1.25rem;
    border-radius: 0 15px 0 0 !important;
}

.card-body {
    padding: 2.5rem;
}

.list-group-item {
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 0;
    padding: 1rem 0;
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item-action {
    transition: all var(--transition-speed) ease;
}

.list-group-item-action:hover {
    background-color: rgba(40, 167, 69, 0.05);
    transform: translateX(5px);
}

.list-group-item h5 {
    color: var(--dark-grey);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.list-group-item p {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.list-group-item small {
    color: #6c757d;
    font-size: 0.85rem;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    border-radius: 6px;
}

.btn-outline-primary {
    color: var(--primary-green);
    border-color: var(--primary-green);
}

.btn-outline-primary:hover {
    background-color: var(--primary-green);
    border-color: var(--primary-green);
    color: var(--white);
}

.text-danger {
    color: #dc3545 !important;
}

/* Home Page */
.hero-section {
    background-color: #4b6cb7;
    background-image: linear-gradient(to right, #4b6cb7, #182848);
    color: white;
    padding: 4rem 0;
    border-radius: 8px;
    margin-bottom: 3rem;
}

.feature-card {
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background-color: #fff;
    height: 100%;
    transition: transform 0.3s ease;
}

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

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #4b6cb7;
}

/* Profile page */
.profile-section {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    margin-bottom: 2rem;
}

/* Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    height: calc(100vh - var(--topbar-height));
    width: var(--sidebar-width);
    background-color: var(--white);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
    overflow-y: auto;
    overflow-x: hidden;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    /* Prevent text from being cut off */
    min-width: var(--sidebar-width);
    max-width: 100vw;
}

/* Webkit browsers custom scrollbar (Chrome, Safari, Edge) */
.sidebar::-webkit-scrollbar {
    width: 3px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* Show slightly more visible scrollbar on hover for better UX */
.sidebar:hover::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
}

.sidebar.expanded {
    width: var(--sidebar-width-expanded);
    min-width: var(--sidebar-width-expanded);
    /* Allow sidebar to grow if content needs more space (e.g., when zoomed) */
    max-width: min(100vw, 400px);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    min-width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Prevent horizontal overflow issues */
    box-sizing: border-box;
    /* Ensure proper scrolling behavior */
    min-height: 0; /* Allow flex child to shrink below content size */
    flex-shrink: 1; /* Allow nav to shrink when needed */
    overflow: visible; /* Let parent handle scrolling */
}

.nav-item {
    margin: 2px 0;
    position: relative;
}

.bottom-nav {
    margin-top: auto;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 0.5rem;
    width: 100%;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--dark-grey);
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition-speed) ease;
    border-radius: 0;
    cursor: pointer;
    position: relative;
    min-height: 44px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Prevent text from being cut off */
    min-width: 0;
    flex-shrink: 1;
    box-sizing: border-box;
}

.nav-link:hover {
    background-color: rgba(57, 40, 167, 0.1);
    color: var(--primary-green);
    transform: translateX(5px);
}

.nav-link.active {
    background-color: var(--primary-green);
    color: var(--white);
    transform: translateX(5px);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background-color: var(--white);
    border-radius: 0 4px 4px 0;
}

.nav-link.active i {
    color: var(--white);
}

.nav-link i {
    font-size: 1.25rem;
    min-width: 30px;
    text-align: center;
    transition: all var(--transition-speed) ease;
}

.nav-link:hover i {
    transform: scale(1.1);
}

.nav-link span {
    margin-left: 10px;
    opacity: 0;
    transition: all var(--transition-speed) ease;
    font-size: 0.95rem;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.logout-link {
    color: #dc3545;
}

.logout-link:hover {
    background: rgba(220, 53, 69, 0.1);
}

.sidebar.expanded .nav-link span {
    opacity: 1;
}

/* Sidebar Section Labels (for Super Admin) */
.nav-section-label {
    padding: 1.25rem 1.25rem 0.5rem;
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.3);
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    margin-top: 0.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar.expanded .nav-section-label {
    opacity: 1;
}

.nav-section-label:first-of-type {
    margin-top: 0;
    border-top: none;
}

/* Slightly smaller nav items under section labels */
.nav-section-label + .nav-item .nav-link {
    padding: 11px 20px;
}

/* Profile in Sidebar */
.profile-trigger {
    cursor: pointer;
    position: relative;
}

.profile-trigger.active {
    background-color: var(--primary-green);
    color: var(--white);
}

.profile-trigger.active i {
    color: var(--white);
}

.profile-content {
    position: fixed;
    left: var(--sidebar-width);
    bottom: 10px;
    background: var(--white);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-20px);
    transition: all var(--transition-speed) ease;
    border-radius: 0 8px 8px 0;
    overflow: hidden;
    min-width: 220px;
}

.sidebar.expanded .profile-content {
    left: var(--sidebar-width-expanded);
}

.profile-content.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.profile-email {
    padding: 12px 20px;
    color: var(--dark-grey);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--light-grey);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: var(--light-grey);
}

.profile-logout {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--dark-grey);
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    font-size: 0.95rem;
    background-color: var(--white);
}

.profile-logout:hover {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--primary-green);
}

.profile-logout i {
    margin-right: 10px;
    font-size: 1.1rem;
}

/* Top Navbar */
.top-navbar {
    height: var(--topbar-height);
    background-color: var(--white);
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1001;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--dark-grey);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: all var(--transition-speed) ease;
    margin-left: 2px;
    position: relative;
    z-index: 10;
}

.menu-toggle:hover {
    background-color: rgba(40, 61, 167, 0.1);
    color: var(--primary-green);
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    pointer-events: none;
}

.brand img {
    pointer-events: auto;
}

.brand i {
    color: var(--primary-green);
    font-size: 1.5rem;
    margin-right: 10px;
}

.brand span {
    color: var(--dark-grey);
    font-weight: 600;
    font-size: 1.25rem;
}

/* User Menu */
.user-menu {
    margin-left: auto;
    position: relative;
}

.user-menu-trigger {
    background: none;
    border: none;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--dark-grey);
    cursor: pointer;
    border-radius: 8px;
    transition: all var(--transition-speed) ease;
}

.user-menu-trigger:hover {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--primary-green);
}

.user-menu-trigger i {
    font-size: 1.25rem;
}

.user-menu-trigger span {
    font-size: 0.95rem;
}

.user-menu-content {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 8px 0;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-speed) ease;
}

.user-menu.active .user-menu-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-email {
    padding: 8px 15px;
    color: var(--dark-grey);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--light-grey);
    margin-bottom: 8px;
}

.user-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    color: var(--dark-grey);
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    font-size: 0.95rem;
}

.user-menu-item:hover {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--primary-green);
}

.user-menu-item i {
    margin-right: 10px;
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    transition: margin-left var(--transition-speed) ease;
}

.sidebar.expanded + .main-content {
    margin-left: var(--sidebar-width-expanded);
}

.content-wrapper {
    padding: 20px;
    background-color: var(--bg-light);
}

/* Courses Sidebar */
.courses-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: -320px; /* Hidden by default */
    width: 320px;
    height: calc(100vh - var(--topbar-height));
    background-color: var(--white);
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.08);
    z-index: 999; /* Behind main sidebar (z-index 1000) */
    transition: left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1), width var(--transition-speed) ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.courses-sidebar.show {
    left: var(--sidebar-width); /* Position after main sidebar */
}

.courses-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.25rem;
    border-bottom: 0.5px solid var(--bg-border-light);
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.courses-sidebar-header h3 {
    margin: 0;
    color: var(--dark-grey);
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.3px;
}

.courses-close-btn {
    background: transparent;
    border: none;
    color: var(--dark-grey);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.courses-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

.courses-sidebar-content {
    padding: 0;
}

.courses-nav-links {
    background-color: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.courses-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    color: var(--dark-grey) !important;
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.courses-nav-link span {
    color: var(--dark-grey) !important;
}

.courses-nav-link i {
    font-size: 1.1rem;
    color: var(--primary-green);
    transition: all var(--transition-speed) ease;
}

.courses-nav-link:hover {
    background-color: var(--primary-green);
    color: var(--white)!important;
    padding-left: 1.5rem;
}

.courses-nav-link:hover span {
    color: var(--white)!important;
}

.courses-nav-link:hover i {
    color: var(--white);
    transform: scale(1.1);
}

.courses-nav-link:last-child {
    border-bottom: none;
}

.courses-section-header {
    padding: 0.9rem 1.25rem;
    background-color: var(--light-grey);
    color: var(--dark-grey) !important;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 5;
}

/* Ensure all child elements inherit the proper color */
.courses-section-header span,
.courses-section-header * {
    color: var(--dark-grey) !important;
}

.courses-list {
    background-color: var(--white);
}

.courses-items {
    max-height: calc(100vh - 250px);
    width: 100%;
    overflow-y: auto;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.courses-items::-webkit-scrollbar {
    width: 6px;
}

.courses-items::-webkit-scrollbar-track {
    background: transparent;
}

.courses-items::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.courses-sidebar .course-item {
    display: block;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--white);
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    margin: 0;
    position: relative;
    color: var(--dark-grey);
    text-decoration: none;
}

.courses-sidebar .course-item:hover,
.courses-sidebar .course-item:focus,
.courses-sidebar .course-item:active {
    color: var(--dark-grey);
    text-decoration: none;
}

.courses-sidebar .course-item * {
    text-decoration: none;
}

.courses-sidebar .course-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background-color: var(--primary-green);
    transition: width var(--transition-speed) ease;
}

.courses-sidebar .course-item:hover {
    background-color: rgba(10, 72, 111, 0.04);
    padding-left: 1.5rem;
}

.courses-sidebar .course-item:hover::before {
    width: 4px;
}

.courses-sidebar .course-item:last-child {
    border-bottom: none;
}

.courses-sidebar .course-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    width: 100%;
}

.courses-sidebar .course-title {
    font-weight: 600;
    color: #343a40 !important;
    font-size: 0.875rem !important;
    line-height: 1.4 !important;
    flex: 1 1 0%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    padding-right: 0.5rem;
    transition: color 0.2s ease;
}

.courses-sidebar .course-item:hover .course-title {
    color: var(--primary-green) !important;
}

.courses-sidebar .course-progress-badge {
    background-color: var(--primary-green);
    color: var(--white);
    font-size: 0.7rem !important;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.courses-sidebar .course-subtitle {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    color: #6c757d !important;
    font-size: 0.75rem !important;
    font-weight: 400;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    margin-top: 0.4rem;
}

.courses-sidebar .course-student-count {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #0a486ff7 !important;
    font-weight: 500;
    font-size: 0.75rem !important;
}

.courses-sidebar .course-student-count i {
    font-size: 0.85rem !important;
}

/* Course Progress Bar - Scoped to sidebar */
.courses-sidebar .course-progress-bar {
    width: 100%;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.6rem;
}

.courses-sidebar .course-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green) 0%, var(--primary-light) 100%);
    border-radius: 2px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure proper text visibility in course items - Maximum specificity */
.courses-sidebar .courses-items .course-item .course-title,
.courses-sidebar .courses-items .course-item .course-item-header .course-title,
.courses-sidebar .course-item .course-title,
.courses-sidebar .course-item-header .course-title {
    color: #343a40 !important;
    background-color: transparent !important;
    text-shadow: none !important;
    font-size: 0.875rem !important;
    line-height: 1.4 !important;
}

.courses-sidebar .courses-items .course-item .course-student-count,
.courses-sidebar .course-item .course-student-count {
    color: #0a486ff7 !important;
    background-color: transparent !important;
    font-size: 0.75rem !important;
}



/* Course Navigation Sidebar (Course-specific nav) */
.course-nav-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: -320px; /* Hidden by default */
    width: 320px;
    height: calc(100vh - var(--topbar-height));
    background-color: var(--white);
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.08);
    z-index: 998; /* Behind courses sidebar (z-index 999) */
    transition: left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1), width var(--transition-speed) ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.course-nav-sidebar.show {
    left: var(--sidebar-width); /* Position after main sidebar */
}

.course-nav-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 2px solid var(--primary-green);
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-dark) 100%);
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 0.75rem;
}

.course-nav-sidebar-header h3 {
    margin: 0;
    color: var(--white);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.course-nav-back-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--white);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.course-nav-back-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateX(-3px);
}

.course-nav-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.course-nav-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

.course-nav-sidebar-content {
    padding: 0;
}

.course-nav-items {
    width: 100%;
}

.course-nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    color: var(--dark-grey) !important;
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.course-nav-item span {
    color: var(--dark-grey) !important;
}

.course-nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background-color: var(--primary-green);
    transition: width var(--transition-speed) ease;
}

.course-nav-item:hover {
    background-color: rgba(10, 72, 111, 0.04);
    padding-left: 1.5rem;
}

.course-nav-item:hover::before {
    width: 4px;
}

.course-nav-item.active {
    background-color: rgba(10, 72, 111, 0.08);
    color: var(--primary-green);
    font-weight: 600;
    padding-left: 1.5rem;
}

.course-nav-item.active::before {
    width: 4px;
}

.course-nav-item i {
    font-size: 1.1rem;
    color: var(--primary-green);
    transition: all var(--transition-speed) ease;
    width: 24px;
    text-align: center;
}

.course-nav-item:hover i {
    transform: scale(1.1);
}

.course-nav-item.active i {
    color: var(--primary-green);
}

/* Course Navigation Badge */
.course-nav-badge {
    margin-left: auto;
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.course-nav-badge.badge-danger {
    background: #dc3545;
}

.course-nav-badge.badge-primary {
    background: #0073E6;
}

.course-nav-badge.badge-success {
    background: #28a745;
}

.course-nav-badge.badge-warning {
    background: #ffc107;
    color: #212529;
}

/* Module navigation styles */
.course-nav-module {
    margin-bottom: 0;
}

.course-nav-module.locked {
    opacity: 0.6;
}

.course-nav-module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    background-color: rgba(10, 72, 111, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all var(--transition-speed) ease;
}

.course-nav-module-header:hover {
    background-color: rgba(10, 72, 111, 0.06);
}

.module-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.module-toggle {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    color: var(--dark-grey);
}

.module-toggle.expanded {
    transform: rotate(90deg);
}

.module-icon {
    font-size: 1rem;
    color: var(--primary-green);
}

.module-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark-grey);
}

.module-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.module-progress-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background-color: rgba(10, 72, 111, 0.1);
    color: var(--primary-green);
    border-radius: 12px;
    font-weight: 600;
}

.module-lock-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border-radius: 12px;
    font-weight: 600;
}

.course-nav-module-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: var(--white);
}

.course-nav-module-items.show {
    max-height: 2000px;
}

.course-nav-subitem {
    padding: 0.75rem 1.25rem 0.75rem 2.5rem !important;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.course-nav-subitem.indent-1 {
    padding-left: 3rem !important;
}

.course-nav-subitem.indent-2 {
    padding-left: 3.5rem !important;
}

.course-nav-subitem.indent-3 {
    padding-left: 4rem !important;
}

.course-nav-subitem i:first-child {
    font-size: 0.9rem;
    min-width: 20px;
}

.course-nav-subitem .completion-icon {
    margin-left: auto;
    font-size: 0.9rem;
    color: #10b981;
}

.course-nav-subitem.completed {
    opacity: 0.7;
}

.course-nav-subitem.completed:not(.active) {
    color: #6b7280 !important;
}

.course-nav-subitem.completed:not(.active) span {
    color: #6b7280 !important;
}

/* Responsive courses sidebar */
@media (max-width: 768px) {
    .courses-sidebar {
        width: 100%;
        left: -100%;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
    }
    
    .courses-sidebar.show {
        left: 0;
        z-index: 1001; /* Above main sidebar on mobile */
    }
    
    .course-nav-sidebar {
        width: 100%;
        left: -100%;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
    }
    
    .course-nav-sidebar.show {
        left: 0;
        z-index: 1001;
    }
    
    /* Adjust main content for mobile */
    .courses-sidebar.show ~ .main-content {
        margin-left: 0;
        padding-left: 0;
    }
    
    .sidebar.expanded ~ .courses-sidebar.show ~ .main-content {
        margin-left: 0;
        padding-left: 0;
    }
    
    .course-nav-sidebar.show ~ .main-content {
        margin-left: 0;
        padding-left: 0;
    }
    
    /* Ensure backdrop is behind sidebars but above main content */
    .sidebar-backdrop {
        z-index: 998;
    }
    
    .sidebar {
        z-index: 1000;
    }
    
    .courses-sidebar.show,
    .course-nav-sidebar.show {
        z-index: 1001;
    }
}

/* Adjust main content when courses sidebar is open on desktop */
@media (min-width: 769px) {
    .courses-sidebar.show ~ .main-content {
        margin-left: calc(var(--sidebar-width) + 270px);
    }
    
    .sidebar.expanded ~ .courses-sidebar.show ~ .main-content {
        margin-left: calc(var(--sidebar-width-expanded) + 270px);
    }
    
    .course-nav-sidebar.show ~ .main-content {
        margin-left: calc(var(--sidebar-width) + 270px);
    }
    
    .sidebar.expanded ~ .course-nav-sidebar.show ~ .main-content {
        margin-left: calc(var(--sidebar-width-expanded) + 270px);
    }
}

/* Responsive Design - Enhanced Sidebar */

/* Sidebar Backdrop/Overlay for Mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* Large Tablets and Small Desktops (1024px and below) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 70px;
        --sidebar-width-expanded: 220px;
    }
    
    .sidebar {
        width: var(--sidebar-width);
    }
    
    .sidebar.expanded {
        width: var(--sidebar-width-expanded);
    }
    
    .main-content {
        padding-left: var(--sidebar-width);
    }
    
    .sidebar.expanded ~ .main-content {
        padding-left: var(--sidebar-width-expanded);
    }
    
    .nav-link {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .nav-link i {
        font-size: 1.1rem;
    }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 70px;
        --sidebar-width-expanded: 280px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        /* Use viewport width that scales with zoom */
        width: min(85vw, 320px);
        min-width: min(85vw, 280px);
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
        z-index: 1000;
        /* Allow sidebar to expand when zoomed */
        overflow-x: visible;
    }
    
    .sidebar.expanded {
        transform: translateX(0);
        /* Use viewport width that scales with zoom level */
        width: min(90vw, 400px);
        min-width: min(85vw, 280px);
        max-width: 95vw;
    }
    
    .sidebar-nav {
        /* Ensure nav doesn't constrain width */
        min-width: 100%;
        width: 100%;
    }
    
    .sidebar-backdrop.show {
        display: block;
    }
    
    .main-content {
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
    
    .top-navbar {
        left: 0;
        width: 100%;
    }
    
    .sidebar.expanded ~ .main-content {
        margin-left: 0;
        padding-left: 0;
    }
    
    .nav-link {
        padding: 14px 20px;
        font-size: 0.95rem;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.4;
        /* Ensure link fits within sidebar */
        width: 100%;
        box-sizing: border-box;
    }
    
    .nav-link span {
        display: block;
        opacity: 1 !important;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin-left: 12px;
        flex: 1 1 auto;
        min-width: 0;
        /* Prevent text truncation - allow wrapping */
        overflow: visible;
        text-overflow: clip;
        hyphens: auto;
    }
    
    .nav-link i {
        font-size: 1.2rem;
        margin-right: 12px;
        flex-shrink: 0;
        min-width: 24px;
    }
    
    .profile-content {
        position: absolute;
        left: 100%;
        bottom: 0;
        transform: translateX(-20px);
    }

    .sidebar.expanded .profile-content {
        left: 100%;
    }
    
    /* Courses sidebar adjustments for tablets */
    .courses-sidebar {
        width: 100%;
        left: -100%;
        z-index: 1001;
    }
    
    .courses-sidebar.show {
        left: 0;
    }
    
    .course-nav-sidebar {
        width: 100%;
        left: -100%;
        z-index: 1001;
    }
    
    .course-nav-sidebar.show {
        left: 0;
    }
    
    /* Adjust main content for mobile */
    .courses-sidebar.show ~ .main-content {
        margin-left: 0;
        padding-left: 0;
    }
    
    .sidebar.expanded ~ .courses-sidebar.show ~ .main-content {
        margin-left: 0;
        padding-left: 0;
    }
    
    .course-nav-sidebar.show ~ .main-content {
        margin-left: 0;
        padding-left: 0;
    }
}

/* Small Tablets and Large Phones (576px and below) */
@media (max-width: 576px) {
    :root {
        --sidebar-width-expanded: 300px;
        --topbar-height: 56px;
    }
    
    .sidebar {
        /* Use viewport width that scales with zoom */
        width: min(90vw, 350px);
        max-width: min(90vw, 350px);
        min-width: min(85vw, 300px);
        overflow-x: visible;
    }
    
    .sidebar.expanded {
        width: min(92vw, 400px);
        min-width: min(85vw, 300px);
        max-width: 95vw;
    }
    
    .sidebar-nav {
        width: 100%;
        min-width: 100%;
    }
    
    .top-navbar {
        height: var(--topbar-height);
        padding: 0 12px;
    }
    
    .menu-toggle {
        font-size: 1.3rem;
        padding: 8px;
    }
    
    .nav-link {
        padding: 16px 20px;
        font-size: 1rem;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
    }
    
    .nav-link span {
        opacity: 1 !important;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin-left: 14px;
    }
    
    .nav-link i {
        font-size: 1.3rem;
        margin-right: 14px;
        min-width: 28px;
        flex-shrink: 0;
    }
    
    .content-wrapper {
        padding: 16px;
    }
    
    .courses-sidebar,
    .course-nav-sidebar {
        width: 100%;
        max-width: 100%;
    }
}

/* Extra Small Phones (480px and below) */
@media (max-width: 480px) {
    :root {
        --sidebar-width-expanded: 100%;
    }
    
    .sidebar {
        /* Full width on small screens, scales with zoom */
        width: 100vw;
        max-width: 100vw;
        min-width: 100vw;
        overflow-x: visible;
    }
    
    .sidebar.expanded {
        width: 100vw;
        min-width: 100vw;
        max-width: 100vw;
    }
    
    .sidebar-nav {
        width: 100%;
        min-width: 100%;
    }
    
    .nav-link {
        padding: 18px 20px;
        font-size: 1.05rem;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
        width: 100%;
        box-sizing: border-box;
    }
    
    .nav-link span {
        opacity: 1 !important;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin-left: 16px;
        flex: 1 1 auto;
        min-width: 0;
        overflow: visible;
        text-overflow: clip;
    }
    
    .nav-link i {
        font-size: 1.4rem;
        margin-right: 16px;
        min-width: 32px;
        flex-shrink: 0;
    }
    
    .content-wrapper {
        padding: 12px;
    }
    
    .top-navbar {
        padding: 0 10px;
    }
    
    .brand img {
        width: 50px !important;
        height: 42px !important;
    }
}

/* Landscape Orientation for Tablets and Phones */
@media (max-width: 1024px) and (orientation: landscape) {
    .sidebar {
        height: calc(100vh - var(--topbar-height));
    }
    
    .sidebar-nav {
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .nav-link {
        padding: 10px 16px;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .nav-link span {
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sidebar {
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.08);
    }
    
    .sidebar.expanded {
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.12);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav-link {
        padding: 16px 20px;
        min-height: 48px;
    }
    
    .menu-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }
    
    .courses-close-btn,
    .course-nav-back-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* High Zoom Level Support - Ensure text wraps properly when zoomed */
@media (max-width: 768px) {
    /* Ensure text always wraps and doesn't get cut off when zoomed */
    .nav-link span {
        /* Force text to wrap at word boundaries */
        word-break: break-word;
        overflow-wrap: anywhere;
        hyphens: auto;
        /* Ensure text is fully visible */
        overflow: visible;
        text-overflow: clip;
    }
    
    /* When zoomed in significantly, allow sidebar to use more space */
    .sidebar.expanded {
        /* Ensure minimum width scales with viewport */
        min-width: min(85vw, 280px);
    }
}

/* ============================================
   LOW-HEIGHT SCREEN FIXES
   Fixes for PCs with low-height screens (e.g., 1366x768, 1024x600)
   ============================================ */

/* Ensure sidebar-nav properly constrains content for scrolling */
.sidebar-nav {
    min-height: 0; /* Allow flex child to shrink below content size */
    flex-shrink: 1; /* Allow nav to shrink when needed */
}

/* Improve scrolling behavior - ensure all content is accessible */
.sidebar {
    /* Ensure scrollbar is more visible on low-height screens */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px; /* Slightly wider for better visibility */
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2); /* More visible */
}

/* Low-height screens (≤800px height) - General adjustments */
@media (max-height: 800px) {
    .sidebar {
        /* Ensure scrollbar is always visible when content overflows */
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.05);
    }
    
    .sidebar::-webkit-scrollbar {
        width: 5px; /* More visible on low-height screens */
    }
    
    .sidebar::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.3);
    }
    
    .sidebar::-webkit-scrollbar-thumb:hover {
        background-color: rgba(0, 0, 0, 0.4);
    }
    
    /* Reduce nav item spacing */
    .nav-item {
        margin: 1px 0;
    }
    
    /* Reduce nav link padding */
    .nav-link {
        padding: 10px 16px;
        min-height: 40px; /* Slightly smaller minimum height */
    }
    
    /* Reduce icon size */
    .nav-link i {
        font-size: 1.1rem;
        min-width: 26px;
    }
    
    /* Reduce bottom nav padding */
    .bottom-nav {
        padding-top: 0.25rem;
        border-top-width: 1px;
    }
    
    /* Ensure sidebar-nav can scroll properly */
    .sidebar-nav {
        padding: 0.5rem 0;
    }
}

/* Very low-height screens (≤700px height) - More aggressive adjustments */
@media (max-height: 700px) {
    .nav-item {
        margin: 0.5px 0;
    }
    
    .nav-link {
        padding: 8px 14px;
        min-height: 36px;
    }
    
    .nav-link i {
        font-size: 1rem;
        min-width: 24px;
    }
    
    .nav-link span {
        font-size: 0.85rem;
    }
    
    .bottom-nav {
        padding-top: 0.2rem;
    }
    
    .sidebar-nav {
        padding: 0.4rem 0;
    }
}

/* Low-height desktop screens (width ≥769px but height ≤800px) */
@media (min-width: 769px) and (max-height: 800px) {
    .nav-link {
        padding: 9px 16px;
        min-height: 38px;
    }
    
    .nav-link i {
        font-size: 1.05rem;
        min-width: 25px;
    }
    
    /* Ensure expanded sidebar also has compact spacing */
    .sidebar.expanded .nav-link {
        padding: 9px 16px;
    }
}

/* Low-height desktop screens - very low (width ≥769px but height ≤700px) */
@media (min-width: 769px) and (max-height: 700px) {
    .nav-link {
        padding: 7px 14px;
        min-height: 34px;
    }
    
    .nav-link i {
        font-size: 0.95rem;
        min-width: 22px;
    }
    
    .nav-link span {
        font-size: 0.8rem;
    }
    
    .sidebar.expanded .nav-link {
        padding: 7px 14px;
    }
}

/* Combined: Small width AND low height (e.g., 1024x600) */
@media (max-width: 1024px) and (max-height: 800px) {
    .nav-link {
        padding: 8px 14px;
        min-height: 36px;
    }
    
    .nav-link i {
        font-size: 1rem;
        min-width: 24px;
    }
}

@media (max-width: 1024px) and (max-height: 700px) {
    .nav-link {
        padding: 7px 12px;
        min-height: 32px;
    }
    
    .nav-link i {
        font-size: 0.9rem;
        min-width: 22px;
    }
    
    .nav-link span {
        font-size: 0.8rem;
    }
}

/* Ensure bottom navigation is always accessible */
.bottom-nav {
    flex-shrink: 0; /* Prevent bottom nav from being compressed */
    min-height: fit-content;
}

/* Improve scrollbar visibility on all low-height scenarios */
@media (max-height: 800px) {
    .sidebar:hover::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.4);
    }
} 