/**
 * GuideOnHoliday - AJAX Filter Styles
 * 
 * Styling for AJAX filter system including loading states,
 * animations, and transitions
 * 
 * @version 1.0.0
 */

/* ==========================================================================
   Loading States
   ========================================================================== */

/* Ensure containers have proper positioning for overlay */
#accommodationsContainer,
#restaurantsContainer,
#beachesContainer,
#activitiesContainer {
    position: relative;
    min-height: 200px;
}

.ajax-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.ajax-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.ajax-loading-overlay.visible {
    opacity: 1;
}

/* Spinner Animation */
.ajax-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #e5e7eb;
    border-top: 5px solid #3b82f6;
    border-right: 5px solid #60a5fa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite, spinnerScale 0.3s ease-out;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

/* Spinner scale animation on appear */
@keyframes spinnerScale {
    0% {
        transform: scale(0.5) rotate(0deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

/* Loading text */
.ajax-loading-text {
    margin-top: 1.5rem;
    color: #374151;
    font-size: 1.125rem;
    font-weight: 600;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Loading state for container */
.ajax-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    z-index: 99;
}

/* ==========================================================================
   Notifications
   ========================================================================== */

.ajax-notification {
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.ajax-notification.animate-slide-out {
    animation: slideOutRight 0.3s ease-in;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ==========================================================================
   Filter Form Enhancements
   ========================================================================== */

/* Smooth transitions for filter inputs */
.ajax-filter-form input,
.ajax-filter-form select,
.ajax-filter-form textarea {
    transition: all 0.3s ease;
}

.ajax-filter-form input:focus,
.ajax-filter-form select:focus,
.ajax-filter-form textarea:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* Active filter indicator */
.ajax-filter-form input:not(:placeholder-shown),
.ajax-filter-form select:not([value=""]) {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

/* Checkbox and Radio enhancements */
.ajax-filter-form input[type="checkbox"]:checked,
.ajax-filter-form input[type="radio"]:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* ==========================================================================
   Content Transitions
   ========================================================================== */

/* Fade in animation for newly loaded content */
#accommodationsContainer > *,
#restaurantsContainer > *,
#beachesContainer > *,
#activitiesContainer > * {
    animation: contentFadeIn 0.5s ease-out;
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for grid items */
#accommodationsContainer > *:nth-child(1),
#restaurantsContainer > *:nth-child(1),
#beachesContainer > *:nth-child(1),
#activitiesContainer > *:nth-child(1) {
    animation-delay: 0.05s;
}

#accommodationsContainer > *:nth-child(2),
#restaurantsContainer > *:nth-child(2),
#beachesContainer > *:nth-child(2),
#activitiesContainer > *:nth-child(2) {
    animation-delay: 0.1s;
}

#accommodationsContainer > *:nth-child(3),
#restaurantsContainer > *:nth-child(3),
#beachesContainer > *:nth-child(3),
#activitiesContainer > *:nth-child(3) {
    animation-delay: 0.15s;
}

#accommodationsContainer > *:nth-child(4),
#restaurantsContainer > *:nth-child(4),
#beachesContainer > *:nth-child(4),
#activitiesContainer > *:nth-child(4) {
    animation-delay: 0.2s;
}

#accommodationsContainer > *:nth-child(5),
#restaurantsContainer > *:nth-child(5),
#beachesContainer > *:nth-child(5),
#activitiesContainer > *:nth-child(5) {
    animation-delay: 0.25s;
}

#accommodationsContainer > *:nth-child(6),
#restaurantsContainer > *:nth-child(6),
#beachesContainer > *:nth-child(6),
#activitiesContainer > *:nth-child(6) {
    animation-delay: 0.3s;
}

/* ==========================================================================
   Pagination Enhancements
   ========================================================================== */

.pagination-container {
    transition: opacity 0.3s ease;
}

.ajax-loading .pagination-container {
    opacity: 0.5;
    pointer-events: none;
}

.pagination-link {
    transition: all 0.2s ease;
}

.pagination-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Results Info Animation
   ========================================================================== */

.results-info {
    transition: all 0.3s ease;
}

