/**
 * Much of this was from code on CodeShack (https://codeshack.io/event-calendar-php/ accessed: 2022-11-18)
 * Heavily modified by Jim Kinsman
 */
.calendar {
    display: flex;
    flex-flow: column;
}
.calendar .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
}
.calendar .header .month-year {
    font-size: 20px;
    font-weight: bold;
    color: #636e73;
    padding: 20px 0;
}
.calendar .days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    width: 100%;
}
.calendar .days .day_name {
    border-right: 1px solid #2c7aca;
    padding: 20px;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: bold;
    color: #818589;
    color: #fff;
    background-color: #448cd6;
}
.calendar .days .day_name:nth-child(7) {
    border: none;
}

.calendar .days .day_num {
    /*display: grid;
    grid-template-columns: repeat(7, 90px);*/
    border-right: 1px solid #e6e9ea;
    border-bottom: 1px solid #e6e9ea;
    /*padding: 15px;*/
    font-weight: bold;
    color: #7c878d;
    min-height: 100px;
}

.calendar .days .day_num span {
    display: inline-flex;
    width: 30px;
    font-size: 14px;
}
.calendar .days .day_num .event {
    /*margin-top: 10px;*/
    font-weight: 500;
    font-size: 10px;
    padding: 0 2px;
    border-radius: 3px;
    background-color: #f7c30d;
    color: #fff;
    word-wrap: break-word;
    margin-bottom: 1px;
    line-height: 15px;
}

.calendar .days .day_num .event a,
.calendar .days .day_num .event a:hover,
.calendar .days .day_num .event a:visited,
.calendar .days .day_num .event a:link {
    color: white;
}
.calendar .days .day_num .event.green {
    background-color: #51ce57;
}
.calendar .days .day_num .event.blue {
    background-color: #518fce;
}
.calendar .days .day_num .event.red {
    background-color: #ce5151;
}
.calendar .days .day_num .event.yellow {
    background-color: #d2d05a;
}
.calendar .days .day_num:nth-child(7n+1) {
    border-left: 1px solid #e6e9ea;
}
.calendar .days .day_num:hover {
    background-color: #fdfdfd;
}
.calendar .days .day_num.ignore {
    background-color: #fdfdfd;
    color: #ced2d4;
    cursor: inherit;
}
.calendar .days .day_num.selected {
    background-color: transparent !important;
    cursor: inherit;
}

.calendar .header .cal-nav-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 16px;
    color: #448cd6;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.calendar .header .cal-nav-btn:hover {
    background-color: #448cd6;
    color: #fff;
    border-color: #448cd6;
}

.calendar .days .hidemonth {
    border: none;
    border-bottom: 1px solid #e6e9ea;
}

.calendar .days .hidemonth.last{
    border-right: 1px solid #e6e9ea;
}

