* {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "segoe ui", roboto, oxygen, ubuntu, cantarell, "fira sans", "droid sans", "helvetica neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
    --calendar-width-mobile: 100%;
    --calendar-width-tablet: 95%;
    --calendar-width-desktop: 100%;
    --calendar-max-width: 1200px;
    --header-height-mobile: 60px;
    --header-height-tablet: 70px;
    --header-height-desktop: 80px;
}

html {
    font-size: 14px;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

body {
    background-color: #FFFFFF;
    margin: 0;
    padding: 0;
}

.navtop {
    background-color: #3b4656;
    width: 100%;
    border: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height-mobile);
}

.navtop div {
    display: flex;
    margin: 0 auto;
    width: 100%;
    max-width: var(--calendar-width-desktop);
    height: 100%;
    padding: 0 1rem;
}

@media (max-width: 768px) {
    .navtop div {
        padding: 0 0.5rem;
    }
}

.navtop div h1, .navtop div a {
    display: inline-flex;
    align-items: center;
}

.navtop div h1 {
    flex: 1;
    font-size: 1.5rem;
    padding: 0;
    margin: 0;
    color: #ebedee;
    font-weight: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .navtop div h1 {
        font-size: 1.2rem;
    }
}

.navtop div a {
    padding: 0 20px;
    text-decoration: none;
    color: #c4c8cc;
    font-weight: bold;
}

.navtop div a i {
    padding: 2px 8px 0 0;
}

.navtop div a:hover {
    color: #ebedee;
}

.content {
    width: 100%;
    max-width: var(--calendar-width-desktop);
    margin: 0 auto;
    padding: 1rem;
}

@media (max-width: 768px) {
    .content {
        padding: 0.5rem;
    }
}

.content h2 {
    margin: 0;
    padding: 1.5rem 0;
    font-size: 1.5rem;
    border-bottom: 1px solid #ebebeb;
    color: #666666;
}

@media (max-width: 768px) {
    .content h2 {
        padding: 1rem 0;
        font-size: 1.25rem;
    }
}

/* Calendar specific styles */
/* Base calendar container */
.calendar-container {
    width: 100%;
    max-width: var(--calendar-max-width);
    margin: 0 auto;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Calendar header */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem; /* Reduced padding for tighter header */
    border-bottom: 1px solid #E5E7EB;
}

.month-title {
    font-size: 1.125rem; /* Further reduced from 1.25rem */
    font-weight: 600;
    color: #1F2937;
    text-align: center; /* Ensure centered text */
}

/* Calendar grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)); /* Using minmax to ensure equal widths */
    padding: 0.75rem; /* Reduced padding */
    gap: 0.75rem;
}

/* Weekday headers */
.weekday {
    width: 100%; /* Ensure full width within grid cell */
    text-align: center;
    font-weight: 500;
    color: #6B7280;
    padding: 0.75rem 0;
    border-bottom: 2px solid #E5E7EB;
    font-size: 1rem; /* Increased from 0.875rem */
    min-width: 0; /* Prevent overflow */
}

/* Calendar cells */
.calendar-cell {
    width: 100%; /* Ensure full width within grid cell */
    min-height: 120px; /* Minimum height instead of fixed aspect ratio */
    height: auto; /* Allow flexible height */
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    padding: 0.5rem 0.375rem; /* Reduced padding for better fit */
    background: white;
    position: relative;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
    overflow: hidden; /* Prevent content overflow */
}

.date-container {
    flex: 1; /* Take up available space */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center horizontally */
    justify-content: flex-start; /* Align to top */
    gap: 0.35rem; /* Increased gap */
    padding-top: 0.25rem; /* Add some top spacing */
}

.date-number {
    font-size: 1.25rem; /* Increased from 1.125rem */
    font-weight: 600; /* Slightly bolder */
    color: #1F2937;
    line-height: 1.2; /* Better line height */
    text-align: center;
}

