/* ========================================
   CALENDAR - MODERN GRAY/WHITE - COMPACT (50% SMALLER)
   ======================================== */

/* Calendar Overlay */
.calendar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 3000;
}

.calendar-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Calendar Dialog - SMALLER */
.calendar-dialog {
    background: white;
    border-radius: 12px;
    max-width: 500px;  /* Reduced from 900px for mobile/single month */
    max-height: 80vh;  /* Reduced from 90vh */
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Desktop: Wider for 2 months side-by-side */
@media (min-width: 769px) {
    .calendar-dialog {
        max-width: 800px;  /* Wider for 2 months */
    }
}

/* Calendar Header - SMALLER */
.calendar-header {
    background: #212529;
    color: white;
    padding: 0.75rem 1rem;  /* Reduced from 1rem 1.25rem */
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;  /* Reduced from 1rem */
    flex-shrink: 0;
}

.calendar-back {
    background: none;
    border: none;
    color: white;
    font-size: 20px;  /* Reduced from 24px */
    cursor: pointer;
    padding: 0;
    width: 32px;  /* Reduced from 36px */
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.calendar-back:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Desktop month navigation buttons - Only in navigation row */
.calendar-prev-month,
.calendar-next-month {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.calendar-prev-month:hover,
.calendar-next-month:hover {
    background: rgba(255, 255, 255, 0.1);
}

.calendar-prev-month:disabled,
.calendar-next-month:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.calendar-prev-month:disabled:hover,
.calendar-next-month:disabled:hover {
    background: none;
}

.calendar-title {
    font-size: 1rem;  /* Reduced from 1.125rem */
    font-weight: 600;
    margin: 0;
}

/* Calendar Body */
.calendar-body {
    display: flex;
    flex-direction: column;
    min-height: 0;  /* Important for flex child to shrink */
    flex: 1;
}

/* Desktop Navigation Row - appears between header and calendar */
.calendar-navigation-row {
    display: none;  /* Hidden on mobile */
}

@media (min-width: 769px) {
    .calendar-navigation-row {
        display: flex;
        justify-content: space-between;  /* Align buttons to edges */
        align-items: center;
        padding: 0.75rem 1rem;
        background: #f8f9fa;
        border-bottom: 1px solid #e9ecef;
        flex-shrink: 0;
    }
    
    .calendar-navigation-row .calendar-prev-month,
    .calendar-navigation-row .calendar-next-month {
        display: flex;  /* Show these navigation arrows */
        background: white;
        border: 1px solid #dee2e6;
        color: #495057;
        width: 36px;
        height: 36px;
    }
    
    .calendar-navigation-row .calendar-prev-month:hover,
    .calendar-navigation-row .calendar-next-month:hover {
        background: #e9ecef;
        border-color: #ced4da;
    }
    
    .calendar-navigation-row .calendar-prev-month:disabled,
    .calendar-navigation-row .calendar-next-month:disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }
    
    .calendar-navigation-row .calendar-prev-month:disabled:hover,
    .calendar-navigation-row .calendar-next-month:disabled:hover {
        background: white;
    }
}

/* Weekdays Header (static) - MOBILE ONLY */
.calendar-weekdays {
    display: grid;
    grid-template-columns: 28px repeat(7, 1fr);
    gap: 2px;
    padding: 0.75rem 1rem 0.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Desktop: Hide static header, use per-month headers instead */
@media (min-width: 769px) {
    .calendar-weekdays {
        display: none;
    }
}

.calendar-weekday {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
}

.calendar-weekday.week-col {
    /* Week column header */
}

/* Per-Month Weekday Header (Desktop) */
.month-weekday-header {
    display: none;  /* Hidden on mobile by default */
}

@media (min-width: 769px) {
    .month-weekday-header {
        display: grid;
        grid-template-columns: 28px repeat(7, 1fr);
        gap: 2px;
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #f8f9fa;
    }
}

.weekday-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
}

/* Calendar Container - SMALLER */
.calendar-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem;
    background: #f8f9fa;
}

/* Desktop: Grid layout for 2 months side-by-side */
@media (min-width: 769px) {
    .calendar-container-desktop {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        padding: 1rem;
        overflow-y: visible;  /* No scroll on desktop */
    }
    
    .calendar-container-desktop .calendar-month {
        margin-bottom: 0;  /* No margin in grid */
    }
}

/* Calendar Month - SMALLER */
.calendar-month {
    background: white;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid #e9ecef;
}

/* Desktop: Fixed height to prevent jumping */
@media (min-width: 769px) {
    .calendar-container-desktop .calendar-month {
        height: 340px;  /* Increased to fit 6 full weeks */
        display: flex;
        flex-direction: column;
    }
}

.calendar-month:last-child {
    margin-bottom: 0;
}

.month-title {
    font-size: 0.875rem;  /* Reduced from 1rem */
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.75rem;  /* Reduced from 1rem */
    text-align: center;
}

/* Calendar Week - SMALLER */
.calendar-week {
    display: grid;
    grid-template-columns: 28px repeat(7, 1fr);  /* Reduced from 40px */
    gap: 2px;  /* Reduced from 4px */
    margin-bottom: 2px;
}

/* Week Number - SMALLER */
.week-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;  /* Reduced from 0.75rem */
    color: #6c757d;
    font-weight: 500;
}

