/* Sol Casa Date Range Picker Styles - Optimized Version */
/* css/date-range-picker.css */

/* ================================
   Container and Input Styles
   ================================ */
.sol-casa-picker-container {
    position: relative !important;
    width: 100%;
    z-index: 3;
}

.date-range-input {
    cursor: pointer;
    background-color: #fff;
    position: relative;
    padding-right: 35px;
    width: 100%;
}

.date-range-input:focus {
    background-color: #fff;
}

.sol-casa-picker-container::after {
    content: '\f073';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
    z-index: 1;
}

/* ================================
   Picker Popup Base Styles
   ================================ */
.picker-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    bottom: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    width: 420px;
    max-width: 420px;
    min-width: 350px;
    max-height: 80vh;
    overflow-y: auto;
    box-sizing: border-box;
    animation: slideDown 0.3s ease-out;
    transform: none; /* Ensure no transform by default */
}
@media (min-width: 769px) {
    .picker-popup {
        position: absolute !important;
        /* Don't override top/left here - let JS handle it */
        width: 420px !important;
        max-width: 420px !important;
        min-width: 350px !important;
        transform: none !important; /* Critical - no transform on desktop */
    }
    
    /* Ensure popup doesn't get mobile styles on desktop */
    .picker-popup.position-center {
        transform: none !important;
    }
}

/* Position Variations */
.picker-popup.position-top {
    top: auto;
    bottom: calc(100% + 8px);
    animation: slideUp 0.3s ease-out;
}

.picker-popup.position-right {
    left: auto;
    right: 0;
}

/* ================================
   Header Section
   ================================ */
.picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.month-year-display {
    font-weight: 600;
    font-size: 1.1rem;
    color: #1f2937;
    min-width: 140px;
    text-align: center;
}

