/**
 * Enhanced Skeleton Screens CSS
 * Professional loading states for PWA
 */

/* Base Skeleton Styles */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #f8f8f8 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.8s ease-in-out infinite;
    border-radius: 8px;
}

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

/* Dark theme skeleton */
.theme-dark .skeleton {
    background: linear-gradient(
        90deg,
        #2a2a2a 0%,
        #353535 20%,
        #2a2a2a 40%,
        #2a2a2a 100%
    );
    background-size: 400% 100%;
}

/* Skeleton Variants */
.skeleton-text {
    height: 14px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.skeleton-text.large {
    height: 18px;
}

.skeleton-text.small {
    height: 10px;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 16px;
    border-radius: 6px;
    width: 60%;
}

.skeleton-subtitle {
    height: 18px;
    margin-bottom: 12px;
    border-radius: 4px;
    width: 40%;
}

.skeleton-card {
    height: 200px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.skeleton-card.small {
    height: 120px;
}

.skeleton-card.large {
    height: 300px;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-circle.small {
    width: 32px;
    height: 32px;
}

.skeleton-circle.large {
    width: 80px;
    height: 80px;
}

.skeleton-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
}

/* Skeleton Wrapper */
.skeleton-wrapper {
    animation: skeleton-fade-in 0.2s ease-in;
}

@keyframes skeleton-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Page-Specific Skeletons */

/* Home Page Skeleton */
.skeleton-home {
    padding: 20px;
}

.skeleton-stories {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    margin-bottom: 24px;
    padding-bottom: 8px;
}

.skeleton-stories .skeleton-circle {
    flex-shrink: 0;
}

.skeleton-rewards-card {
    background: linear-gradient(135deg, #e0e0e0, #f0f0f0);
    height: 180px;
    border-radius: 16px;
    margin-bottom: 24px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.skeleton-rewards-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: skeleton-slide 2s infinite;
}

@keyframes skeleton-slide {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.skeleton-product-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    margin-bottom: 24px;
}

.skeleton-product-grid .skeleton-card {
    min-width: 180px;
    flex-shrink: 0;
}

.skeleton-menu-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.skeleton-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.theme-dark .skeleton-menu-item {
    background: #1a1a1a;
}

.skeleton-menu-item-content {
    flex: 1;
}

/* Product Detail Skeleton */
.skeleton-product-detail {
    padding: 20px;
}

.skeleton-product-image {
    height: 280px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.skeleton-product-info {
    margin-bottom: 24px;
}

.skeleton-product-description {
    margin-bottom: 16px;
}

.skeleton-product-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

.skeleton-product-actions .skeleton {
    height: 56px;
    flex: 1;
    border-radius: 12px;
}

/* Profile Skeleton */
.skeleton-profile {
    padding: 20px;
}

.skeleton-profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 32px;
}

.skeleton-profile-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-profile-item {
    height: 64px;
    border-radius: 12px;
}

/* Branches Skeleton */
.skeleton-branches {
    padding: 20px;
}

.skeleton-branch-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.theme-dark .skeleton-branch-card {
    background: #1a1a1a;
}

.skeleton-branch-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* Rewards Skeleton */
.skeleton-rewards {
    padding: 20px;
}

.skeleton-reward-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.theme-dark .skeleton-reward-card {
    background: #1a1a1a;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.theme-dark .loading-overlay {
    background: rgba(0, 0, 0, 0.95);
}

/* Loading Spinner */
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f0f0f0;
    border-top-color: #04764E;
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

@keyframes spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

.theme-dark .loading-spinner {
    border-color: #2a2a2a;
    border-top-color: #04764E;
}

/* Page Transition Effects */
.page-content {
    transition: opacity 0.2s ease;
}

.page-transitioning .page-content {
    opacity: 0.3;
    pointer-events: none;
}

/* Optimistic UI States */
.optimistic-loading {
    position: relative;
    pointer-events: none;
}

.optimistic-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    border-radius: inherit;
    z-index: 10;
}

.theme-dark .optimistic-loading::after {
    background: rgba(0, 0, 0, 0.7);
}

/* Skeleton Pulse (Alternative Animation) */
.skeleton-pulse {
    animation: skeleton-pulse-anim 1.5s ease-in-out infinite;
}

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

/* Responsive Adjustments */
@media (max-width: 576px) {
    .skeleton-product-grid {
        gap: 12px;
    }
    
    .skeleton-product-grid .skeleton-card {
        min-width: 160px;
    }
    
    .skeleton-menu-item {
        padding: 10px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .skeleton,
    .skeleton-shimmer,
    .skeleton-pulse,
    .skeleton-rewards-card::after,
    .loading-spinner {
        animation: none !important;
    }
    
    .skeleton {
        background: #f0f0f0;
    }
    
    .theme-dark .skeleton {
        background: #2a2a2a;
    }
}

/* Print Styles */
@media print {
    .skeleton,
    .skeleton-wrapper,
    .loading-overlay {
        display: none !important;
    }
}

/* Component-Specific Skeletons */

/* Story Bubble Skeleton */
.skeleton-story {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.skeleton-story .skeleton-circle {
    width: 60px;
    height: 60px;
}

.skeleton-story .skeleton-text {
    width: 60px;
    height: 10px;
}

/* Coffee Points Card Skeleton */
.skeleton-coffee-points {
    background: linear-gradient(135deg, #04764E, #03553a);
    height: 180px;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.skeleton-coffee-points::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.skeleton-coffee-points::after {
    content: '';
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 40px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

/* Tab Skeleton */
.skeleton-tabs {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.skeleton-tab {
    height: 40px;
    min-width: 100px;
    border-radius: 20px;
}

/* Button Skeleton */
.skeleton-button {
    height: 48px;
    border-radius: 12px;
}

.skeleton-button.full-width {
    width: 100%;
}

.skeleton-button.small {
    height: 36px;
    border-radius: 8px;
}

/* Input Field Skeleton */
.skeleton-input {
    height: 48px;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* Badge Skeleton */
.skeleton-badge {
    width: 60px;
    height: 24px;
    border-radius: 12px;
    display: inline-block;
}

/* Utility Classes */
.skeleton-mb-1 { margin-bottom: 8px; }
.skeleton-mb-2 { margin-bottom: 16px; }
.skeleton-mb-3 { margin-bottom: 24px; }
.skeleton-mb-4 { margin-bottom: 32px; }

.skeleton-mt-1 { margin-top: 8px; }
.skeleton-mt-2 { margin-top: 16px; }
.skeleton-mt-3 { margin-top: 24px; }
.skeleton-mt-4 { margin-top: 32px; }

.skeleton-w-25 { width: 25%; }
.skeleton-w-50 { width: 50%; }
.skeleton-w-75 { width: 75%; }
.skeleton-w-100 { width: 100%; }

/* Fade transitions */
.fade-enter {
    opacity: 0;
}

.fade-enter-active {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.fade-exit {
    opacity: 1;
}

.fade-exit-active {
    opacity: 0;
    transition: opacity 0.3s ease;
}