.calendar .days .day_num.today {
    background-color: #eef5ff;
}
.calendar .days .day_num.today > span:first-child {
    background-color: #448cd6;
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.calendar-with-minis {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.calendar-with-minis > .calendar {
    flex: 1;
    min-width: 0;
}
.calendar-mini-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 200px;
    max-width: 220px;
}
.mini-calendar {
    border: 1px solid #e6e9ea;
    border-radius: 6px;
    overflow: hidden;
    font-size: 12px;
}
.mini-calendar .mini-header {
    background-color: #448cd6;
    color: #fff;
    text-align: center;
    padding: 6px 0;
    font-weight: bold;
    font-size: 13px;
}
.mini-calendar table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.mini-calendar th {
    color: #818589;
    font-size: 10px;
    text-transform: uppercase;
    padding: 4px 0;
    text-align: center;
    font-weight: bold;
}
.mini-calendar td {
    text-align: center;
    padding: 4px 0;
    color: #7c878d;
    font-size: 12px;
}
.mini-calendar td.other-month {
    color: #ced2d4;
}
.mini-calendar td.mini-today {
    font-weight: bold;
    background-color: #fffacd;
    position: relative;
}
.mini-calendar td.mini-today span:not(.event-indicator) {
    color: inherit;
}
.mini-calendar td.has-events {
    position: relative;
}
.mini-calendar td .event-indicator {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    height: 4px;
    cursor: help;
    z-index: 1;
}

.mini-calendar td .event-indicator-dot {
    display: inline-block;
    width: 3px;
    height: 3px;
    background-color: #518fce;
    border-radius: 50%;
}

.mini-calendar td .event-indicator-dot.event-indicator-plus {
    width: 2px;
    height: 2px;
    background-color: #ff6b35;
}

.mini-calendar td .event-indicator:hover::after {
    content: attr(data-events);
    position: fixed;
    top: var(--tooltip-top, 0);
    left: var(--tooltip-left, 0);
    background: #2c3e50;
    color: #fff;
    font-size: 11px;
    font-weight: normal;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-width: 240px;
    width: auto;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
    line-height: 1.4;
}

.mini-calendar td .event-indicator:hover::before {
    content: '';
    position: fixed;
    top: var(--tooltip-arrow-top, 0);
    left: var(--tooltip-arrow-left, 0);
    border: 6px solid transparent;
    border-top-color: #2c3e50;
    z-index: 99999;
    pointer-events: none;
}

.mini-calendar td .mini-event-count {
    display: none;
}
.mini-calendar td a {
    color: inherit;
    text-decoration: none;
    display: block;
}
.mini-calendar td a:hover {
    background-color: #eef5ff;
    border-radius: 4px;
}

.mini-calendar td a:hover {
    background-color: #eef5ff;
    border-radius: 4px;
}

/* Centered Mini Calendars Layout */
.calendar-with-centered-minis {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.calendar-with-centered-minis > .calendar {
    flex: 1;
    min-width: 0;
}
.calendar-mini-center-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 240px;
    max-width: 260px;
}
.mini-calendar.current-month {
    box-shadow: 0 4px 12px rgba(68, 140, 214, 0.2);
    border-color: #448cd6;
    border-width: 2px;
    transform: scale(1.05);
    transform-origin: top center;
}
.mini-calendar.current-month .current-month-header {
    background: linear-gradient(135deg, #448cd6 0%, #3377c2 100%);
    font-size: 14px;
    padding: 8px 0;
}

/* Stacked Mini Calendars Layout */
.calendar-with-stacked-minis {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.calendar-with-stacked-minis > .calendar {
    flex: 1;
    min-width: 0;
}
.calendar-mini-stacked-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 200px;
    max-width: 220px;
}
.mini-calendar.stacked-current {
    box-shadow: 0 4px 12px rgba(68, 140, 214, 0.25);
    border-color: #448cd6;
    border-width: 2px;
    background: linear-gradient(135deg, #f0f7ff 0%, #ffffff 100%);
}
.mini-calendar.stacked-current .stacked-current-header {
    background: linear-gradient(135deg, #448cd6 0%, #3377c2 100%);
    font-size: 13px;
    font-weight: bold;
    padding: 7px 0;
    color: #fff;
}
.mini-calendar.stacked-current table {
    font-size: 11px;
}
.mini-calendar.stacked-current th {
    font-size: 9px;
    padding: 3px 0;
}
.mini-calendar.stacked-current td {
    padding: 3px 0;
    font-size: 11px;
}

@media (max-width: 1024px) {
    .calendar-with-minis,
    .calendar-with-centered-minis,
    .calendar-with-stacked-minis {
        gap: 15px;
    }
    .calendar-mini-sidebar,
    .calendar-mini-center-sidebar,
    .calendar-mini-stacked-sidebar {
        min-width: 180px;
        max-width: 200px;
    }
}

@media (max-width: 768px) {
    .calendar .days .day_name {
        padding: 8px 2px;
        font-size: 10px;
    }
    .calendar .days .day_num {
        min-height: 60px;
        font-size: 12px;
    }
    .calendar .days .day_num .event {
        font-size: 9px;
        line-height: 12px;
    }
    .calendar .header .month-year {
        font-size: 16px;
    }
    .calendar .header {
        padding: 0 5px;
    }
    
    .calendar-with-minis,
    .calendar-with-centered-minis,
    .calendar-with-stacked-minis {
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }
    
    .calendar-with-minis > .calendar,
    .calendar-with-centered-minis > .calendar,
    .calendar-with-stacked-minis > .calendar {
        width: 100%;
        flex: 1;
        min-width: 0;
    }
    
    .calendar-mini-sidebar,
    .calendar-mini-center-sidebar,
    .calendar-mini-stacked-sidebar {
        flex-direction: row;
        min-width: 0;
        max-width: 100%;
        width: 100%;
        gap: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .calendar-mini-sidebar .mini-calendar,
    .calendar-mini-center-sidebar .mini-calendar,
    .calendar-mini-stacked-sidebar .mini-calendar {
        flex: 0 0 calc(50% - 5px);
        min-width: 140px;
    }
    
    .mini-calendar.current-month {
        transform: scale(1.02);
    }
    
    .mini-calendar.stacked-current {
        flex: 0 0 calc(50% - 5px);
    }
    
    .mini-calendar {
        font-size: 11px;
    }
    
    .mini-calendar .mini-header {
        font-size: 12px;
        padding: 5px 0;
    }
    
    .mini-calendar th {
        font-size: 9px;
        padding: 3px 0;
    }
    
    .mini-calendar td {
        padding: 3px 0;
        font-size: 11px;
    }
    
    .mini-calendar td .event-indicator-dot {
        width: 2.5px;
        height: 2.5px;
    }
}

@media (max-width: 750px) {
    /* Medium mobile: ensure mini calendars fit without horizontal scrollbars */
    .calendar-mini-sidebar,
    .calendar-mini-center-sidebar,
    .calendar-mini-stacked-sidebar {
        gap: 8px;
        overflow: visible;
        max-height: none;
    }
    
    .calendar-mini-sidebar .mini-calendar,
    .calendar-mini-center-sidebar .mini-calendar,
    .calendar-mini-stacked-sidebar .mini-calendar {
        flex: 0 0 calc(33.333% - 6px);
        min-width: 100px;
        height: auto;
        max-height: none;
        overflow: visible;
    }
    
    .mini-calendar {
        font-size: 10px;
        overflow: visible;
    }
    
    .mini-calendar table {
        height: auto;
        overflow: visible;
    }
    
    .mini-calendar .mini-header {
        font-size: 11px;
        padding: 4px 0;
    }
    
    .mini-calendar th {
        font-size: 9px;
        padding: 2px 0;
    }
    
    .mini-calendar td {
        padding: 2px 0;
        font-size: 9px;
    }
    
    .mini-calendar td .event-indicator-dot {
        width: 2px;
        height: 2px;
    }
}

@media (max-width: 480px) {
    .calendar .days {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
    
    .calendar .header .cal-nav-btn {
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .calendar .header .month-year {
        font-size: 14px;
        padding: 15px 0;
    }
    
    .calendar .days .day_name {
        padding: 6px 1px;
        font-size: 9px;
    }
    
    .calendar .days .day_num {
        min-height: 50px;
        font-size: 11px;
        padding: 4px;
    }
    
    .calendar .days .day_num span {
        width: 24px;
        font-size: 12px;
    }
    
    .calendar .days .day_num .event {
        font-size: 8px;
        line-height: 10px;
        padding: 0 1px;
        margin-bottom: 1px;
    }
    
    .calendar-mini-sidebar,
    .calendar-mini-center-sidebar,
    .calendar-mini-stacked-sidebar {
        gap: 8px;
        overflow: visible;
        max-height: none;
    }
    
    .calendar-mini-sidebar .mini-calendar,
    .calendar-mini-center-sidebar .mini-calendar,
    .calendar-mini-stacked-sidebar .mini-calendar {
        flex: 0 0 calc(50% - 4px);
        min-width: 120px;
        height: auto;
        max-height: none;
        overflow: visible;
    }
    
    .mini-calendar {
        font-size: 10px;
        border-radius: 4px;
        overflow: visible;
    }
    
    .mini-calendar .mini-header {
        font-size: 11px;
        padding: 4px 0;
    }
    
    .mini-calendar th {
        font-size: 8px;
        padding: 2px 0;
    }
    
    .mini-calendar td {
        padding: 2px 0;
        font-size: 10px;
    }
    
    .mini-calendar td .event-indicator-dot {
        width: 2px;
        height: 2px;
    }
    
    .mini-calendar td.mini-today span {
        /* removed circular styling - using background highlight instead */
    }
    
    .mini-calendar table {
        width: 100%;
        height: auto;
        overflow: visible;
    }
    
    .mini-calendar td a {
        display: block;
        padding: 2px;
    }
    
    .mini-calendar td a:hover {
        border-radius: 3px;
    }
    
    /* Hide current month mini calendar on mobile (hide-current mode) */
    :root[data-mobile-mini-mode="hide-current"] .mini-calendar.stacked-current,
    :root[data-mobile-mini-mode="hide-current"] .mini-calendar.current-month {
        display: none;
    }
    
    /* Compact mode: make mini calendars much smaller */
    :root[data-mobile-mini-mode="compact"] .mini-calendar {
        font-size: 9px;
    }
    
    :root[data-mobile-mini-mode="compact"] .mini-calendar .mini-header {
        font-size: 10px;
        padding: 3px 0;
    }
    
    :root[data-mobile-mini-mode="compact"] .mini-calendar th {
        font-size: 7px;
        padding: 2px 0;
    }
    
    :root[data-mobile-mini-mode="compact"] .mini-calendar td {
        padding: 1px 0;
        font-size: 8px;
    }
    
    :root[data-mobile-mini-mode="compact"] .mini-calendar td .event-indicator-dot {
        width: 1.5px;
        height: 1.5px;
    }
    
    :root[data-mobile-mini-mode="compact"] .calendar-mini-sidebar,
    :root[data-mobile-mini-mode="compact"] .calendar-mini-center-sidebar,
    :root[data-mobile-mini-mode="compact"] .calendar-mini-stacked-sidebar {
        gap: 5px;
    }
    
    :root[data-mobile-mini-mode="compact"] .mini-calendar {
        border-radius: 3px;
    }
}
