/* ============================================================
   Weekly Calendar View — Google Calendar style
   ============================================================ */

:root {
    --hour-row-height: 120px;
}

.weekly-calendar-container {
    width: 100%;
    font-family: inherit;
    border: 1px solid #dadce0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

/* --- Navigation bar --- */
.week-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #dadce0;
    background: #fafafa;
}

.week-nav-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--pink-main, #333);
}

.week-nav-btn {
    cursor: pointer;
    color: var(--pink-main, #1a73e8);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    user-select: none;
}

.week-nav-btn:hover {
    text-decoration: underline;
}

/* --- Header row (day names + day numbers) --- */
.week-header-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    border-bottom: 1px solid #dadce0;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 3;
}

.week-header-gutter {
    border-right: 1px solid #dadce0;
}

.week-header-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 6px;
    border-right: 1px solid #eee;
    font-size: 0.8rem;
    color: #70757a;
}

.week-header-cell:last-child {
    border-right: none;
}

.week-header-day-name {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.week-header-day-number {
    font-size: 1.5rem;
    font-weight: 400;
    color: #3c4043;
    line-height: 1.3;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.week-today-header .week-header-day-name {
    color: var(--green-dark, #1a73e8);
}

.week-today-circle {
    background: var(--green-dark, #1a73e8);
    color: #fff !important;
    border-radius: 50%;
}

/* --- All-day events row --- */
.week-allday-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    border-bottom: 2px solid #dadce0;
    min-height: 32px;
    background: #fff;
}

.week-allday-gutter {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4px 2px;
    font-size: 0.65rem;
    color: #70757a;
    border-right: 1px solid #dadce0;
}

.week-allday-cell {
    border-right: 1px solid #eee;
    padding: 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.week-allday-cell:last-child {
    border-right: none;
}

.week-allday-cell .day-card-wrapper {
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0;
}

.week-loading {
    color: #999;
    font-size: 0.75rem;
}

/* --- Scrollable time grid body --- */
.week-body-scroll {
    min-height: calc(var(--hour-row-height) * 3); /* 3 hours visible by default */
    max-height: calc(var(--hour-row-height) * 6); /* 6 hours visible by default */
    height: calc(100dvh - 250px); /* Adjust based on your layout */
    overflow-y: auto;
    position: relative;
}

.week-body-inner {
    position: relative;
}

/* --- Time grid (rows with hour labels + cells) --- */
.week-time-grid {
    position: relative;
}

.week-time-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    height: var(--hour-row-height);
    border-bottom: 1px solid #f1f3f4;
}

.week-time-gutter {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    border-right: 1px solid #dadce0;
    position: relative;
}

.week-time-gutter span {
    font-size: 0.7rem;
    color: #70757a;
    position: relative;
    top: -8px;
    background: #fff;
    padding: 0 2px;
}

.week-time-cell {
    border-right: 1px solid #f1f3f4;
    position: relative;
}

.week-time-cell:last-child {
    border-right: none;
}

.week-today-col {
    background: rgba(26, 115, 232, 0.03);
}

/* --- Events overlay (positioned absolutely on top of the grid) --- */
.week-events-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    pointer-events: none;
}

.week-events-gutter-spacer {
    pointer-events: none;
}

.week-events-column {
    position: relative;
    pointer-events: none;
}

/* --- Individual event blocks --- */
.week-event-block {
    position: absolute;
    left: 2px;
    right: 2px;
    background-color: var(--red-light, #fce4ec);
    border-left: 3px solid var(--red-main, #e53935);
    border-radius: 4px;
    padding: 4px 6px;
    overflow: hidden;
    cursor: pointer;
    pointer-events: all;
    z-index: 1;
    font-size: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.week-event-block:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transform: scale(1.01);
    z-index: 5;
}

.week-event-inner {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
    overflow: hidden;
}

.week-event-teacher {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.week-event-teacher .teacher-profile-image {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.week-event-time {
    color: #555;
    font-size: 0.7rem;
}

.week-event-student {
    color: var(--blue, #1565c0);
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .week-header-row,
    .week-allday-row,
    .week-time-row,
    .week-events-overlay {
        grid-template-columns: 40px repeat(7, 1fr);
    }

    .week-header-day-name {
        font-size: 0.6rem;
    }

    .week-header-day-number {
        font-size: 1.1rem;
        width: 30px;
        height: 30px;
    }

    .week-time-gutter span {
        font-size: 0.6rem;
    }

    .week-event-block {
        font-size: 0.65rem;
        padding: 2px 3px;
    }

    .week-nav-title {
        font-size: 0.95rem;
    }
}