.calendar-grid-container {
    display: grid;
    /* 1 column for time (auto-sized), 7 for days (equal width) */
    grid-template-columns: auto repeat(7, 1fr);
    /* Each 30-min slot is a 30px high row. Header is auto-sized. */
    grid-template-rows: auto;
    grid-auto-rows: 30px; /* Default height for all other rows */
    border: 1px solid #dee2e6; /* Outer border */
}

/* For print, we need to adjust the row height to fit more content */
@media print {
    .print-weekly .calendar-grid-container {
        grid-auto-rows: 15px !important;
    }
}

/* Styling for all cells in the grid */
.grid-cell {
    box-sizing: border-box; /* Ensures padding/border is inside the cell */
    position: relative; /* Context for event overlays */
}

/* Styling for the header cells (Godzina, Poniedzia�ek, etc.) */
.calendar-header {
    font-weight: bold;
    text-align: center;
    padding: 8px 4px;
    background-color: var(--bs-tertiary-bg);
    border-bottom: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    position: sticky; /* Keeps header visible on scroll */
    top: 0;
    z-index: 10;
}

/* Styling for the time slots on the left */
.time-slot {
    text-align: right;
    padding-right: 8px;
    font-size: 0.8em;
    color: #6c757d;
    border-right: 1px solid #dee2e6;
    grid-column: 1; /* Always in the first column */
    background-color: var(--bs-tertiary-bg);
}

/* The empty background cells for each day/time slot */
.calendar-cell-bg {
    border-bottom: 1px solid #e9ecef;
    border-right: 1px solid #dee2e6;
}

    /* The top half of an hour has a dashed line */
    .calendar-cell-bg.half-hour {
        border-bottom-style: dashed;
    }

/* --- Styling for the Event Overlays --- */
.event-overlay {
    /* These are also grid items, placed on top of the background */
    background-color: rgba(91, 192, 222, 0.85);
    border: 1px solid #31708f;
    color: var(--bs-table-bg);
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.75em;
    overflow: hidden;
    z-index: 5;
    transition: background-color 0.2s ease;
}

    .event-overlay:hover {
        background-color: rgba(49, 112, 143, 1);
        z-index: 6;
    }

    .event-overlay a {
        color: #e0f7ff;
        font-weight: bold;
    }

/* --- Styling for the Leaves Overlay --- */
.leaves-overlay {
    /* These are placed below activities but above availability */
    background-color: #857c75A0;
    border: 1px solid #FFA500;
    border-radius: 2px;
    z-index: 2;
    pointer-events: none; /* Allow clicks to pass through to activities below */
    position: relative;
}

    .leaves-overlay .leaves-label {
        font-size: 10px;
        color: #8B4513;
        text-align: center;
        padding: 2px;
        font-weight: bold;
        text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
    }

    /* Dark mode support for leaves overlay */
    [data-bs-theme="dark"] .leaves-overlay {
        background-color: rgba(255, 165, 0, 0.3);
        border-color: #FF8C00;
    }

    [data-bs-theme="dark"] .leaves-overlay .leaves-label {
        color: #FFD700;
        text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    }

/* --- Styling for the Availability Overlay --- */
.availability-overlay {
    /* These are placed below activities but above background */
    background-color: rgba(144, 238, 144, 0.3);
    border-radius: 2px;
    z-index: 1;
    pointer-events: none; /* Allow clicks to pass through to activities below */
    position: relative;
}

    .availability-overlay .availability-label {
        font-size: 10px;
        color: #006400;
        text-align: center;
        padding: 2px;
        font-weight: bold;
        text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
    }

    /* Dark mode support for availability overlay */
    [data-bs-theme="dark"] .availability-overlay {
        background-color: rgba(144, 238, 144, 0.2);
        border-color: #228B22;
    }

    [data-bs-theme="dark"] .availability-overlay .availability-label {
        color: #98FB98;
        text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    }

/* --- Styling for canceled events --- */
.canceled-event {
    opacity: 0.6;
    background-color: #f8d7da !important;
    border-color: #f5c6cb !important;
}

.canceled-event .event-info {
    position: relative;
}

.canceled-event .event-info::after {
    content: "ODWOŁANO";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: bold;
    white-space: nowrap;
    z-index: 10;
}

.canceled-event .event-info strong {
    text-decoration: line-through;
}

.canceled-stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: bold;
    white-space: nowrap;
    z-index: 10;
}

/* Dark mode support for canceled events */
[data-bs-theme="dark"] .canceled-event {
    background-color: rgba(220, 53, 69, 0.2) !important;
    border-color: rgba(220, 53, 69, 0.5) !important;
}

[data-bs-theme="dark"] .canceled-event .event-info::after {
    background-color: rgba(220, 53, 69, 0.9);
}
