/**
 * BIOMAG SKELETON LIBRARY
 * =======================
 * 
 * O librărie CSS ușoară pentru crearea de animații skeleton loading
 * Compatibilă cu Bootstrap 5.x și Tailwind CSS
 * 
 * Version: 1.0.0
 * Author: Biomag Dev Team
 */

/* ============================================
   SKELETON BASE CLASSES
   ============================================ */

.biomag-skeleton {
    background: linear-gradient(90deg, 
        rgba(240, 240, 240, 0.8) 25%, 
        rgba(224, 224, 224, 0.8) 50%, 
        rgba(240, 240, 240, 0.8) 75%
    );
    background-size: 200% 100%;
    animation: biomag-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

/* Dark theme skeleton */
.biomag-skeleton-dark {
    background: linear-gradient(90deg, 
        rgba(50, 50, 50, 0.8) 25%, 
        rgba(70, 70, 70, 0.8) 50%, 
        rgba(50, 50, 50, 0.8) 75%
    );
}

/* Subtle skeleton (lighter) */
.biomag-skeleton-subtle {
    background: linear-gradient(90deg, 
        rgba(248, 248, 248, 0.6) 25%, 
        rgba(235, 235, 235, 0.6) 50%, 
        rgba(248, 248, 248, 0.6) 75%
    );
}

/* ============================================
   SKELETON SHAPES & SIZES
   ============================================ */

/* Image skeletons */
.biomag-skeleton-img {
    width: 100%;
    height: 200px;
}

.biomag-skeleton-img-sm { height: 80px; }
.biomag-skeleton-img-md { height: 140px; }
.biomag-skeleton-img-lg { height: 200px; }
.biomag-skeleton-img-xl { height: 260px; }

.biomag-skeleton-img-square {
    width: 100%;
    aspect-ratio: 1;
}

.biomag-skeleton-img-wide {
    width: 100%;
    aspect-ratio: 16/9;
}

/* Avatar skeletons */
.biomag-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.biomag-skeleton-avatar-sm { width: 32px; height: 32px; }
.biomag-skeleton-avatar-md { width: 48px; height: 48px; }
.biomag-skeleton-avatar-lg { width: 64px; height: 64px; }

/* Text skeletons */
.biomag-skeleton-text {
    height: 16px;
    width: 100%;
}

.biomag-skeleton-text-sm { height: 12px; }
.biomag-skeleton-text-md { height: 14px; }
.biomag-skeleton-text-lg { height: 18px; }
.biomag-skeleton-text-xl { height: 22px; }

/* Text width variants */
.biomag-skeleton-text-xs { width: 25%; }
.biomag-skeleton-text-short { width: 50%; }
.biomag-skeleton-text-medium { width: 75%; }
.biomag-skeleton-text-long { width: 100%; }

/* Title skeletons (multiple lines) */
.biomag-skeleton-title {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.biomag-skeleton-title .biomag-skeleton-text:last-child {
    width: 75%;
}

/* Button skeletons */
.biomag-skeleton-btn {
    height: 40px;
    width: 120px;
    border-radius: 6px;
}

.biomag-skeleton-btn-sm { height: 32px; width: 100px; }
.biomag-skeleton-btn-lg { height: 48px; width: 140px; }
.biomag-skeleton-btn-block { width: 100%; }

/* Badge skeletons */
.biomag-skeleton-badge {
    width: 60px;
    height: 20px;
    border-radius: 12px;
}

/* Price skeletons */
.biomag-skeleton-price {
    height: 20px;
    width: 80px;
    font-weight: bold;
}

.biomag-skeleton-price-old {
    height: 16px;
    width: 60px;
    opacity: 0.7;
}

/* ============================================
   SKELETON ANIMATIONS
   ============================================ */

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

/* Slow animation variant */
.biomag-skeleton-slow {
    animation-duration: 2.5s;
}

/* Fast animation variant */
.biomag-skeleton-fast {
    animation-duration: 1s;
}

/* Pulse animation */
.biomag-skeleton-pulse {
    animation: biomag-skeleton-pulse 1.5s infinite;
}

@keyframes biomag-skeleton-pulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 0.4;
    }
}

