/**
 * ENTROTERRA - Premium Loading States & Animations
 * Ultra-smooth loading experiences with glassmorphism
 */

:root {
    --primary-green: #6B9F5C;
    --dark-green: #5a8a4c;
    --gold: #D4AF37;
    --skeleton-base: #f0f0f0;
    --skeleton-shimmer: #e0e0e0;
}

/* ==========================================
   SKELETON LOADERS - Property Cards
   ========================================== */

.skeleton-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    animation: pulse 2s ease-in-out infinite;
}

.skeleton-image {
    width: 100%;
    height: 250px;
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-shimmer) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 1rem;
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-shimmer) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.skeleton-text.title {
    height: 1.5rem;
    width: 70%;
}

.skeleton-text.description {
    height: 1rem;
    width: 90%;
}

.skeleton-text.price {
    height: 1.25rem;
    width: 40%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* ==========================================
   BUTTON LOADING STATES
   ========================================== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-loading .btn-text {
    opacity: 0;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================
   CALENDAR DATE LOADING
   ========================================== */

.calendar-loading .day {
    animation: pulse-day 1.5s ease-in-out infinite;
}

.calendar-loading .day:nth-child(2n) {
    animation-delay: 0.1s;
}

.calendar-loading .day:nth-child(3n) {
    animation-delay: 0.2s;
}

@keyframes pulse-day {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ==========================================
   SMOOTH PAGE TRANSITIONS
   ========================================== */

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.slide-up {
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scale-in {
    animation: scaleIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================
   STAGGERED ANIMATIONS (for grids)
   ========================================== */

.stagger-item {
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }

/* ==========================================
   LOADING SPINNER (inline)
   ========================================== */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(107, 159, 92, 0.2);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.spinner-gold {
    border-color: rgba(212, 175, 55, 0.2);
    border-top-color: var(--gold);
}

/* ==========================================
   LOADING OVERLAY (full screen)
   ========================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(250, 248, 243, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease-in;
}

.loading-overlay .spinner {
    width: 50px;
    height: 50px;
    border-width: 5px;
    margin-bottom: 1rem;
}

.loading-overlay p {
    font-family: 'Montserrat', sans-serif;
    color: var(--primary-green);
    font-weight: 600;
    font-size: 1.125rem;
}

/* ==========================================
   PROGRESS BAR
   ========================================== */

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(107, 159, 92, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green), var(--dark-green));
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

/* ==========================================
   RIPPLE EFFECT (for buttons)
   ========================================== */

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ==========================================
   TOAST NOTIFICATION ANIMATIONS
   ========================================== */

.toast-enter {
    animation: toastSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-exit {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-100%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-100%) scale(0.9);
    }
}

/* ==========================================
   HOVER LIFT ANIMATION (enhanced)
   ========================================== */

.hover-lift {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 48px rgba(107, 159, 92, 0.2);
}

/* ==========================================
   GLOW EFFECT (for focused elements)
   ========================================== */

.glow-focus:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(107, 159, 92, 0.2),
                0 4px 16px rgba(107, 159, 92, 0.3);
    border-color: var(--primary-green);
}

.glow-gold:focus {
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2),
                0 4px 16px rgba(212, 175, 55, 0.3);
    border-color: var(--gold);
}

/* ==========================================
   LOADING DOTS (three dots animation)
   ========================================== */

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* ==========================================
   SKELETON CALENDAR
   ========================================== */

.skeleton-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    padding: 1rem;
}

.skeleton-calendar-day {
    aspect-ratio: 1;
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-shimmer) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

.skeleton-calendar-day:nth-child(n) {
    animation-delay: calc(0.05s * var(--item));
}

/* ==========================================
   SUCCESS CHECKMARK ANIMATION
   ========================================== */

.success-checkmark {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: inline-block;
    stroke-width: 3;
    stroke: var(--primary-green);
    stroke-miterlimit: 10;
    box-shadow: inset 0px 0px 0px var(--primary-green);
    animation: fill 0.4s ease-in-out 0.4s forwards,
               scale 0.3s ease-in-out 0.9s both;
}

.success-checkmark circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke-miterlimit: 10;
    stroke: var(--primary-green);
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-checkmark path {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes fill {
    100% {
        box-shadow: inset 0px 0px 0px 30px var(--primary-green);
    }
}

/* ==========================================
   SMOOTH SCROLL BEHAVIOR
   ========================================== */

html {
    scroll-behavior: smooth;
}

/* Customize scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-green), var(--dark-green));
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--dark-green);
}
