/**
 * SKELETON LOADERS - PharmData Design System v3.0
 *
 * Placeholders visuais para estados de carregamento.
 * Mostra a estrutura esperada enquanto dados são carregados.
 *
 * USO:
 * - Adicione classe .skeleton ao container
 * - Use .skeleton-line, .skeleton-circle, .skeleton-badge para elementos
 * - Combine com classes de tamanho (w-*, h-*)
 */

/* ========================================
   CSS CUSTOM PROPERTIES
   ======================================== */

:root {
    /* Colors */
    --skeleton-base: var(--arctic-mist, #E9ECEF);
    --skeleton-highlight: var(--soft-arctic, #E5E8EB);

    /* Animation */
    --skeleton-duration: 1.5s;
    --skeleton-timing: ease-in-out;

    /* Sizing */
    --skeleton-radius: 4px;
    --skeleton-radius-lg: 8px;
    --skeleton-radius-full: 9999px;
}

/* Dark mode */
:root.dark-mode,
[data-theme="dark"] {
    --skeleton-base: var(--soft-arctic, #21262d);
    --skeleton-highlight: rgba(183, 228, 213, 0.08);
}

/* ========================================
   SHIMMER ANIMATION
   ======================================== */

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

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

/* ========================================
   BASE SKELETON STYLES
   ======================================== */

.skeleton,
[class*="skeleton-"] {
    pointer-events: none;
    user-select: none;
}

/* Shimmer effect (default) */
.skeleton-shimmer,
.skeleton-line,
.skeleton-circle,
.skeleton-badge,
.skeleton-avatar,
.skeleton-button,
.skeleton-input,
.skeleton-card,
.skeleton-drop {
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 0%,
        var(--skeleton-highlight) 20%,
        var(--skeleton-base) 40%,
        var(--skeleton-base) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer var(--skeleton-duration) var(--skeleton-timing) infinite;
}

/* Pulse effect (alternative) */
.skeleton-pulse {
    background: var(--skeleton-base);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ========================================
   SKELETON PRIMITIVES
   ======================================== */

/* Line - for text */
.skeleton-line {
    display: block;
    height: 1em;
    border-radius: var(--skeleton-radius);
    margin-bottom: 0.5em;
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

/* Circle - for avatars, icons */
.skeleton-circle {
    display: inline-block;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Rectangle - for images, cards */
.skeleton-rect {
    display: block;
    border-radius: var(--skeleton-radius-lg);
}

/* Badge - for drops/tags */
.skeleton-badge,
.skeleton-drop {
    display: inline-block;
    height: 1.5rem;
    min-width: 3rem;
    border-radius: var(--skeleton-radius-full);
}

/* ========================================
   SKELETON COMPONENTS
   ======================================== */

/* Avatar */
.skeleton-avatar {
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-avatar-sm {
    width: 2rem;
    height: 2rem;
}

.skeleton-avatar-md {
    width: 2.5rem;
    height: 2.5rem;
}

.skeleton-avatar-lg {
    width: 3.5rem;
    height: 3.5rem;
}

/* Button */
.skeleton-button {
    display: inline-block;
    height: 2.5rem;
    min-width: 6rem;
    border-radius: var(--skeleton-radius-lg);
}

.skeleton-button-sm {
    height: 2rem;
    min-width: 4rem;
}

.skeleton-button-lg {
    height: 3rem;
    min-width: 8rem;
}

/* Input */
.skeleton-input {
    display: block;
    width: 100%;
    height: 2.75rem;
    border-radius: var(--skeleton-radius-lg);
}

/* Card */
.skeleton-card {
    display: block;
    border-radius: var(--skeleton-radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--skeleton-base);
}

/* ========================================
   SIZE UTILITIES
   ======================================== */

/* Width */
.skeleton-w-xs { width: 2rem; }
.skeleton-w-sm { width: 4rem; }
.skeleton-w-md { width: 8rem; }
.skeleton-w-lg { width: 12rem; }
.skeleton-w-xl { width: 16rem; }
.skeleton-w-full { width: 100%; }
.skeleton-w-1\/2 { width: 50%; }
.skeleton-w-1\/3 { width: 33.333%; }
.skeleton-w-2\/3 { width: 66.666%; }
.skeleton-w-3\/4 { width: 75%; }
.skeleton-w-1\/4 { width: 25%; }

/* Height */
.skeleton-h-xs { height: 0.5rem; }
.skeleton-h-sm { height: 0.75rem; }
.skeleton-h-md { height: 1rem; }
.skeleton-h-lg { height: 1.5rem; }
.skeleton-h-xl { height: 2rem; }

/* ========================================
   PHARMDATA-SPECIFIC SKELETONS
   ======================================== */

/* Substance Card Skeleton */
.skeleton-substance-card {
    background: var(--cloud);
    border: 1px solid var(--skeleton-base);
    border-radius: var(--skeleton-radius-lg);
    padding: 1.25rem;
}

.skeleton-substance-card .skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 0.75rem;
}

.skeleton-substance-card .skeleton-subtitle {
    height: 1rem;
    width: 40%;
    margin-bottom: 1rem;
}

.skeleton-substance-card .skeleton-drops {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Enrichment Card Skeleton */
.skeleton-enrichment-card {
    background: var(--cloud);
    border: 1px solid var(--skeleton-base);
    border-radius: var(--skeleton-radius-lg);
    overflow: hidden;
}

.skeleton-enrichment-card .skeleton-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--skeleton-base);
    border-bottom: 1px solid var(--skeleton-highlight);
}

.skeleton-enrichment-card .skeleton-body {
    padding: 1rem;
}

.skeleton-enrichment-card .skeleton-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.skeleton-enrichment-card .skeleton-row:last-child {
    margin-bottom: 0;
}

.skeleton-enrichment-card .skeleton-label {
    width: 30%;
    height: 0.875rem;
}

.skeleton-enrichment-card .skeleton-value {
    width: 60%;
    height: 0.875rem;
}

.skeleton-enrichment-card .skeleton-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--skeleton-base);
}

/* Table Skeleton */
.skeleton-table {
    width: 100%;
    border-collapse: collapse;
}

.skeleton-table-header {
    background: var(--skeleton-base);
}

.skeleton-table-header .skeleton-th {
    padding: 0.75rem 1rem;
}

.skeleton-table-row {
    border-bottom: 1px solid var(--skeleton-base);
}

.skeleton-table-row .skeleton-td {
    padding: 0.75rem 1rem;
}

/* Drop/Badge Skeleton */
.skeleton-drop {
    height: 1.5rem;
    min-width: 4rem;
    border-radius: var(--skeleton-radius-full);
}

.skeleton-drop-sm {
    height: 1.25rem;
    min-width: 3rem;
}

.skeleton-drop-lg {
    height: 1.75rem;
    min-width: 5rem;
}

/* SMS Selector Skeleton */
.skeleton-sms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.skeleton-sms-option {
    height: 2.5rem;
    min-width: 4rem;
    border-radius: var(--skeleton-radius-lg);
}

/* Form Field Skeleton */
.skeleton-form-field {
    margin-bottom: 1.25rem;
}

.skeleton-form-field .skeleton-label {
    height: 0.875rem;
    width: 30%;
    margin-bottom: 0.5rem;
}

.skeleton-form-field .skeleton-input {
    height: 2.75rem;
    width: 100%;
}

/* List Item Skeleton */
.skeleton-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--skeleton-base);
}

.skeleton-list-item:last-child {
    border-bottom: none;
}

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

/* ========================================
   SKELETON GROUPS (Pre-built layouts)
   ======================================== */

/* Substance List Skeleton (3 items) */
.skeleton-substance-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Enrichment Panel Skeleton */
.skeleton-enrichment-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* Stats Card Skeleton */
.skeleton-stats {
    display: flex;
    gap: 1rem;
}

.skeleton-stat-card {
    flex: 1;
    padding: 1rem;
    background: var(--cloud);
    border: 1px solid var(--skeleton-base);
    border-radius: var(--skeleton-radius-lg);
}

.skeleton-stat-card .skeleton-number {
    height: 2rem;
    width: 3rem;
    margin-bottom: 0.5rem;
}

.skeleton-stat-card .skeleton-stat-label {
    height: 0.875rem;
    width: 60%;
}

/* ========================================
   ANIMATION CONTROL
   ======================================== */

/* Pause animation on hover (for debugging) */
.skeleton-debug:hover [class*="skeleton-"] {
    animation-play-state: paused;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .skeleton-shimmer,
    .skeleton-line,
    .skeleton-circle,
    .skeleton-badge,
    .skeleton-avatar,
    .skeleton-button,
    .skeleton-input,
    .skeleton-card,
    .skeleton-drop,
    [class*="skeleton-"] {
        animation: skeleton-pulse 2s ease-in-out infinite;
    }
}

/* ========================================
   DELAY STAGGER (for multiple items)
   ======================================== */

.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; }

/* ========================================
   TRANSITION TO CONTENT
   ======================================== */

/* Fade out skeleton, fade in content */
.skeleton-fade-out {
    animation: skeleton-fade-out 0.3s ease forwards;
}

@keyframes skeleton-fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        visibility: hidden;
    }
}

.content-fade-in {
    animation: content-fade-in 0.3s ease forwards;
}

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