/**
 * MonthlyCalendar CSS Styles
 * Enhanced styles for multiple events per date support
 */

/* Base Calendar Container */
.monthly-calendar {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    max-width: 100%;
    user-select: none;
}

/* Calendar Header */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
}

.calendar-title {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    flex: 1;
    margin: 0 20px;
}

/* Calendar Grid */
.calendar-grid {
    width: 100%;
    box-sizing: border-box;
}

.calendar-nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.calendar-nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.calendar-today-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.calendar-today-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Calendar Grid */
.calendar-grid {
    display: flex;
    flex-direction: column;
    background: white;
}

/* Day Headers */
.calendar-day-headers {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
}

.calendar-day-headers.with-week-numbers {
    grid-template-columns: 40px repeat(7, 1fr);
}

.calendar-day-header {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mobile day name in cells (hidden on desktop) */
.mobile-day-name {
    display: none;
}

/* Calendar Weeks */
.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid #f1f3f4;
    min-height: 100px;
}

.calendar-week.with-week-numbers {
    grid-template-columns: 40px repeat(7, 1fr);
}

/* Individual Day Cells */
.calendar-day {
    border: 1px solid transparent;
    position: relative;
    padding: 8px;
    border-right: 1px solid #f1f3f4;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    min-height: 100px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.calendar-day:last-child {
    border-right: none;
}

.calendar-day:hover {
    background: #f8f9fa;
}

.calendar-day.other-month {
    color: #adb5bd;
    background: #f8f9fa;
}

.calendar-day.today {
    background: #e3f2fd;
}

.calendar-day.today .day-number {
    background: #2196f3;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.calendar-day.selected {
    background: #e8f5e8;
    border: 2px solid #4caf50;
}

