/**
 * Jahaz Skeleton Loading System
 *
 * Per JAHAZ_DESIGN_PRINCIPLES.md:
 * "Loading States = Anticipation, Not Waiting"
 * "Never show a boring spinner. Instead, use travel-themed animations."
 *
 * Skeleton loading creates anticipation by showing the shape of content
 * before it loads, making the wait feel shorter and more engaging.
 */

/* ==========================================================================
   CSS Variables for Skeleton System
   ========================================================================== */

:root {
    --skeleton-base: #f3f4f6;
    --skeleton-highlight: #e5e7eb;
    --skeleton-shine: #f9fafb;
    --skeleton-duration: 1.5s;
    --skeleton-radius-sm: 0.375rem;
    --skeleton-radius-md: 0.75rem;
    --skeleton-radius-lg: 1rem;
    --skeleton-radius-xl: 1.5rem;
    --skeleton-radius-full: 9999px;
}

/* ==========================================================================
   Base Skeleton Styles
   ========================================================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-highlight) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer var(--skeleton-duration) ease-in-out infinite;
    border-radius: var(--skeleton-radius-md);
    color: transparent !important;
}

/* Shimmer animation */
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Subtle pulse alternative for simpler skeletons */
.skeleton-pulse {
    background: var(--skeleton-base);
    animation: skeleton-pulse-anim 2s ease-in-out infinite;
    border-radius: var(--skeleton-radius-md);
}

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

/* ==========================================================================
   Skeleton Text Elements
   ========================================================================== */

.skeleton-text {
    height: 1em;
    width: 100%;
    margin-bottom: 0.5em;
}

.skeleton-text-sm {
    height: 0.75em;
    margin-bottom: 0.375em;
}

.skeleton-text-lg {
    height: 1.25em;
    margin-bottom: 0.625em;
}

.skeleton-title {
    height: 1.75em;
    width: 60%;
    margin-bottom: 0.75em;
}

.skeleton-subtitle {
    height: 1.25em;
    width: 40%;
    margin-bottom: 0.5em;
}

/* Variable width text lines for realistic look */
.skeleton-text-75 { width: 75%; }
.skeleton-text-60 { width: 60%; }
.skeleton-text-50 { width: 50%; }
.skeleton-text-40 { width: 40%; }
.skeleton-text-30 { width: 30%; }

/* ==========================================================================
   Skeleton Image/Media Elements
   ========================================================================== */

.skeleton-image {
    aspect-ratio: 16/9;
    width: 100%;
    border-radius: var(--skeleton-radius-lg);
}

.skeleton-image-square {
    aspect-ratio: 1;
    width: 100%;
    border-radius: var(--skeleton-radius-lg);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--skeleton-radius-full);
    flex-shrink: 0;
}

.skeleton-avatar-lg {
    width: 56px;
    height: 56px;
}

.skeleton-avatar-sm {
    width: 32px;
    height: 32px;
}

.skeleton-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--skeleton-radius-sm);
}

/* ==========================================================================
   Skeleton Badge Elements
   ========================================================================== */

.skeleton-badge {
    display: inline-block;
    height: 1.5em;
    width: 4em;
    border-radius: var(--skeleton-radius-full);
}

.skeleton-badge-lg {
    height: 2em;
    width: 6em;
}

.skeleton-price-badge {
    height: 2em;
    width: 5em;
    border-radius: var(--skeleton-radius-md);
}

/* ==========================================================================
   Skeleton Button Elements
   ========================================================================== */

.skeleton-button {
    height: 2.5em;
    width: 8em;
    border-radius: var(--skeleton-radius-md);
}

.skeleton-button-full {
    height: 3em;
    width: 100%;
    border-radius: var(--skeleton-radius-lg);
}

/* ==========================================================================
   Hotel Card Skeleton
   ========================================================================== */

.skeleton-hotel-card {
    background: white;
    border-radius: var(--skeleton-radius-xl);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.skeleton-hotel-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.skeleton-hotel-image {
    height: 200px;
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-highlight) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer var(--skeleton-duration) ease-in-out infinite;
    position: relative;
}

/* Decorative hotel icon overlay */
.skeleton-hotel-image::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.skeleton-hotel-content {
    padding: 1.25rem;
}

.skeleton-hotel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.skeleton-hotel-info {
    flex: 1;
}

.skeleton-hotel-name {
    height: 1.5rem;
    width: 70%;
    margin-bottom: 0.5rem;
}

.skeleton-hotel-location {
    height: 1rem;
    width: 50%;
}

.skeleton-hotel-rating {
    width: 60px;
    height: 1.5rem;
    border-radius: var(--skeleton-radius-sm);
}

.skeleton-hotel-amenities {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.skeleton-amenity {
    height: 1.25rem;
    width: 4rem;
    border-radius: var(--skeleton-radius-full);
}

.skeleton-hotel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #f3f4f6;
}

.skeleton-hotel-price {
    height: 2rem;
    width: 6rem;
}

.skeleton-hotel-button {
    height: 2.5rem;
    width: 7rem;
    border-radius: var(--skeleton-radius-lg);
}

/* ==========================================================================
   Flight Card Skeleton
   ========================================================================== */

