/* Custom Flatpickr Styling for Mas de Pradels */

/* Main calendar container */
.flatpickr-calendar {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: none;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Month navigation */
.flatpickr-months {
    background: #fed136;
    border-radius: 8px 8px 0 0;
    padding: 10px 0;
}

.flatpickr-month {
    color: #212529;
    fill: #212529;
}

.flatpickr-current-month {
    font-size: 120%;
    font-weight: 600;
    color: #212529;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 8px;
    font-weight: 600;
}

.flatpickr-current-month .numInputWrapper {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Navigation arrows */
.flatpickr-prev-month,
.flatpickr-next-month {
    fill: #212529;
}

.flatpickr-prev-month:hover,
.flatpickr-next-month:hover {
    fill: #000000;
}

.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg {
    fill: #000000;
}

/* Weekday headers */
.flatpickr-weekdays {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

span.flatpickr-weekday {
    color: #6c757d;
    font-weight: 600;
    font-size: 90%;
}

/* Day cells */
.flatpickr-day {
    color: #495057;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.flatpickr-day:hover {
    background: #fed136;
    color: #212529;
    border-color: #fed136;
}

/* Disabled days (not Saturdays in July/August) */
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    color: #dee2e6;
    background: transparent;
    cursor: not-allowed;
}

/* Today */
.flatpickr-day.today {
    border-color: #fed136;
    background: rgba(254, 209, 54, 0.1);
}

.flatpickr-day.today:hover {
    background: #fed136;
    color: #212529;
}

/* Selected date */
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: #fed136;
    color: #212529;
    border-color: #fed136;
    font-weight: 700;
}

/* In range dates */
.flatpickr-day.inRange {
    background: rgba(254, 209, 54, 0.2);
    border-color: transparent;
    box-shadow: -5px 0 0 rgba(254, 209, 54, 0.2), 5px 0 0 rgba(254, 209, 54, 0.2);
}

/* Start and end range */
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: #fed136;
    color: #212529;
    border-color: #fed136;
}

/* Days from other months */
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #ced4da;
}

/* Input field styling when focused */
#startDate.flatpickr-input,
#endDate.flatpickr-input {
    cursor: pointer;
}

#startDate.flatpickr-input:focus,
#endDate.flatpickr-input:focus {
    border-color: #fed136;
    box-shadow: 0 0 0 0.2rem rgba(254, 209, 54, 0.25);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .flatpickr-calendar {
        width: 95vw !important;
        max-width: 380px !important;
        font-size: 16px;
    }

    .flatpickr-months {
        padding: 15px 0;
    }

    .flatpickr-current-month {
        font-size: 140%;
        padding: 5px 0;
    }

    .flatpickr-prev-month,
    .flatpickr-next-month {
        padding: 15px;
    }

    .flatpickr-prev-month svg,
    .flatpickr-next-month svg {
        width: 18px;
        height: 18px;
    }

    .flatpickr-weekdays {
        height: 50px;
    }

    .flatpickr-weekday {
        font-size: 14px;
        font-weight: 600;
        line-height: 50px;
    }

    .flatpickr-days {
        width: 100% !important;
    }

    .flatpickr-day {
        max-width: none !important;
        height: 48px !important;
        line-height: 48px !important;
        font-size: 16px !important;
        flex: 1 0 14.28%;
        margin: 0;
    }

    .flatpickr-day.today {
        font-size: 16px !important;
    }

    /* Ensure calendar is centered on mobile */
    .flatpickr-calendar.open {
        margin: 0 auto;
        left: 50% !important;
        transform: translateX(-50%);
    }
}

/* Animation */
.flatpickr-calendar.open {
    animation: flatpickrFadeIn 0.2s ease-out;
}

@keyframes flatpickrFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Highlight Saturdays in July and August with a special indicator */
.flatpickr-day.flatpickr-disabled.notSaturday {
    position: relative;
}

/* Mobile Year Selector Button */
.flatpickr-year-selector-btn {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.flatpickr-year-selector-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.1);
}

/* Only show on mobile */
@media (max-width: 768px) {
    .flatpickr-year-selector-btn {
        display: flex;
    }

    /* Make sure months container has relative positioning */
    .flatpickr-months {
        position: relative;
    }
}

/* Year Grid Overlay */
.flatpickr-year-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Year Grid Container */
.flatpickr-year-grid-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-width: 90%;
    width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Year Grid Header */
.flatpickr-year-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #fed136;
}

.flatpickr-year-grid-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

.flatpickr-year-grid-close {
    background: #fed136;
    border: none;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
    color: #212529;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.flatpickr-year-grid-close:hover {
    background: #ffc107;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Year Grid */
.flatpickr-year-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.flatpickr-year-grid-item {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 16px 12px;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.flatpickr-year-grid-item:hover {
    background: #fed136;
    border-color: #fed136;
    transform: scale(1.05);
}

.flatpickr-year-grid-item.current-year {
    border-color: #fed136;
    background: rgba(254, 209, 54, 0.1);
}

.flatpickr-year-grid-item.selected-year {
    background: #fed136;
    border-color: #fed136;
    color: #212529;
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    .flatpickr-year-grid-container {
        width: 85vw;
        max-width: 340px;
    }

    .flatpickr-year-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .flatpickr-year-grid-item {
        padding: 20px 16px;
        font-size: 20px;
    }
}

/* Add a small indicator for available Saturdays */
.flatpickr-day:not(.flatpickr-disabled)::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #28a745;
    border-radius: 50%;
}

.flatpickr-day.selected::after,
.flatpickr-day.selected:hover::after {
    background: #212529;
}