/* ============================================
   SKELETON CONTAINERS
   ============================================ */

/* Product card skeleton */
.biomag-skeleton-product {
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 300px;
}

.biomag-skeleton-product-compact {
    min-height: 200px;
    padding: 0.75rem;
    gap: 0.75rem;
}

/* Article/Blog skeleton */
.biomag-skeleton-article {
    padding: 1.5rem;
    border-radius: 8px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* List item skeleton */
.biomag-skeleton-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

/* Table row skeleton */
.biomag-skeleton-table-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Spacing utilities for skeleton groups */
.biomag-skeleton-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.biomag-skeleton-group-sm { gap: 0.25rem; }
.biomag-skeleton-group-md { gap: 0.75rem; }
.biomag-skeleton-group-lg { gap: 1rem; }

/* Flexbox utilities for skeleton layouts */
.biomag-skeleton-flex {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.biomag-skeleton-flex-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Show/Hide utilities for loading states */
.biomag-skeleton-loading .biomag-skeleton-content {
    display: block;
}

.biomag-skeleton-loading .biomag-real-content {
    display: none !important;
}

.biomag-skeleton-loaded .biomag-skeleton-content {
    display: none !important;
}

.biomag-skeleton-loaded .biomag-real-content {
    display: block;
}

/* ============================================
   RESPONSIVE VARIATIONS
   ============================================ */

@media (max-width: 576px) {
    .biomag-skeleton-img { height: 160px; }
    .biomag-skeleton-product { min-height: 320px; padding: 0.75rem; }
    .biomag-skeleton-btn { width: 100%; }
}

@media (max-width: 768px) {
    .biomag-skeleton-img-lg { height: 200px; }
    .biomag-skeleton-product { min-height: 360px; }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .biomag-skeleton,
    .biomag-skeleton-content {
        display: none !important;
    }
}

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

/* Respect user's preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .biomag-skeleton {
        animation: none;
        background: #f0f0f0;
    }
    
    .biomag-skeleton-pulse {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .biomag-skeleton {
        background: #e0e0e0;
        border: 1px solid #999;
    }
}

/* Screen reader support */
.biomag-skeleton::before {
    content: 'Loading content...';
    position: absolute;
    left: -9999px;
    top: -9999px;
}

/* ============================================
   COMPONENT INTEGRATION HELPERS
   ============================================ */

/* Bootstrap integration */
.biomag-skeleton.card-img-top {
    border-radius: calc(0.375rem - 1px) calc(0.375rem - 1px) 0 0;
}

.biomag-skeleton.card-text {
    margin-bottom: 1rem;
}

/* Custom component overrides */
.biomag-skeleton.biomag-product-card {
    min-height: inherit;
}

/* Loading state transitions */
.biomag-skeleton-container {
    transition: opacity 0.3s ease-in-out;
}

.biomag-skeleton-container.loading {
    opacity: 1;
}

.biomag-skeleton-container.loaded {
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   THEME VARIABLES (CSS Custom Properties)
   ============================================ */

:root {
    --biomag-skeleton-primary: rgba(240, 240, 240, 0.8);
    --biomag-skeleton-secondary: rgba(224, 224, 224, 0.8);
    --biomag-skeleton-border-radius: 4px;
    --biomag-skeleton-animation-duration: 1.5s;
    --biomag-skeleton-gap: 0.5rem;
}

/* Dark mode theme variables */
[data-theme="dark"] {
    --biomag-skeleton-primary: rgba(50, 50, 50, 0.8);
    --biomag-skeleton-secondary: rgba(70, 70, 70, 0.8);
}

/* Use CSS variables for customizable skeleton */
.biomag-skeleton-custom {
    background: linear-gradient(90deg, 
        var(--biomag-skeleton-primary) 25%, 
        var(--biomag-skeleton-secondary) 50%, 
        var(--biomag-skeleton-primary) 75%
    );
    background-size: 200% 100%;
    animation: biomag-skeleton-shimmer var(--biomag-skeleton-animation-duration) infinite;
    border-radius: var(--biomag-skeleton-border-radius);
    gap: var(--biomag-skeleton-gap);
}