/* Classes Sidebar Styles */
body.has-sidebar {
    position: relative;
    overflow-x: hidden; /* Prevent horizontal scroll */
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas: 
        "sidebar main"
        "footer footer";
    min-height: 100vh;
    padding-top: 82px; /* Account for fixed header */
}

body.has-sidebar > #teacher-header-placeholder {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

#classes-sidebar-placeholder {
    width: 280px;
    grid-area: sidebar;
    position: relative;
}

.classes-sidebar {
    position: -webkit-sticky; /* Safari support */
    position: sticky;
    top: 82px; /* Below fixed header - logo height (50px) + padding top (16px) + padding bottom (16px) = 82px */
    width: 280px;
    height: calc(100vh - 82px); /* Full viewport height minus header */
    background: var(--card-background, #ffffff);
    border-right: 1px solid var(--border-color, #e5e7eb);
    box-shadow: none;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--background-color, #f9fafb);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color, #1f2937);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}


.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-content .btn-block {
    width: 100%;
    padding: 0.75rem 1rem;
    font-weight: 500;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-classes-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.sidebar-class-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--border-radius, 8px);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background: var(--background-color, #f9fafb);
    text-decoration: none;
    color: inherit;
}

.sidebar-class-item:hover {
    background: var(--card-background, #ffffff);
    border-color: var(--border-color, #e5e7eb);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sidebar-class-item.active {
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--background-color, #f9fafb);
}

.sidebar-class-item.active .sidebar-class-name {
    font-weight: 600;
}

.sidebar-class-item.active .sidebar-class-icon {
    background: rgba(79, 70, 229, 0.1);
}

.sidebar-class-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-background, #ffffff);
    border-radius: 8px;
    color: var(--primary-color, #3b82f6);
    flex-shrink: 0;
}


.sidebar-class-info {
    flex: 1;
    min-width: 0;
}

.sidebar-class-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color, #1f2937);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-class-meta {
    font-size: 0.8rem;
    color: var(--text-color-secondary, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-class-meta i {
    font-size: 0.75rem;
}

.sidebar-loading,
.sidebar-error,
.sidebar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-color-secondary, #6b7280);
    gap: 0.5rem;
}

.sidebar-loading i,
.sidebar-error i,
.sidebar-empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.sidebar-error {
    color: var(--error-color, #ef4444);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    background: #ffffff;
    flex-shrink: 0;
}

.sidebar-footer .btn-block {
    width: 100%;
    padding: 0.75rem 1rem;
    font-weight: 500;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    background: #ffffff;
    border: 1px solid var(--border-color, #e5e7eb);
    color: #000000;
}

.sidebar-footer .btn-block i {
    color: #000000;
}

.sidebar-footer .btn-block:hover {
    background: #f9fafb;
    border-color: var(--border-color, #e5e7eb);
    color: #000000;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sidebar-footer .btn-block:hover i {
    color: #000000;
}

/* Adjust main content when sidebar is present */
body.has-sidebar .main-content {
    grid-area: main;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

/* Footer full width */
body.has-sidebar > #footer-placeholder {
    grid-area: footer;
    width: 100%;
}

body.has-sidebar > #footer-placeholder .footer {
    width: 100%;
    max-width: 100%;
}

/* Responsive Design */
@media (max-width: 550px) {
    body.has-sidebar {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        grid-template-areas: 
            "main"
            "footer";
        padding-top: 64px;
    }
    
    #classes-sidebar-placeholder {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    body.has-sidebar {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        grid-template-areas: 
            "main"
            "footer";
        padding-top: 82px;
    }
    
    #classes-sidebar-placeholder {
        display: none;
    }
}

@media (max-width: 768px) {
    body.has-sidebar {
        grid-template-rows: 1fr auto;
        padding-top: 64px; /* Header height on mobile - logo (40px) + padding (12px top + 12px bottom) = 64px */
    }
    
    #classes-sidebar-placeholder {
        width: 260px;
    }
    
    .classes-sidebar {
        width: 260px;
        top: 64px; /* Below fixed header on mobile */
        height: calc(100vh - 64px); /* Full viewport height minus header */
    }

    .sidebar-header {
        padding: 0.875rem 1rem;
    }

    .sidebar-header h3 {
        font-size: 1rem;
    }

    .sidebar-content {
        padding: 0.875rem;
    }

    .sidebar-class-item {
        padding: 0.625rem;
    }

    .sidebar-class-name {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    body.has-sidebar {
        grid-template-rows: 1fr auto;
        padding-top: 51px; /* Header height on small mobile - logo (35px) + padding (8px top + 8px bottom) = 51px */
    }
    
    #classes-sidebar-placeholder {
        width: 260px;
    }
    
    .classes-sidebar {
        top: 51px; /* Below fixed header on small mobile */
        height: calc(100vh - 51px); /* Full viewport height minus header */
    }
}

/* Scrollbar Styling */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

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

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border-color, #e5e7eb);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-color-secondary, #9ca3af);
}
