/* Layout Styles */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    /* App Shell: Body doesn't scroll, Main does */
    background-color: var(--bg-body);
    font-family: var(--font-sans);
}

header {
    flex-shrink: 0;
    position: relative;
    z-index: var(--z-header);
    background: var(--bg-header);
    border-bottom: 1px solid var(--color-gray-200);
    padding: var(--space-md);
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--breakpoint-xl);
    margin: 0 auto;
    width: 100%;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0 auto;
    max-width: 100%;
    /* ENABLE SCROLL BOTH AXES */
    overflow-y: auto;
    overflow-x: auto;
    padding: 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* Smooth iOS scroll */
}

/* New Calendar Layout */
.calendar-container {
    /* Remove flex constraints so it flows */
    flex: none;
    display: block;
    background: var(--bg-card);
    width: 100%;
    height: auto;
    position: relative;
    padding-bottom: 40px;
    /* Space at bottom */
}

.calendar-wrapper {
    display: flex;
    flex-direction: column;
    height: auto;
    width: 100%;
}

/* Header Row (Sticky within Main) */
.calendar-header-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    border-bottom: 1px solid var(--color-gray-200);
    background: var(--bg-header);
    /* Needs background to cover content */

    /* Make Sticky */
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Time Header Spacer (Top-Left Corner, Sticky) */
.time-header-spacer {
    position: sticky;
    left: 0;
    z-index: 110;
    /* Above header cells */
    background: var(--bg-header);
    border-right: 1px solid var(--color-gray-200);
}

.header-day-cell {
    text-align: center;
    padding: 8px 4px;
    border-left: 1px solid var(--color-gray-100);
}

.header-day-cell.current-day {
    color: var(--color-primary);
}

.header-day-cell .day-name {
    font-size: var(--font-size-xs);
    font-weight: 600;
    margin-bottom: 2px;
}

.header-day-cell .day-num {
    font-size: var(--font-size-xl);
    font-weight: 300;
}

/* Body (No longer scrollable internally, just flow) */
.calendar-body-scroll {
    overflow: visible;
    height: auto;
    background: var(--bg-body);
}

.calendar-main-grid {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    min-width: 800px;
    position: relative;
    /* Height is set by JS or variable */
}

/* Time Axis - Sticky Left for Horizontal Scroll */
.time-axis-column {
    position: sticky;
    left: 0;
    z-index: 50;
    /* Above day columns when scrolling right */
    border-right: 1px solid var(--color-gray-200);
    background: var(--bg-card);
}

.time-marker {
    height: 60px;
    /* 1 hour height */
    position: relative;
}

.time-text {
    position: absolute;
    top: -10px;
    /* Align with line */
    right: 8px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Day Columns */
.day-column {
    position: relative;
    border-left: 1px solid var(--color-gray-200);
    /* Vertical lines */
}

.grid-cell-hour {
    height: 60px;
    border-bottom: 1px solid var(--color-gray-100);
    /* Subtle horizontal lines */
    box-sizing: border-box;
}

/* Event Blocks (Absolute) */
.event-block {
    position: absolute;
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.2;
    color: white;
    backdrop-filter: blur(4px);
    /* Glassmorphism */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: z-index 0.2s, transform 0.2s, opacity 0.2s;
}

.event-block:hover {
    z-index: 50 !important;
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.event-block .event-time {
    font-weight: bold;
    margin-bottom: 1px;
}

.event-block .event-title {
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nav & Stats */
.week-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-header);
    border-bottom: 1px solid var(--color-gray-200);
}

.actions-rapides {
    padding: 0 var(--space-md);
    margin-top: var(--space-sm);
}