/* =============================================================================
   SMART BOOKING CALENDAR STYLES
   Modern, accessible calendar with glass morphism design and modal support
   ============================================================================= */

/* Modal overlay for calendar */
.smart-calendar-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: var(--z-calendar, 3000);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.smart-calendar-modal.active {
    opacity: 1;
    visibility: visible;
}

.smart-calendar-modal-content {
    position: relative;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.smart-calendar-modal.active .smart-calendar-modal-content {
    transform: scale(1) translateY(0);
}

.smart-calendar-container {
    max-width: 100%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    position: relative;
}

/* Close button for modal */
.calendar-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #666;
    font-size: 18px;
    line-height: 1;
}

.calendar-close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #333;
}

/* =============================================================================
   CALENDAR HEADER
   ============================================================================= */

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.calendar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
    text-align: center;
    flex: 1;
}

.calendar-nav-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #667eea;
    font-size: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.calendar-nav-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.calendar-nav-btn:active {
    transform: scale(0.95);
}

.calendar-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* =============================================================================
   WEEKDAYS HEADER
   ============================================================================= */

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 4px;
}

.calendar-weekday {
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: #718096;
    padding: 12px 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =============================================================================
   CALENDAR GRID
   ============================================================================= */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    cursor: default;
    min-height: 48px;
}

/* Empty calendar cells for alignment */
.calendar-day.empty {
    visibility: hidden;
    pointer-events: none;
}

/* Past dates */
.calendar-day.past {
    color: #a0aec0;
    background: rgba(160, 174, 192, 0.05);
    opacity: 0.6;
    cursor: not-allowed;
}

/* 48-hour minimum rule - dates too close */
.calendar-day.too-soon {
    color: #f56565;
    background: rgba(245, 101, 101, 0.05);
    cursor: not-allowed;
    position: relative;
}

.calendar-day.too-soon::after {
    content: '⏱';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    opacity: 0.7;
}

.calendar-day.too-soon:hover {
    background: rgba(245, 101, 101, 0.1);
}

/* Tooltip for 48-hour rule */
.calendar-day.too-soon[title]:hover::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

/* Unavailable dates */
.calendar-day.unavailable {
    color: #cbd5e0;
    background: rgba(203, 213, 224, 0.05);
    cursor: not-allowed;
    position: relative;
}

.calendar-day.unavailable::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #e2e8f0;
    transform: translate(-50%, -50%) rotate(45deg);
    opacity: 0.5;
}

/* Available dates */
.calendar-day.available {
    color: #2d3748;
    background: rgba(102, 126, 234, 0.08);
    border-color: rgba(102, 126, 234, 0.2);
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.calendar-day.available:hover {
    background: rgba(102, 126, 234, 0.15);
    transform: scale(1.08);
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
}

.calendar-day.available:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    background: rgba(102, 126, 234, 0.15);
}

/* Today's date */
.calendar-day.today {
    background: rgba(72, 187, 120, 0.1) !important;
    border-color: #48bb78 !important;
    color: #2f855a !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.2);
}

.calendar-day.today.available:hover {
    background: rgba(72, 187, 120, 0.2) !important;
    box-shadow: 0 4px 16px rgba(72, 187, 120, 0.3);
}

/* Selected date */
.calendar-day.selected {
    background: #667eea !important;
    color: white !important;
    border-color: #667eea !important;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    z-index: 10;
}

.calendar-day.selected .slots-indicator {
    color: rgba(255, 255, 255, 0.9);
}

/* Day number styling */
.day-number {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

/* Slots indicator */
.slots-indicator {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 2px;
    font-weight: 500;
    line-height: 1;
    color: inherit;
}

/* =============================================================================
   CALENDAR LEGEND
   ============================================================================= */

.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #718096;
    font-weight: 500;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-color.available {
    background: rgba(102, 126, 234, 0.3);
    border: 1px solid rgba(102, 126, 234, 0.5);
}

.legend-color.unavailable {
    background: rgba(203, 213, 224, 0.3);
    border: 1px solid rgba(203, 213, 224, 0.5);
}

.legend-color.today {
    background: rgba(72, 187, 120, 0.3);
    border: 1px solid rgba(72, 187, 120, 0.5);
}

/* =============================================================================
   LOADING AND ERROR STATES
   ============================================================================= */

.calendar-loading,
.calendar-error {
    text-align: center;
    padding: 60px 20px;
    color: #718096;
}

.calendar-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.calendar-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.calendar-error i {
    font-size: 2rem;
    color: #f56565;
    margin-bottom: 8px;
}

.retry-button {
    margin-top: 12px;
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.retry-button:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* =============================================================================
   TIME SLOTS STYLES (for time selection after date)
   ============================================================================= */

.time-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.time-slot {
    padding: 12px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.time-slot:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
    transform: translateY(-2px);
}

.time-slot.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.time-slot .time {
    font-weight: 600;
    font-size: 0.9rem;
}

.time-slot .capacity {
    font-size: 0.75rem;
    opacity: 0.8;
}

.time-slot.selected .capacity {
    opacity: 0.9;
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
    .smart-calendar-container {
        padding: 16px;
        border-radius: 12px;
    }
    
    .calendar-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }
    
    .calendar-title {
        font-size: 1.1rem;
    }
    
    .calendar-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .calendar-day {
        font-size: 0.8rem;
        min-height: 44px;
        border-radius: 8px;
    }
    
    .day-number {
        font-size: 0.9rem;
    }
    
    .slots-indicator {
        font-size: 0.65rem;
    }
    
    .calendar-legend {
        gap: 16px;
    }
    
    .legend-item {
        font-size: 0.75rem;
    }
    
    .time-slots-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .time-slot {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .smart-calendar-container {
        padding: 12px;
        margin: 0 -8px;
    }
    
    .calendar-grid {
        gap: 4px;
    }
    
    .calendar-day {
        min-height: 40px;
        border-radius: 6px;
    }
    
    .day-number {
        font-size: 0.85rem;
    }
    
    .calendar-legend {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
    
    .time-slots-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 6px;
    }
}

/* =============================================================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================================================= */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .smart-calendar-container {
        border: 2px solid #000;
        background: white;
    }
    
    .calendar-day.available {
        border: 2px solid #0066cc;
        background: #e6f3ff;
        color: #000;
    }
    
    .calendar-day.selected {
        background: #0066cc !important;
        color: white !important;
        border: 2px solid #000 !important;
    }
    
    .calendar-nav-btn {
        border: 2px solid #0066cc;
        background: #e6f3ff;
        color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .calendar-day,
    .calendar-nav-btn,
    .time-slot,
    .loading-spinner {
        transition: none;
        animation: none;
    }
    
    .calendar-day.available:hover,
    .calendar-day.selected {
        transform: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .smart-calendar-container {
        background: rgba(45, 55, 72, 0.8);
        border-color: rgba(255, 255, 255, 0.2);
        color: white;
    }
    
    .calendar-title {
        color: white;
    }
    
    .calendar-weekday {
        color: #a0aec0;
    }
    
    .calendar-day {
        background: rgba(255, 255, 255, 0.05);
        color: #e2e8f0;
    }
    
    .calendar-day.available {
        background: rgba(102, 126, 234, 0.2);
        color: white;
    }
    
    .calendar-day.unavailable {
        color: #718096;
        background: rgba(113, 128, 150, 0.1);
    }
    
    .legend-item {
        color: #a0aec0;
    }
    
    .time-slot {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }
}
