/**
 * Skeleton Loading Styles for AItrove.ai
 * 
 * Provides smooth skeleton animations while content loads
 * Matches the actual tool card dimensions to prevent layout shift
 */

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

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

@keyframes skeleton-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .skeleton,
    .skeleton-icon,
    .skeleton-title,
    .skeleton-description,
    .skeleton-badge {
        animation: none !important;
    }
}

/* === SKELETON TOOL CARD === */

.skeleton.tool-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    min-height: 160px; /* Match actual tool card height */
    cursor: default;
    pointer-events: none;
}

.skeleton.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    z-index: 1;
}

/* === SKELETON ELEMENTS === */

.skeleton-icon {
    width: 48px;
    height: 48px;
    background: var(--skeleton-color, #e2e8f0);
    border-radius: 8px;
    margin-bottom: 12px;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-title {
    height: 18px;
    background: var(--skeleton-color, #e2e8f0);
    border-radius: 4px;
    width: 70%;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
    animation-delay: 0.1s;
}

.skeleton-description {
    height: 14px;
    background: var(--skeleton-color, #e2e8f0);
    border-radius: 4px;
    width: 100%;
    margin-bottom: 4px;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
    animation-delay: 0.2s;
}

.skeleton-description:last-child {
    width: 85%;
}

.skeleton-badge {
    height: 20px;
    background: var(--skeleton-color, #e2e8f0);
    border-radius: 10px;
    width: 60px;
    margin-top: 8px;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
    animation-delay: 0.3s;
}

/* === SKELETON VARIATIONS === */

/* Large skeleton for featured tools */
.skeleton.tool-card.featured {
    min-height: 200px;
    padding: 24px;
}

.skeleton.tool-card.featured .skeleton-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
}

.skeleton.tool-card.featured .skeleton-title {
    height: 20px;
    width: 75%;
}

/* Compact skeleton for smaller viewports */
.skeleton.tool-card.compact {
    min-height: 120px;
    padding: 16px;
}

.skeleton.tool-card.compact .skeleton-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
}

.skeleton.tool-card.compact .skeleton-title {
    height: 16px;
}

.skeleton.tool-card.compact .skeleton-description {
    height: 12px;
}

/* === CATEGORY SKELETON === */

.skeleton-category {
    margin-bottom: 40px;
}

.skeleton-category-title {
    height: 28px;
    background: var(--skeleton-color, #e2e8f0);
    border-radius: 6px;
    width: 200px;
    margin-bottom: 20px;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-category-description {
    height: 16px;
    background: var(--skeleton-color, #e2e8f0);
    border-radius: 4px;
    width: 300px;
    margin-bottom: 24px;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
    animation-delay: 0.1s;
}

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

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--skeleton-color, #e2e8f0);
    border-top: 2px solid var(--primary-color, #3b82f6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === SHOW MORE BUTTON === */

.show-more-btn {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: 20px;
    padding: 20px;
}

.btn-show-more {
    background: var(--primary-color, #3b82f6);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-show-more:hover {
    background: var(--primary-hover, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-show-more:active {
    transform: translateY(0);
}

.btn-show-more i {
    font-size: 12px;
}

/* Loading state for show more button */
.btn-show-more.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-show-more.loading i {
    animation: spin 1s linear infinite;
}

/* === RESPONSIVE DESIGN === */

@media (max-width: 768px) {
    .skeleton.tool-card {
        padding: 16px;
        min-height: 140px;
    }
    
    .skeleton-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 10px;
    }
    
    .skeleton-title {
        height: 16px;
    }
    
    .skeleton-description {
        height: 12px;
    }
    
    .skeleton-category-title {
        height: 24px;
        width: 150px;
    }
    
    .skeleton-category-description {
        height: 14px;
        width: 250px;
    }
}

@media (max-width: 480px) {
    .skeleton.tool-card {
        padding: 12px;
        min-height: 120px;
    }
    
    .skeleton-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 8px;
    }
    
    .skeleton-title {
        height: 14px;
        width: 80%;
    }
    
    .skeleton-description {
        height: 11px;
    }
    
    .btn-show-more {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* === DARK MODE SUPPORT === */

@media (prefers-color-scheme: dark) {
    :root {
        --skeleton-color: #374151;
        --card-bg: #1f2937;
        --border-color: #374151;
    }
    
    .skeleton.tool-card::before {
        background: linear-gradient(
            90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent
        );
    }
    
    .loading-overlay {
        background: rgba(31, 41, 55, 0.8);
    }
}

/* Manual dark mode class */
.dark .skeleton.tool-card {
    background: var(--card-bg, #1f2937);
    border-color: var(--border-color, #374151);
}

.dark .skeleton.tool-card::before {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
}

.dark .skeleton-icon,
.dark .skeleton-title,
.dark .skeleton-description,
.dark .skeleton-badge,
.dark .skeleton-category-title,
.dark .skeleton-category-description {
    background: var(--skeleton-color, #374151);
}

.dark .loading-overlay {
    background: rgba(31, 41, 55, 0.8);
}

/* === FADE IN ANIMATIONS === */

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

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

.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

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

/* Stagger animation for multiple elements */
.stagger-fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.stagger-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === HIGH CONTRAST MODE === */

@media (prefers-contrast: high) {
    .skeleton-icon,
    .skeleton-title,
    .skeleton-description,
    .skeleton-badge {
        background: #666666;
    }
    
    .skeleton.tool-card {
        border: 2px solid #333333;
    }
}

/* === NEWS SKELETON STYLES === */

/* News skeleton loading animation for better LCP */
.news-skeleton {
    pointer-events: none;
    user-select: none;
    opacity: 0.8;
}

.news-skeleton .skeleton-line, 
.news-skeleton .skeleton-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    height: 1em;
    margin: 0.25em 0;
}

.news-skeleton .skeleton-image {
    height: 120px;
    border-radius: 8px;
    margin: 0;
    width: 100%;
}

.news-skeleton .skeleton-short {
    width: 60px;
    height: 0.8em;
}

.news-skeleton .skeleton-medium {
    width: 80%;
    height: 0.9em;
}

.news-skeleton .skeleton-title {
    width: 90%;
    height: 1.2em;
    margin: 0.5em 0;
}

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

/* Dark mode news skeleton */
@media (prefers-color-scheme: dark) {
    .news-skeleton .skeleton-line, 
    .news-skeleton .skeleton-image {
        background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
        background-size: 200% 100%;
    }
}

.dark .news-skeleton .skeleton-line, 
.dark .news-skeleton .skeleton-image {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

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

@media print {
    .skeleton,
    .news-skeleton,
    .show-more-btn,
    .loading-overlay {
        display: none !important;
    }
}