.skeleton-flight-card {
    background: white;
    border-radius: var(--skeleton-radius-xl);
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.skeleton-flight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.skeleton-flight-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.skeleton-airline-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--skeleton-radius-md);
}

.skeleton-flight-info {
    flex: 1;
}

.skeleton-airline-name {
    height: 1.25rem;
    width: 8rem;
    margin-bottom: 0.25rem;
}

.skeleton-flight-number {
    height: 0.875rem;
    width: 5rem;
}

.skeleton-flight-route {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.skeleton-flight-endpoint {
    text-align: center;
}

.skeleton-flight-time {
    height: 2rem;
    width: 4rem;
    margin: 0 auto 0.25rem;
}

.skeleton-flight-code {
    height: 1rem;
    width: 3rem;
    margin: 0 auto;
}

.skeleton-flight-path {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.skeleton-flight-duration {
    height: 1rem;
    width: 3.5rem;
}

.skeleton-flight-line {
    height: 2px;
    width: 100%;
    position: relative;
}

.skeleton-flight-stops {
    height: 0.875rem;
    width: 4rem;
}

.skeleton-flight-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #f3f4f6;
}

.skeleton-flight-price {
    height: 2rem;
    width: 5rem;
}

.skeleton-flight-button {
    height: 2.5rem;
    width: 6rem;
    border-radius: var(--skeleton-radius-lg);
}

/* ==========================================================================
   Place Card Skeleton (Explore Page)
   ========================================================================== */

.skeleton-place-card {
    display: flex;
    background: white;
    border-radius: var(--skeleton-radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 0.75rem;
}

.skeleton-place-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.skeleton-place-thumb {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-highlight) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer var(--skeleton-duration) ease-in-out infinite;
}

.skeleton-place-content {
    flex: 1;
    padding: 0.875rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.skeleton-place-name {
    height: 1.125rem;
    width: 75%;
    margin-bottom: 0.375rem;
}

.skeleton-place-oneliner {
    height: 0.875rem;
    width: 90%;
}

.skeleton-place-badges {
    display: flex;
    gap: 0.375rem;
    margin-top: auto;
}

.skeleton-place-badge {
    height: 1.25rem;
    width: 3rem;
    border-radius: var(--skeleton-radius-full);
}

/* ==========================================================================
   Loading Message Component
   ========================================================================== */

.skeleton-loading-message {
    text-align: center;
    padding: 1rem;
    margin-bottom: 1rem;
}

.skeleton-loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: #6366f1;
    opacity: 0;
    animation: message-fade 0.5s ease forwards;
}

.skeleton-loading-subtext {
    font-size: 0.875rem;
    color: #9ca3af;
    margin-top: 0.25rem;
    opacity: 0;
    animation: message-fade 0.5s ease 0.2s forwards;
}

@keyframes message-fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Message rotation animation */
.skeleton-loading-text.switching {
    animation: message-switch 0.3s ease forwards;
}

@keyframes message-switch {
    0% { opacity: 1; transform: translateY(0); }
    50% { opacity: 0; transform: translateY(-8px); }
    51% { transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Grid Layouts for Skeleton Cards
   ========================================================================== */

.skeleton-grid-hotels {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
}

@media (min-width: 768px) {
    .skeleton-grid-hotels {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .skeleton-grid-hotels {
        grid-template-columns: repeat(1, 1fr);
    }
}

.skeleton-grid-flights {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-list-places {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ==========================================================================
   Animation Staggering for Multiple Skeletons
   ========================================================================== */

.skeleton-stagger > *:nth-child(1) { animation-delay: 0s; }
.skeleton-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.skeleton-stagger > *:nth-child(3) { animation-delay: 0.2s; }
.skeleton-stagger > *:nth-child(4) { animation-delay: 0.3s; }
.skeleton-stagger > *:nth-child(5) { animation-delay: 0.4s; }
.skeleton-stagger > *:nth-child(6) { animation-delay: 0.5s; }
.skeleton-stagger > *:nth-child(7) { animation-delay: 0.6s; }
.skeleton-stagger > *:nth-child(8) { animation-delay: 0.7s; }

/* ==========================================================================
   Transition from Skeleton to Content
   ========================================================================== */

.skeleton-container {
    position: relative;
}

.skeleton-container.loading .skeleton-content {
    opacity: 0;
    pointer-events: none;
}

.skeleton-container.loading .skeleton-placeholder {
    opacity: 1;
    pointer-events: auto;
}

.skeleton-container .skeleton-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.skeleton-container .skeleton-content {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Fade in animation when content loads */
.skeleton-fade-in {
    animation: skeleton-content-appear 0.4s ease forwards;
}

@keyframes skeleton-content-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */

@media (max-width: 640px) {
    .skeleton-hotel-image {
        height: 160px;
    }

    .skeleton-hotel-content {
        padding: 1rem;
    }

    .skeleton-flight-card {
        padding: 1rem;
    }

    .skeleton-flight-route {
        flex-direction: column;
        gap: 0.75rem;
    }

    .skeleton-flight-path {
        width: 100%;
    }

    .skeleton-place-thumb {
        width: 80px;
        height: 80px;
    }

    .skeleton-place-content {
        padding: 0.75rem;
    }
}
