/**
 * Modern Booking.com-style DatePicker
 * Responsive, accessible, and beautiful date range picker
 */

/* Hide old jQuery datepickers when modern datepicker is active */
.ui-datepicker,
.ui-datepicker-div {
    display: none !important;
    visibility: hidden !important;
}

/* DatePicker Container */
.modern-datepicker {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    margin-top: 4px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.modern-datepicker.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* DatePicker Header */
.datepicker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.date-range-display {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.date-range-display.empty {
    color: #999;
}

.datepicker-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.datepicker-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Calendar Container */
.calendar-container {
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Month Navigation */
.month-nav {
    position: absolute;
    top: 15px;
    z-index: 10;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.month-nav:hover {
    background: #f8f9fa;
    border-color: #0071c2;
    color: #0071c2;
}

.month-nav.prev {
    left: 12px;
}

.month-nav.next {
    right: 12px;
}

.month-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.month-nav:disabled:hover {
    background: #ffffff;
    border-color: #e0e0e0;
    color: inherit;
}

/* Calendar Grid */
.calendar-grid {
    flex: 1;
    min-width: 280px;
    padding: 20px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.calendar-grid:not(:last-child) {
    border-right: 1px solid #f0f0f0;
}

/* Month Header */
.month-header {
    text-align: center;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Days Grid */
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

/* Day Headers */
.day-header {
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: #666;
    padding: 8px 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Day Cells */
.day-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    color: #333;
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
    min-height: 40px;
}

.day-cell:hover {
    background: #f0f8ff;
    color: #0071c2;
}

/* Day Cell States */
.day-cell.other-month {
    color: #ccc;
    cursor: default;
}

.day-cell.other-month:hover {
    background: transparent;
    color: #ccc;
}

.day-cell.disabled {
    color: #ccc;
    cursor: not-allowed;
}

.day-cell.disabled:hover {
    background: transparent;
    color: #ccc;
}

.day-cell.today {
    font-weight: 600;
    border: 2px solid #0071c2;
}

.day-cell.selected {
    background: #0071c2;
    color: #ffffff;
    font-weight: 500;
}

.day-cell.selected:hover {
    background: #005999;
    color: #ffffff;
}

/* Range Selection */
.day-cell.in-range {
    background: #e6f3ff;
    color: #0071c2;
}

.day-cell.range-start {
    background: #0071c2;
    color: #ffffff;
    border-radius: 4px 0 0 4px;
}

.day-cell.range-end {
    background: #0071c2;
    color: #ffffff;
    border-radius: 0 4px 4px 0;
}

.day-cell.range-start.range-end {
    border-radius: 4px;
}

.day-cell.hover-range {
    background: #f0f8ff;
    color: #0071c2;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modern-datepicker {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        border-radius: 0;
        border: none;
        transform: translateY(100%);
    }

    .modern-datepicker.show {
        transform: translateY(0);
    }

    .calendar-container {
        flex-direction: column;
        height: calc(100vh - 80px);
        overflow-y: auto;
    }

    .calendar-grid {
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid #f0f0f0;
    }

    .calendar-grid:last-child {
        border-bottom: none;
    }

    .month-nav {
        display: none;
    }

    .datepicker-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: #ffffff;
        border-bottom: 1px solid #e0e0e0;
    }
}

/* Single Month View (Mobile) */
@media (max-width: 480px) {
    .calendar-container {
        display: block;
    }
    
    .calendar-grid:not(.active) {
        display: none;
    }
    
    .month-nav {
        display: flex;
    }
}

/* Animation for month transitions */
.calendar-container.transitioning .calendar-grid {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus styles for accessibility */
.day-cell:focus {
    outline: 2px solid #0071c2;
    outline-offset: 2px;
}

.month-nav:focus {
    outline: 2px solid #0071c2;
    outline-offset: 2px;
}

/* Loading state */
.modern-datepicker.loading {
    pointer-events: none;
}

.modern-datepicker.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Smooth scrolling for mobile */
@media (max-width: 768px) {
    .calendar-container {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .day-cell.selected,
    .day-cell.range-start,
    .day-cell.range-end {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .modern-datepicker,
    .calendar-grid,
    .day-cell,
    .month-nav {
        transition: none;
    }
}

/* RTL Support */
[dir="rtl"] .month-nav.prev {
    left: auto;
    right: 12px;
}

[dir="rtl"] .month-nav.next {
    right: auto;
    left: 12px;
}

[dir="rtl"] .day-cell.range-start {
    border-radius: 0 4px 4px 0;
}

[dir="rtl"] .day-cell.range-end {
    border-radius: 4px 0 0 4px;
}