/* Day Header Container */
.day-header {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: space-between;
    margin-bottom: 4px;
    min-height: 20px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.day-header-left {
    display: flex;
    align-items: center;
}

/* Day Number */
.day-number {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    line-height: 1;
    flex-shrink: 0;
    min-width: 20px;
}

/* Daily Summary */
.daily-summary {
    display: flex;
    flex-direction: row;

    font-size: 0.7rem;
    line-height: 1.1;
    flex: 1;

    min-width: 0;
    overflow: hidden;
    text-align: right;
}

.summary-item {
    color: #6c757d;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-basis: 50%;
}

.summary-item.firstcontact {
    color: #6f42c1; /* Purple color matching the image */
}

.summary-item.secondcontact {
    color: #6c757d; /* Gray color matching the image */
}

.summary-mts {
    display: flex;
    gap: 4px;
    font-size: 0.8rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.mtf-summary {
    flex-basis: 30%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 14px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
}

/* Due Counter */
.due-counter {
    /* background: #ffc107; */
    color: #212529;
    /* border-radius: 50%; */
    /* width: 24px; */
    /* height: 24px; */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
    gap: 1px;
    /* margin-left: 4px; */
    /* box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); */
    min-width: 0;
}
.due-counter-count {
    background: hsl(48, 80%, 50%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    padding: 0px 3px;
}
.due-counter-icon {
    font-size: 0.75rem;
    font-weight: 600;
    /* display: none;  */
    color: hsl(48, 80%, 50%);
}

/* Events Container */
.day-events {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    border-top: 1px solid #e6e6e6;
}

/* Individual Events */
.calendar-event {
    background: #4caf50;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 3px;
}

.calendar-event:hover {
    background: #45a049;
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Event Overflow Indicator */
.calendar-event-overflow {
    /* background: #6c757d !important; */
    font-style: italic;
    opacity: 0.8;
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.calendar-event-overflow:hover {
    /* background: #5a6268 !important; */
    transform: none;
    box-shadow: none;
}

/* Grouped Events */
.calendar-event-grouped {
    background: #17a2b8 !important;
    border-left: 3px solid #138496;
    font-weight: 600;
}

.calendar-event-grouped:hover {
    background: #138496 !important;
}

/* Event Color Variants */
.calendar-event.event-primary {
    background: #007bff;
}
.calendar-event.event-primary:hover {
    background: #0056b3;
}

.calendar-event.event-success {
    background: #28a745;
}
.calendar-event.event-success:hover {
    background: #1e7e34;
}

.calendar-event.event-warning {
    background: #ffc107;
    color: #212529;
}
.calendar-event.event-warning:hover {
    background: #e0a800;
}

.calendar-event.event-danger {
    background: #dc3545;
}
.calendar-event.event-danger:hover {
    background: #c82333;
}

.calendar-event.event-info {
    background: #17a2b8;
}
.calendar-event.event-info:hover {
    background: #138496;
}

.calendar-event.event-secondary {
    background: #6c757d;
}
.calendar-event.event-secondary:hover {
    background: #545b62;
}

.calendar-event.event-dark {
    background: #343a40;
}
.calendar-event.event-dark:hover {
    background: #23272b;
}

.calendar-event.event-light {
    background: #f8f9fa;
    color: #212529;
    border: 1px solid #dee2e6;
}
.calendar-event.event-light:hover {
    background: #e2e6ea;
}

/* Week Numbers */
.calendar-week-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #6c757d;
    background: #f8f9fa;
    border-right: 1px solid #e1e5e9;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Hide day headers row on mobile */
    .calendar-day-headers {
        display: none;
    }

    /* Show mobile day names in cells */
    .mobile-day-name {
        display: block;
        font-size: 0.7rem;
        font-weight: 600;
        color: #6c757d;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 4px;
        opacity: 0.7;
    }

    /* Adjust day header layout for mobile */
    .day-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .calendar-week {
        grid-template-columns: repeat(3, 1fr);
        display: grid;
    }

    .calendar-week.with-week-numbers {
        grid-template-columns: 30px repeat(3, 1fr);
    }

    .calendar-day {
        min-height: 100px;
        padding: 8px;
        min-width: calc((100vw - 40px) / 3); /* Ensure readable width with 3 columns */
        border-right: 1px solid #f1f3f4;
        border-bottom: 1px solid #f1f3f4;
    }

    /* Remove right border from last column in each row */
    .calendar-week .calendar-day:nth-child(3n),
    .calendar-week .calendar-day:last-child {
        border-right: none;
    }

    .calendar-event {
        font-size: 0.7rem;
        padding: 1px 4px;
    }

    .day-number {
        font-size: 0.85rem;
    }

    .daily-summary {
        font-size: 0.65rem;
    }

    .summary-item {
        font-size: 0.65rem;
    }

    .due-counter {
        width: 20px;
        height: 20px;
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    /* Change to 2 columns on small mobile devices */
    .calendar-day-headers {
        grid-template-columns: repeat(2, 1fr);
    }

    .calendar-day-headers.with-week-numbers {
        grid-template-columns: 25px repeat(2, 1fr);
    }

    .calendar-week {
        grid-template-columns: repeat(2, 1fr);
        display: grid;
    }

    .calendar-week.with-week-numbers {
        grid-template-columns: 25px repeat(2, 1fr);
    }

    .calendar-day {
        min-height: 90px;
        padding: 6px;
        min-width: calc((100vw - 40px) / 2); /* Ensure readable width with 2 columns */
        border-right: 1px solid #f1f3f4;
        border-bottom: 1px solid #f1f3f4;
    }

    /* Remove right border from last column in each row */
    .calendar-week .calendar-day:nth-child(2n),
    .calendar-week .calendar-day:last-child {
        border-right: none;
    }

    .calendar-event {
        font-size: 0.65rem;
        padding: 1px 3px;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .daily-summary {
        font-size: 0.6rem;
    }

    .summary-item {
        font-size: 0.6rem;
    }

    .due-counter {
        width: 18px;
        height: 18px;
        font-size: 0.55rem;
    }
}

/* Dark Theme */
.monthly-calendar[data-theme="dark"] {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

.monthly-calendar[data-theme="dark"] .calendar-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

.monthly-calendar[data-theme="dark"] .calendar-day-headers {
    background: #4a5568;
    border-bottom-color: #718096;
}

.monthly-calendar[data-theme="dark"] .calendar-day-header {
    color: #a0aec0;
}

.monthly-calendar[data-theme="dark"] .calendar-week {
    border-bottom-color: #4a5568;
}

.monthly-calendar[data-theme="dark"] .calendar-day {
    border-right-color: #4a5568;
    color: #e2e8f0;
}

.monthly-calendar[data-theme="dark"] .calendar-day:hover {
    background: #4a5568;
}

.monthly-calendar[data-theme="dark"] .calendar-day.other-month {
    color: #718096;
    background: #4a5568;
}

.monthly-calendar[data-theme="dark"] .calendar-day.today {
    background: #2b6cb0;
}

.monthly-calendar[data-theme="dark"] .calendar-day.selected {
    background: #2f855a;
    border-color: #38a169;
}

.monthly-calendar[data-theme="dark"] .day-number {
    color: #e2e8f0;
}

.monthly-calendar[data-theme="dark"] .calendar-week-number {
    background: #4a5568;
    border-right-color: #718096;
    color: #a0aec0;
}

/* Accessibility Improvements */
.calendar-nav-btn:focus,
.calendar-today-btn:focus,
.calendar-day:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.calendar-event:focus {
    outline: 2px solid #ffc107;
    outline-offset: 1px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .monthly-calendar {
        border: 2px solid #000;
    }

    .calendar-day {
        border: 1px solid #000;
    }

    .calendar-event {
        border: 1px solid #000;
        font-weight: bold;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .calendar-nav-btn,
    .calendar-today-btn,
    .calendar-day,
    .calendar-event {
        transition: none;
    }

    .calendar-nav-btn:hover,
    .calendar-today-btn:hover,
    .calendar-event:hover {
        transform: none;
    }
}

/* Minimal Theme */
.monthly-calendar[data-theme="minimal"] {
    border: none;
    box-shadow: none;
    background: transparent;
    font-family: inherit;
}

.monthly-calendar[data-theme="minimal"] .calendar-header {
    background: transparent;
    color: #333;
    border-bottom: 1px solid #e1e5e9;
    padding: 12px 16px;
}

.monthly-calendar[data-theme="minimal"] .calendar-title {
    color: #333;
    font-weight: 500;
}

.monthly-calendar[data-theme="minimal"] .calendar-nav-btn {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    width: 32px;
    height: 32px;
    font-size: 1rem;
}

.monthly-calendar[data-theme="minimal"] .calendar-nav-btn:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #bbb;
}

.monthly-calendar[data-theme="minimal"] .calendar-today-btn {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.monthly-calendar[data-theme="minimal"] .calendar-today-btn:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #bbb;
}

.monthly-calendar[data-theme="minimal"] .calendar-day-headers {
    background: transparent;
    border-bottom: 1px solid #e1e5e9;
}

.monthly-calendar[data-theme="minimal"] .calendar-day-header {
    color: #666;
    font-weight: 500;
    padding: 8px 4px;
}

.monthly-calendar[data-theme="minimal"] .calendar-week {
    border-bottom: 1px solid #f1f3f4;
    min-height: 80px;
}

.monthly-calendar[data-theme="minimal"] .calendar-day {
    border-right: 1px solid #f1f3f4;
    padding: 6px;
    min-height: 80px;
}

.monthly-calendar[data-theme="minimal"] .calendar-day:hover {
    background: #f8f9fa;
}

.monthly-calendar[data-theme="minimal"] .calendar-day.other-month {
    color: #adb5bd;
    background: transparent;
    background: #f8f9fa;
}

.monthly-calendar[data-theme="minimal"] .calendar-day.other-month:hover {
    background: #f8f9fa;
}

.monthly-calendar[data-theme="minimal"] .calendar-day.today {
    background: #f0f8ff;
}

.monthly-calendar[data-theme="minimal"] .calendar-day.today .day-number {
    background: #007bff;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.monthly-calendar[data-theme="minimal"] .calendar-day.selected {
    background: #e8f5e8;
    border: 1px solid #4caf50;
}

.monthly-calendar[data-theme="minimal"] .day-number {
    color: #333;
    font-size: 0.85rem;
    font-weight: 400;
}

.monthly-calendar[data-theme="minimal"] .calendar-day.selected .day-number {
    font-weight: bold;
    color: #279027;
    font-size: 0.9em;
    margin-left: 2px;
}

.monthly-calendar[data-theme="minimal"] .calendar-event {
    background: #6c757d;
    color: white;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 0.7rem;
    font-weight: 400;
}

.monthly-calendar[data-theme="minimal"] .calendar-event:hover {
    background: #5a6268;
    transform: none;
    box-shadow: none;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-primary {
    background: #007bff;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-primary:hover {
    background: #0056b3;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-success {
    background: #28a745;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-success:hover {
    background: #1e7e34;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-warning {
    background: #ffc107;
    color: #212529;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-warning:hover {
    background: #e0a800;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-danger {
    background: #dc3545;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-danger:hover {
    background: #c82333;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-info {
    background: #17a2b8;
}

.monthly-calendar[data-theme="minimal"] .calendar-event.event-info:hover {
    background: #138496;
}

.monthly-calendar[data-theme="minimal"] .calendar-event-overflow {
    /* background: #6c757d !important; */
    background: none !important;
    color: #6c757d;
    font-style: italic;
    opacity: 0.7;
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.monthly-calendar[data-theme="minimal"] .calendar-event-grouped {
    background: #17a2b8 !important;
    border-left: 2px solid #138496;
    font-weight: 500;
}

.monthly-calendar[data-theme="minimal"] .calendar-week-number {
    background: transparent;
    border-right: 1px solid #e1e5e9;
    color: #6c757d;
    font-size: 0.75rem;
}

.monthly-calendar[data-theme="minimal"] .day-header {
    margin-bottom: 2px;
    min-height: 18px;
}

.monthly-calendar[data-theme="minimal"] .daily-summary {
    font-size: 0.75rem;
}

.monthly-calendar[data-theme="minimal"] .summary-item {
    color: #6c757d;
    font-weight: 400;
}

.monthly-calendar[data-theme="minimal"] .summary-item.firstcontact {
    color: #6f42c1;
}

.monthly-calendar[data-theme="minimal"] .summary-item.secondcontact {
    color: #6c757d;
    min-width: fit-content;
}

.monthly-calendar[data-theme="minimal"] .due-counter {
    /* background: #ffc107; */
    color: #212529;
    /* width: 20px; */
    /* height: 20px; */
    font-size: 0.65rem;
    /* margin-left: 2px; */
    /* box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); */
}

.monthly-calendar .calendar-event.mtsr-cal-day-event-mt {
    background: none !important;
    color: #212529 !important;
}