.picker-header .btn-link {
    color: #6b7280;
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.picker-header .btn-link:hover {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
    border-color: #2563eb;
}

/* ================================
   Calendar Grid
   ================================ */
.calendar-grid {
    padding: 1rem;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.weekday {
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    padding: 0.5rem 0;
    background: #f8f9fa;
    border-radius: 6px;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

/* ================================
   Calendar Day Styles
   ================================ */
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: default;
    position: relative;
    background: #f9fafb;
    transition: all 0.2s ease;
    min-height: 48px;
    border: 1px solid #e5e7eb;
    padding: 4px;
}

.calendar-day.empty {
    background: transparent;
    border: none;
}

.calendar-day.selectable {
    cursor: pointer;
    background: white;
}

.calendar-day.selectable:hover:not(.selected-start):not(.selected-end):not(.in-range) {
    background: #e5e7eb;
    transform: scale(1.05);
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

/* Day States */
.calendar-day.available {
    background: #dcfce7;
    border-color: #bbf7d0;
}

.calendar-day.booked {
    background: #fee2e2;
    border-color: #fecaca;
    opacity: 0.7;
    cursor: not-allowed;
}

.calendar-day.blocked {
    background: #f3f4f6;
    border-color: #d1d5db;
    opacity: 0.6;
    cursor: not-allowed;
}

.calendar-day.past {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Selected States */
.calendar-day.selected-start,
.calendar-day.selected-end {
    background: #2563eb !important;
    color: white;
    font-weight: 600;
    border-color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transform: scale(1.05);
}

.calendar-day.in-range {
    background: rgba(37, 99, 235, 0.15) !important;
    border-color: rgba(37, 99, 235, 0.3);
}

.calendar-day.custom-price {
    border: 2px solid #3b82f6;
    background: #dbeafe;
}

/* Day Content */
.day-number {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    line-height: 1;
}

.day-price {
    font-size: 0.625rem;
    color: #6b7280;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* State-specific Colors */
.calendar-day.available .day-number {
    color: #166534;
    font-weight: 600;
}

.calendar-day.available .day-price {
    color: #059669;
    font-weight: 600;
}

.calendar-day.booked .day-number {
    color: #991b1b;
}

.calendar-day.blocked .day-number {
    color: #6b7280;
}

.calendar-day.selected-start .day-number,
.calendar-day.selected-end .day-number,
.calendar-day.selected-start .day-price,
.calendar-day.selected-end .day-price {
    color: white !important;
}

.calendar-day.in-range .day-number {
    color: #1d4ed8;
    font-weight: 600;
}

.calendar-day.in-range .day-price {
    color: #2563eb;
    font-weight: 500;
}

.calendar-day.custom-price .day-price {
    color: #1d4ed8;
    font-weight: 600;
}

/* ================================
   Footer Section
   ================================ */
.picker-footer {
    border-top: 1px solid #e5e7eb;
    padding: 1rem;
    background: #f8f9fa;
}

.selection-info {
    text-align: center;
    font-size: 0.875rem;
    color: #4b5563;
    margin-bottom: 1rem;
    min-height: 1.5rem;
    word-wrap: break-word;
    line-height: 1.4;
}

.picker-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ================================
   Legend Section
   ================================ */
.picker-legend {
    padding: 0.75rem 1rem;
    background: #f1f5f9;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    border-radius: 0 0 12px 12px;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    white-space: nowrap;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    flex-shrink: 0;
}

.legend-color.available {
    background: #dcfce7;
    border-color: #bbf7d0;
}

.legend-color.booked {
    background: #fee2e2;
    border-color: #fecaca;
}

.legend-color.blocked {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.legend-color.selected {
    background: #2563eb;
    border-color: #1d4ed8;
}

/* ================================
   Loading and Error States
   ================================ */
.picker-loading,
.picker-error {
    padding: 1rem;
    text-align: center;
}

.picker-loading .spinner-border {
    width: 2rem;
    height: 2rem;
}

.picker-error .alert {
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.picker-error .retry-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* ================================
   Animations
   ================================ */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================
   Modal Integration
   ================================ */
.modal-open .picker-popup {
    z-index: 1070 !important;
}


.form-group,
.mb-3 {
    position: relative;
    z-index: 1;
}


/* Card container fixes */
.card {
    position: relative;
    z-index: 1;
    overflow: visible; /* Important for popup visibility */
}

.card:has(.picker-popup[style*="block"]) {
    z-index: 1061;
    overflow: visible;
}


/* ================================
   Responsive Styles
   ================================ */

@media (max-width: 768px) {
    .picker-popup {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        width: 95vw !important;
        max-width: 380px !important;
        max-height: 85vh !important;
        margin: 0 !important;
        z-index: 9999 !important;
    }
}

@media (max-width: 576px) {
    .picker-popup {
        min-width: 320px;
        max-width: 95vw;
    }
    
    .calendar-day {
        min-height: 40px;
        font-size: 0.75rem;
    }
    
    .day-price {
        font-size: 0.5rem;
    }
    
    .picker-legend {
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .legend-item {
        font-size: 0.625rem;
    }
    
    .legend-color {
        width: 12px;
        height: 12px;
    }
    
    .month-year-display {
        font-size: 1rem;
        min-width: 120px;
    }
    
    .picker-header,
    .calendar-grid,
    .picker-footer {
        padding: 0.75rem;
    }
}

@media (max-width: 400px) {
    .picker-popup {
        min-width: 300px;
    }
    
    .calendar-day {
        min-height: 36px;
    }
    
    .day-price {
        display: none;
    }
    
    .weekday {
        font-size: 0.65rem;
        padding: 0.25rem 0;
    }
}

/* ================================
   Dark Mode Support
   ================================ */
@media (prefers-color-scheme: dark) {
    .picker-popup {
        background: #1f2937;
        border-color: #374151;
    }
    
    .picker-header,
    .picker-footer,
    .picker-legend {
        background: #111827;
        border-color: #374151;
    }
    
    .month-year-display {
        color: #f9fafb;
    }
    
    .calendar-day {
        background: #374151;
        border-color: #4b5563;
    }
    
    .day-number {
        color: #e5e7eb;
    }
    
    .day-price {
        color: #9ca3af;
    }
    
    .selection-info,
    .legend-item {
        color: #d1d5db;
    }
    
    .weekday {
        background: #374151;
        color: #9ca3af;
    }
}

/* ================================
   Accessibility - High Contrast
   ================================ */
@media (prefers-contrast: high) {
    .calendar-day,
    .picker-popup {
        border-width: 2px;
    }
    
    .calendar-day.selected-start,
    .calendar-day.selected-end {
        border-width: 3px;
    }
}
/* ======== Add this ======== */
.picker-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1059;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.picker-backdrop.fade-in {
  opacity: 1;
  transition: opacity 0.3s ease;
}
.picker-backdrop.active {
  /* only intercept clicks when active */
  pointer-events: auto;
}
/* ======== End addition ======== */
