.app-container {
    display: flex;
    height: 100vh;
    position: relative; 
}

/* Sidebar Styles */
.sidebar {
    width: 250px; 
    background-color: #f4f4f4;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    box-sizing: border-box;
    z-index: 200;
    flex-shrink: 0; 
    transition: margin-left 0.3s ease;
    margin-left: 0; 
    border-right: 1px solid #ccc; 
}

.sidebar.collapsed {
    margin-left: -250px; 
}

.sidebar-header {
    text-align: center;
    margin-bottom: 15px;
    width: 100%;
}

.sidebar-header h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 2em;
    color: #333;
    white-space: nowrap;
}

/* Updated User Profile Styles */
.user-profile { /* Changed from .teacher-profile */
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #ccc;
}

.user-profile .avatar-placeholder { 
    width: 60px;
    height: 60px;
    background-color: #2a9d8f; /* Student's color */
    color: white;
    border: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    border-radius: 50%;
    margin-bottom: 8px;
}

.user-profile .user-role { /* Added user-role for "Teacher" / "Student" */
    font-size: 1em;
    color: #333;
    white-space: nowrap;
    margin-bottom: 2px; /* Small space between role and name */
    font-weight: bold;
}

.user-profile .user-name { /* Added user-name for full name */
    font-size: 1.2em;
    color: #666;
    white-space: nowrap;
}


/* Styles for the new navigation list */
.sidebar-nav {
    width: 100%;
    text-align: left;
}

.sidebar-nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: block;
    color: #333;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}
.sidebar-nav li:not(:first-child) > a:not(.collapsible-trigger) {
    padding: 12px 20px;
    border-radius: 4px;
}


.sidebar-nav li a:hover {
    background-color: #e9ecef;
    color: #007bff;
}

