body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
}

.calendar-container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.calendar-header {
    display: flex;
    flex-direction: column;
    padding: 15px 20px;
    color: black;
    gap: 10px;
}

.calendar-header h2 {
    margin: 0;
    text-align: center;
    order: 2; 
}

.nav-group {
    display: flex;
    justify-content: center;
    gap: 10px;
    order: 1;
}

.calendar-header button {
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-decoration: none;
    color: #333;
    font-size: 0.9em;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.calendar-header button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

#prev-month {
    grid-column: 1;
    justify-self: start;
}

#next-month {
    grid-column: 3;
    justify-self: end;
}

#today-button {
    display: none;
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-decoration: none;
    color: #333;
    font-size: 0.9em;
    white-space: nowrap;
    transition: all 0.2s ease;
}

#today-button:hover {
    background-color: #f1f1f1;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background-color: #f1f1f1;
    font-weight: bold;
    text-align: center;
    padding: 10px 0;
}

.calendar-weekdays div {
    padding: 5px;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background-color: #e0e0e0;
}

.day {
    position: relative;
    min-height: 100px;
    background-color: white;
    overflow: visible;
}

.day:hover {
    background-color: #f9f9f9;
}

.day-number {
    font-weight: bold;
    margin: 5px;
    flex-shrink: 0; 
}

.other-month {
    color: #aaa;
    background-color: #f9f9f9;
}

.today {
    background-color: #e8f4fe;
}

.event-container {
    display: flex;
    flex-direction: column;
    min-height: 22px;
    position: relative;
    overflow: visible;
    padding-bottom: 5px;
}

.event.single-day {
    font-size: 12px;
    padding: 2px 5px;
    margin: 1px 0 0 5px;
    color: white;
    text-overflow: ellipsis;
    white-space: normal;
    cursor: pointer;
    box-sizing: border-box;
    height: 18px;
    line-height: 14px;
    border-radius: 3px;
    left: 5px;
    right: 5px;
    width: calc(100% - 10px);
    height: auto;
}

.event.multi-day {
    position: absolute;
    top: unset;
    font-size: 10.5px;
    padding-left: 5px;
    margin: 1px 0;
    color: white;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    z-index: 1;
    box-sizing: border-box;
    height: 18px;
}

.event.multi-day.start {
    border-radius: 3px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    left: 5px;
    right: 0;
    width: calc(100% - 5px);
    z-index: 2;
    overflow: visible;
}

.event.multi-day.middle {
    left: 0;
    right: 0;
    border-radius: 0;
    width: 100%;
}

.event.multi-day.end {
    border-radius: 3px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    right: 5px;
    left: 0;
    width: calc(100% - 5px);
}

.event a {
    text-decoration: none;
}

/* Mobile optimization - starts at 790px and below */
@media screen and (max-width: 790px) {
    .calendar-container {
        border-radius: 0;
        margin: 0 -20px;
        max-width: none;
    }
    
    .calendar-header {
        padding: 10px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .calendar-header h2 {
        order: 1;
        font-size: 1.1em;
        margin: 0 10px;
    }
    
    .nav-group {
        order: 2;
        gap: 5px;
    }
    
    .calendar-header button {
        padding: 6px 8px;
        font-size: 0.8em;
    }
    
    .calendar-weekdays {
        display: none;
    }
    
    .calendar-days {
        grid-template-columns: 1fr;
        gap: 5px;
        background-color: transparent;
    }
    
    .day {
        min-height: auto;
        border: 1px solid #e0e0e0;
        border-radius: 5px;
        padding: 5px;
    }
    
    .day-number {
        font-size: 1.1em;
        margin-bottom: 5px;
        padding-bottom: 5px;
        border-bottom: 1px solid #eee;
    }
    
    .event-container {
        display: block;
    }
    
    .event {
        position: static !important;
        width: 100% !important;
        margin: 5px 0 !important;
        padding: 5px !important;
        border-radius: 3px !important;
        height: auto !important;
    }
    
    .event.single-day,
    .event.multi-day.start,
    .event.multi-day.middle,
    .event.multi-day.end {
        position: relative;
        display: block;
        white-space: normal;
        margin: 5px 0 !important;
        padding: 5px !important;
        border-radius: 3px !important;
    }
    
    .event.multi-day.middle a::after,
    .event.multi-day.end a::after {
        content: " - Day " attr(data-day);
    }
    
    .other-month {
        display: none;
    }
    
    #today-button {
        display: inline-block;
    }

    .event.multi-day.middle a::after,
    .event.multi-day.end a::after {
        content: " - Day " attr(data-day);
    }

    .event.multi-day.start a::after {
        content: " - Day 1";
    }
}