/* Calendar Day - SMALLER */
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.75rem;  /* Reduced from 0.875rem */
    color: #212529;
    transition: all 0.2s;
    position: relative;
    min-height: 28px;  /* Ensure minimum touch target */
}

.calendar-day:hover:not(.calendar-day-disabled):not(.calendar-day-empty) {
    background: #212529;
    color: white;
}

.calendar-day:active:not(.calendar-day-disabled):not(.calendar-day-empty) {
    background: #212529;
    color: white;
}

.calendar-day-empty {
    cursor: default;
}

.calendar-day-disabled {
    color: #ced4da;
    cursor: not-allowed;
}

.calendar-day-start,
.calendar-day-end {
    background: #212529;
    color: white;
    font-weight: 600;
}

.calendar-day-range {
    background: #212529;
    color: white;
}

/* Range preview on hover - same as selected */
.calendar-day-range-preview {
    background: #212529;
    color: white;
}

.calendar-day-start.calendar-day-range,
.calendar-day-end.calendar-day-range {
    background: #212529;
}

/* Calendar Footer - SMALLER */
.calendar-footer {
    padding: 0.75rem 1rem;  /* Reduced from 1rem 1.25rem */
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    background: white;
    border-radius: 0 0 12px 12px;
}

.calendar-confirm {
    background: #FFC107;
    color: #212529;
    border: none;
    padding: 0.5rem 1.25rem;  /* Reduced from 0.625rem 1.5rem */
    border-radius: 6px;
    font-size: 0.875rem;  /* Reduced from 0.9375rem */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.calendar-confirm:hover:not(:disabled) {
    background: #FFB300;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.3);
}

.calendar-confirm:disabled {
    background: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
}

/* Scrollbar */
.calendar-container::-webkit-scrollbar {
    width: 4px;  /* Reduced from 6px */
}

.calendar-container::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.calendar-container::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 2px;
}

.calendar-container::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .calendar-dialog {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
    
    .calendar-header {
        border-radius: 0;
        padding: 0.875rem 1rem;  /* Slightly larger on mobile for touch */
    }
    
    .calendar-footer {
        border-radius: 0;
        padding: 0.875rem 1rem;
    }
    
    /* Larger touch targets on mobile */
    .calendar-day {
        min-height: 32px;
        font-size: 0.875rem;
    }
    
    .calendar-weekdays {
        padding: 0.875rem 1rem 0.625rem;
    }
    
    .calendar-weekday {
        font-size: 0.6875rem;
    }
}