.ajax-loading .results-info {
    opacity: 0.5;
}

/* ==========================================================================
   Filter Badge Animations
   ========================================================================== */

.filter-badge {
    display: inline-flex;
    align-items: center;
    background-color: #3b82f6;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    margin: 0.25rem;
    animation: badgeFadeIn 0.3s ease-out;
    transition: all 0.2s ease;
}

.filter-badge:hover {
    background-color: #2563eb;
    transform: scale(1.05);
}

.filter-badge .remove-badge {
    margin-left: 0.5rem;
    cursor: pointer;
    font-weight: bold;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.filter-badge .remove-badge:hover {
    opacity: 1;
}

@keyframes badgeFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   Skeleton Loading (Optional Enhancement)
   ========================================================================== */

.skeleton-item {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 70%;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
}

.skeleton-image {
    height: 16rem;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
}

/* ==========================================================================
   Listing Controls (Per-Page Selector & Sort Dropdown)
   ========================================================================== */

/* Container for both dropdowns */
.perpageselect,
.sortingdropdown {
    display: inline-block;
}

/* Per-Page Selector Styling */
#perPageSelect {
    transition: all 0.3s ease;
}

#perPageSelect:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#perPageSelect:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Sort Dropdown Styling */
#sortSelect {
    transition: all 0.3s ease;
}

#sortSelect:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#sortSelect:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* ==========================================================================
   Mobile Optimizations
   ========================================================================== */

@media (max-width: 768px) {
    .ajax-notification {
        max-width: calc(100% - 2rem);
        right: 1rem;
        left: 1rem;
    }

    .ajax-spinner {
        width: 48px;
        height: 48px;
    }

    /* Disable stagger animation on mobile for better performance */
    #accommodationsContainer > *,
    #restaurantsContainer > *,
    #beachesContainer > *,
    #activitiesContainer > * {
        animation-delay: 0s !important;
    }
    
    /* Stack dropdowns on very small screens */
    @media (max-width: 640px) {
        .perpageselect,
        .sortingdropdown {
            display: block;
            margin-bottom: 0.5rem;
        }
        
        #perPageSelect,
        #sortSelect {
            width: 100%;
        }
    }
}

/* ==========================================================================
   Empty State Styling
   ========================================================================== */

.empty-state {
    padding: 4rem 2rem;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.empty-state i {
    font-size: 4rem;
    color: #d1d5db;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ==========================================================================
   Filter Clear Button Enhancement
   ========================================================================== */

.clear-filters-btn {
    transition: all 0.3s ease;
}

.clear-filters-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.clear-filters-btn:active {
    transform: scale(0.98);
}

/* ==========================================================================
   Loading Dots Animation (Alternative Loader)
   ========================================================================== */

.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background-color: #3b82f6;
    border-radius: 50%;
    animation: loadingDots 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loadingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ==========================================================================
   Smooth Scroll Behavior
   ========================================================================== */

html {
    scroll-behavior: smooth;
}

/* ==========================================================================
   Focus States for Accessibility
   ========================================================================== */

.ajax-filter-form *:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ==========================================================================
   Print Styles (Hide AJAX Elements)
   ========================================================================== */

@media print {
    .ajax-loading-overlay,
    .ajax-notification,
    .ajax-spinner {
        display: none !important;
    }
}

/* ==========================================================================
   Dark Mode Support (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .ajax-loading-overlay {
        background: rgba(31, 41, 55, 0.8);
    }

    .ajax-spinner {
        border-color: #374151;
        border-top-color: #60a5fa;
    }

    .skeleton-item {
        background: linear-gradient(
            90deg,
            #374151 25%,
            #4b5563 50%,
            #374151 75%
        );
    }
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

/* GPU Acceleration for animations */
.ajax-loading-overlay,
.ajax-notification,
.ajax-spinner {
    will-change: transform, opacity;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .ajax-loading-overlay,
    .ajax-notification,
    #accommodationsContainer > *,
    #restaurantsContainer > *,
    #beachesContainer > *,
    #activitiesContainer > * {
        animation: none !important;
    }
}