.sidebar-nav li a.active-link {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

/* Collapsible "My Courses" styles */
.collapsible-trigger {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    width: 100%;
    box-sizing: border-box; 
    padding: 12px 20px;
    cursor: pointer;
    color: #333;
    text-decoration: none;
    white-space: nowrap;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.collapsible-trigger:hover {
    background-color: #e9ecef;
    color: #007bff;
}

.collapsible-trigger .arrow-icon {
    transition: transform 0.3s ease;
    font-size: 0.8em;
    margin-left: 10px; 
}

.collapsible-trigger.expanded .arrow-icon {
    transform: rotate(180deg); 
}

.collapsible-content {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden; 
    transition: max-height 0.3s ease-out; 
    max-height: 0; 
}

.collapsible-content.expanded {
    /* max-height will be set dynamically by JS to scrollHeight */
}
.sidebar-item {
    display: block;               /* 确保按钮撑满行 */
    width: 100%;
    padding: 10px 20px;
    font-size: 0.9em;
    color: #333;
    text-align: left;
    border: none;
    background-color: transparent;
    border-bottom: 1px dotted #ccc;
    box-sizing: border-box;
    cursor: pointer;
}

.sidebar-item:hover {
    background-color: #f0f0f0;
}

.course-item {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 8px; 
    font-size: 0.9em;
    color: #333;
    border-bottom: 1px dotted #ccc; 
}

.course-item label {
    flex-grow: 1; 
    cursor: pointer;
}

.course-checkbox {
    cursor: pointer;
}

.assignment-item {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: #333;
    border-bottom: 1px dotted #ccc;
}

/* 圆形按钮 */
.today-assignment-button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background-color: #007bff;
    color: #fff;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}
.today-assignment-button.due-today { background-color: #dc3545; }

.assignment-detail-box {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    width: 360px;
    max-height: 520px;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 100;
}
.assignment-detail-box.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.assignment-detail-box .popover-header {
    font-size: 1.2em;
    font-weight: bold;
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
}

.assignment-detail-box .popover-content {
    padding: 16px 20px;
}
.assignment-detail-box .popover-content p {
    margin: 8px 0;
    font-size: 0.95em;
}
.assignment-detail-box .popover-content strong {
    display: inline-block;
    width: 65px;
    color: #333;
}
/* 分隔符样式 */
.assignment-detail-box .popover-content p.separator {
    text-align: center;
    color: #ccc;
    margin: 8px 0;
}

.assignment-detail-close {
    position: absolute;
    top: 10px; right: 10px;
    font-size: 1.3em;
    cursor: pointer;
    color: #666;
}
/* Toggle button for sidebar */
.toggle-sidebar-btn {
    position: absolute;
    top: 50%;
    left: 250px; 
    transform: translateY(-50%);
    background-color: #007bff; color: white; border: none;
    padding: 10px 5px; cursor: pointer; border-radius: 0 5px 5px 0;
    z-index: 201;
    transition: left 0.3s ease;
}

.sidebar.collapsed + .toggle-sidebar-btn {
    left: 0px; 
}

/* Main Content Styles */
.main-content {
    flex-grow: 1;
    padding: 20px;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    overflow-y: auto; 
    position: relative; 
}

.main-header { 
    margin-bottom: 20px; 
    text-align: center; 
    border-bottom: 1px solid #ddd; 
}
.main-header h1 {
    margin-top: 0;
    font-size: 1.8em;
    margin-bottom: 15px; 
}

.view-controls {
    margin-bottom: 10px; 
    display: flex; 
    justify-content: center; 
}
.view-btn {
    padding: 8px 15px; margin: 0 5px; 
    cursor: pointer;
    border: 1px solid #ccc; background-color: #f0f0f0; border-radius: 4px;
}
.view-btn.active { background-color: #007bff; color: white; border-color: #007bff; }

.calendar-navigation {
    margin-bottom: 20px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    text-align: left; 
}
.calendar-navigation span { 
    font-size: 1.2em; 
    font-weight: bold; 
}

/* Calendar View General */
#calendarView {
    flex-grow: 1;
    border: 1px solid #ccc;
    background-color: #f9f9f9; 
    text-align: left; 
    position: relative; 
	border: 1px solid black;
	table-layout: fixed;
	width: 100%;
}

.calendar-cell {
	vertical-align: top;
	height: 10em;
}

/* Month View Specific */
#calendarView.month-view {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: auto repeat(6, minmax(80px, auto)); 
    gap: 1px;
    background-color: #ddd;
}
.calendar-day-header, .calendar-day {
    background-color: #fff;
    padding: 8px;
    border: 1px solid #eee;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    overflow: hidden; 
    box-sizing: border-box; 
    text-align: center; 
    position: relative; 
	vertical-align: top;
}
.calendar-day.empty { 
    background-color: #f9f9f9; 
} 

/* New styles for Month View Events */
.month-events-container {
    display: flex;
    flex-direction: column; 
    width: 100%; 
    padding: 0 2px; 
    box-sizing: border-box;
    margin-top: 5px; 
    gap: 2px; 
    overflow: hidden; 
    flex-grow: 1; 
}

.month-event {
	font-size: 80%;
    background-color: #cccccc; 
    color: white;
    border-radius: 4px; 
    padding: 2px 4px; 
    text-align: center;
    width: calc(100% - 4px); 
    box-sizing: border-box;
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
    cursor: pointer !important; 
    min-height: 18px; 
    display: block; 
    z-index: 20; 
    position: relative; 
}

.month-event-link {
	color: #ffffff;
}

.month-event span { 
    cursor: inherit !important; 
    pointer-events: none; 
}


.month-event-code {
    font-weight: bold;
}

/* Week View Specific */
#calendarView.week-view {
    display: flex;
    flex-direction: column; 
    height: 100%; 
    overflow-y: auto; 
}

.week-view-header-container {
    display: flex;
    flex-shrink: 0; 
    background-color: #f0f0f0;
    border-bottom: 1px solid #ccc;
}

.week-view-header-gutter-spacer {
    width: 60px; 
    flex-shrink: 0;
}

.week-view-days-header-row {
    display: flex;
    flex-grow: 1; 
}

.week-view-day-header {
    flex: 1; 
    padding: 10px;
    text-align: center;
    font-weight: bold;
    border-left: 1px solid #ddd;
}
.week-view-day-header:first-child { 
    border-left: none; 
}
.week-view-day-header.today-header {
    background-color: #e0efff; 
}

.week-view-body-scrollable {
    display: flex;
    flex-grow: 1; 
    overflow-y: auto; 
    position: relative; 
}

.time-gutter {
    width: 60px; 
    flex-shrink: 0;
    border-right: 1px solid #eee;
    background-color: #f8f8f8;
    position: sticky; 
    top: 0; 
    left: 0;
    z-index: 10; 
}

.hour-label {
    height: 50px; 
    display: flex;
    align-items: flex-start; 
    justify-content: center;
    padding-top: 5px;
    box-sizing: border-box;
    font-size: 0.8em;
    color: #777;
    border-bottom: 1px solid #eee;
}

.week-view-days-content {
    display: flex;
    flex-grow: 1; 
    position: relative; 
}

.week-view-day-column {
    flex: 1;
    border-left: 1px solid #ddd;
    position: relative; 
    min-width: 100px; 
}
.week-view-day-column:first-child { 
    border-left: none; 
}
.week-view-day-column.today-column {
    background-color: #f0f7ff; 
}

.hour-slot {
  height: var(--hour-height);
}

.week-event {
    position: absolute; 
    left: 2px;  
    right: 2px; 
    box-sizing: border-box;
    padding: 5px 8px; 
    border-radius: 4px;
    color: white;
    font-size: 0.85em; 
    overflow: hidden; 
    white-space: normal; 
    z-index: 20; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    border-left: 3px solid rgba(0,0,0,0.2); 
    cursor: pointer !important; 
    display: flex;
    align-items: center; 
    line-height: 1.3;
}
.week-event span {
    cursor: inherit !important; 
    pointer-events: none; 
}


/* Year View Specific (no visual events) */
#calendarView.year-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 20px; 
    padding: 15px;
    align-content: flex-start;
    overflow-y: auto; 
}
.year-view-month-container {
    border: 1px solid #ccc;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.year-view-month-title {
    text-align: center;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #333;
}
.mini-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    font-size: 0.75em; 
    background-color: #ddd; 
}
.mini-calendar-day-header, .mini-calendar-day {
    text-align: center;
    padding: 2px;
    background-color: #fff;
}
.mini-calendar-day-header { 
    background-color: #f8f8f8; 
    font-weight: normal; 
    color: #555;
}
.mini-calendar-day.empty { 
    visibility: hidden; 
}
.mini-calendar-day.today { 
    background-color: #e0efff; 
    border-radius: 2px; 
    font-weight: bold;
    color: #007bff;
}

/* Event Details Popover Styles */
.event-details-popover {
    position: fixed; /* IMPORTANT: Keep fixed for screen center */
    top: 50%; /* Center vertically */
    left: 50%; /* Center horizontally */
    transform: translate(-50%, -50%); /* Adjust for own dimensions to truly center */
    
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    padding: 15px;
    width: 280px; 
    z-index: 1000; 
    display: none; 
    opacity: 0; 
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.event-details-popover.show {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1); /* Ensure scale(1) happens from center */
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.popover-header h4 {
    margin: 0;
    font-size: 1.1em;
    color: #333;
    word-break: break-word; 
}

.close-popover-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #888;
    line-height: 1; 
    padding: 0; 
}

.close-popover-btn:hover {
    color: #333;
}

.popover-content p {
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #555;
    line-height: 1.4;
}

.popover-content strong {
    color: #333;
}

.popover-footer {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    text-align: right; 
}

.popover-action-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
}

.popover-action-btn:hover {
    background-color: #0056b3;
}

/* Popover Arrow Styles - REMOVED for fixed center positioning */
/* If you decide to re-implement relative positioning later, you'll need these */
.event-details-popover::before,
.event-details-popover::after {
    display: none; /* Hide arrows for fixed center popover */
}