.cost-indicator {
    font-size: 0.9375rem; /* Increased from 0.8125rem */
    color: #6B7280;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

/* Event styling */
.events-container {
    margin-top: auto; /* Push to bottom */
    width: 100%; /* Full width */
    padding: 0.25rem; /* Reduced padding */
    display: flex;
    flex-direction: column;
    gap: 0.125rem; /* Reduced gap */
    overflow: hidden; /* Prevent overflow */
    flex-shrink: 0; /* Prevent shrinking */
}

.event {
    padding: 0.1875rem 0.25rem; /* Reduced padding for tighter fit */
    border-radius: 0.25rem;
    font-size: 0.6875rem; /* Decreased from 0.75rem */
    text-align: center;
    line-height: 1.1; /* Tighter line height */
    width: 100%; /* Full width */
    overflow: hidden; /* Prevent text overflow */
    text-overflow: ellipsis; /* Show ellipsis for long text */
    white-space: nowrap; /* Prevent text wrapping */
    display: block; /* Ensure proper text overflow behavior */
}

/* Cell states */
.calendar-cell.inactive {
    background: #F9FAFB;
    opacity: 0.5;
}

.calendar-cell.today {
    border: 2px solid #6366F1;
    background: #EEF2FF;
}

.calendar-cell.weekend:not(.inactive) {
    background: #FFFBEB;
    border-color: #FEF3C7;
}

/* Responsive styles */
@media (max-width: 640px) {
    .calendar-container {
        width: 95%; /* Slightly wider on mobile */
        border-radius: 0.75rem;
        transform: scale(0.95); /* Less reduction on mobile */
    }

    .calendar-header {
        padding: 0.5rem; /* Reduced mobile header padding */
    }

    .month-title {
        font-size: 1rem; /* Further reduced from 1.125rem */
    }

    .calendar-grid {
        padding: 0.5rem; /* Reduced mobile grid padding */
        gap: 0.375rem; /* Slightly increased gap for mobile */
    }

    .calendar-cell {
        padding: 0.375rem 0.25rem; /* Further reduced mobile padding */
        min-height: 100px; /* Reduced minimum height for mobile */
    }

    .weekday .full-name {
        display: none;
    }

    .weekday .short-name {
        display: block;
        font-size: 1rem; /* Increased from 0.875rem */
    }

    .date-number {
        font-size: 1.125rem; /* Increased from 1rem */
    }

    .cost-indicator {
        font-size: 0.8125rem; /* Increased from 0.75rem */
    }

    .events-container {
        bottom: 0.125rem;
        left: 0.125rem;
        right: 0.125rem;
    }

    .event {
        padding: 0.2rem 0.3rem;
        font-size: 0.75rem; /* Increased from 0.6875rem */
    }
}

/* Tablet styles */
@media (min-width: 641px) and (max-width: 1024px) {
    .calendar-container {
        width: 92%; /* Slightly wider on tablet */
        transform: scale(0.92); /* Less reduction on tablet */
        margin: 1rem auto;
    }

    .calendar-grid {
        gap: 0.5rem; /* Reduced gap for tablet */
    }

    .calendar-cell {
        padding: 0.5rem 0.375rem; /* Balanced padding for tablet */
        min-height: 110px; /* Appropriate height for tablet */
    }

    .event {
        font-size: 0.625rem; /* Decreased from 0.6875rem */
        padding: 0.1875rem 0.25rem;
    }

    .weekday .short-name {
        display: none;
    }

    .weekday .full-name {
        display: block;
    }
}

/* Desktop styles */
@media (min-width: 1025px) {
    .calendar-container {
        margin: 1.5rem auto;
    }

    .calendar-grid {
        gap: 0.5rem;
    }

    .calendar-cell {
        min-height: 130px; /* Optimal height for desktop */
        padding: 0.625rem 0.5rem;
    }

    .event {
        font-size: 0.75rem; /* Decreased from 0.8125rem */
        padding: 0.25rem 0.375rem;
    }

    .weekday .short-name {
        display: none;
    }

    .weekday .full-name {
        display: block;
    }
}
