/**
 * Loading States & Skeleton Loaders
 * Provides consistent loading experiences across the IFL application
 */

/* ===========================
   SKIP NAVIGATION LINK
   =========================== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #670000;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    font-weight: bold;
    z-index: 10000;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #ffcc00;
    outline-offset: 2px;
}

/* ===========================
   LOADING SPINNER
   =========================== */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(103, 0, 0, 0.1);
    border-top-color: #670000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-large {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

.loading-spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

/* Loading Container */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
}

.loading-text {
    color: #670000;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Overlay Loading State */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.loading-overlay.hidden {
    display: none;
}

/* Inline Loading State */
.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===========================
   SKELETON LOADERS
   =========================== */

/* Base Skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

/* Skeleton Text Lines */
.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text-title {
    height: 2rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-text-subtitle {
    height: 1.5rem;
    width: 40%;
    margin-bottom: 0.75rem;
}

/* Skeleton Card (for player/team cards) */
.skeleton-card {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.skeleton-card-image {
    width: 100%;
    height: 200px;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.skeleton-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Skeleton Player Card */
.skeleton-player-card {
    background: white;
    border-radius: 10px;
    border: 2px solid #f0f0f0;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-player-image {
    width: 100%;
    height: 250px;
    border-radius: 8px;
}

.skeleton-player-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.skeleton-stat-item {
    height: 40px;
    border-radius: 4px;
}

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

.skeleton-table-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.skeleton-table-cell {
    height: 1.5rem;
    border-radius: 4px;
}

/* Skeleton Gallery Grid */
.skeleton-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
}

.skeleton-gallery-item {
    width: 100%;
    height: 200px;
    border-radius: 10px;
}

/* Skeleton Match Preview */
.skeleton-match-preview {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.skeleton-match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.skeleton-team {
    width: 30%;
    height: 60px;
    border-radius: 8px;
}

.skeleton-vs {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.skeleton-stat-box {
    height: 80px;
    border-radius: 8px;
}

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

/* Fade-in animation for loaded content */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

/* Hide elements while loading */
.loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(103, 0, 0, 0.1);
    border-top-color: #670000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-loading-light::after {
    border-top-color: white;
}

.btn-loading-dark::after {
    border-top-color: #670000;
}

/* ===========================
   PROGRESSIVE IMAGE LOADING
   =========================== */

.progressive-image {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

.progressive-image.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.5),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

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

.progressive-image img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.progressive-image img.loaded {
    opacity: 1;
}

/* ===========================
   RESPONSIVE ADJUSTMENTS
   =========================== */

@media (max-width: 768px) {
    .loading-spinner-large {
        width: 50px;
        height: 50px;
        border-width: 5px;
    }

    .skeleton-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    .skeleton-stats-grid {
        grid-template-columns: 1fr;
    }

    .skeleton-match-header {
        flex-direction: column;
        gap: 1rem;
    }

    .skeleton-team {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .loading-container {
        padding: 2rem 1rem;
    }

    .skeleton-player-stats {
        grid-template-columns: 1fr;
    }

    .skeleton-gallery {
        grid-template-columns: 1fr;
    }
}

/* ===========================
   BREADCRUMBS NAVIGATION
   =========================== */

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: #666;
}

.breadcrumbs-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 0.5rem;
}

.breadcrumbs-item {
    display: flex;
    align-items: center;
}

.breadcrumbs-link {
    color: #670000;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.breadcrumbs-link:hover {
    background-color: rgba(103, 0, 0, 0.1);
    text-decoration: underline;
}

.breadcrumbs-link:focus {
    outline: 2px solid #670000;
    outline-offset: 2px;
}

.breadcrumbs-separator {
    color: #999;
    margin: 0 0.25rem;
    user-select: none;
}

.breadcrumbs-current {
    color: #333;
    font-weight: 500;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .breadcrumbs {
        font-size: 0.85rem;
        padding: 0.75rem 0;
    }

    .breadcrumbs-list {
        gap: 0.25rem;
    }

    .breadcrumbs-link {
        padding: 0.2rem 0.4rem;
    }
}

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

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.opacity-0 {
    opacity: 0;
}

.opacity-50 {
    opacity: 0.5;
}

.opacity-100 {
    opacity: 1;
}

.pointer-events-none {
    pointer-events: none;
}

.pointer-events-auto {
    pointer-events: auto;
}

/* Smooth transitions */
.transition-opacity {
    transition: opacity 0.3s ease;
}

.transition-all {
    transition: all 0.3s ease;
}

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

/* Dot Pulse Spinner */
.spinner-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.spinner-dots span {
    width: 10px;
    height: 10px;
    background: var(--color-maroon, #670000);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.spinner-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.spinner-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Spinner with Label */
.spinner-labeled {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3, 0.75rem);
}

.spinner-labeled .spinner-label {
    font-size: var(--text-sm, 0.875rem);
    color: var(--color-gray-600, #7F8C8D);
    font-weight: var(--font-medium, 500);
}

/* Progress Bar with Glow */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-gray-200, #e9ecef);
    border-radius: var(--radius-full, 9999px);
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-maroon, linear-gradient(135deg, #670000 0%, #a70000 100%));
    border-radius: inherit;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar-glow .progress-bar-fill {
    box-shadow: 0 0 10px rgba(103, 0, 0, 0.4);
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s ease-in-out infinite;
}

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

/* Progress with Label */
.progress-labeled {
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 0.5rem);
}

.progress-labeled .progress-label {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm, 0.875rem);
    color: var(--color-gray-700, #414141);
}

.progress-labeled .progress-value {
    font-weight: var(--font-semibold, 600);
    color: var(--color-maroon, #670000);
}

/* Enhanced Skeleton Card v2 */
.skeleton-card-v2 {
    background: linear-gradient(180deg, #f5f5f5 0%, #fafafa 100%);
    border-radius: var(--radius-xl, 16px);
    overflow: hidden;
    box-shadow: var(--shadow-card, 0 2px 8px rgba(0, 0, 0, 0.06));
}

.skeleton-card-v2 .skeleton-header {
    height: 120px;
    background: linear-gradient(135deg, #e8e8e8 0%, #d8d8d8 100%);
    position: relative;
}

.skeleton-card-v2 .skeleton-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--color-gray-300, #E1E8ED);
}

.skeleton-card-v2 .skeleton-body {
    padding: var(--space-4, 1rem);
}

/* Skeleton Player Card v2 */
.skeleton-player-v2 {
    background: white;
    border-radius: var(--radius-xl, 16px);
    overflow: hidden;
    box-shadow: var(--shadow-card, 0 2px 8px rgba(0, 0, 0, 0.06));
}

.skeleton-player-v2 .skeleton-avatar {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #e8e8e8 0%, #d8d8d8 100%);
}

.skeleton-player-v2 .skeleton-info {
    padding: var(--space-4, 1rem);
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 0.5rem);
}

.skeleton-player-v2 .skeleton-name {
    height: 1.25rem;
    width: 70%;
    border-radius: var(--radius-sm, 4px);
}

.skeleton-player-v2 .skeleton-team {
    height: 1rem;
    width: 50%;
    border-radius: var(--radius-sm, 4px);
}

.skeleton-player-v2 .skeleton-stats-row {
    display: flex;
    gap: var(--space-4, 1rem);
    margin-top: var(--space-3, 0.75rem);
    padding-top: var(--space-3, 0.75rem);
    border-top: 1px solid var(--color-gray-200, #e9ecef);
}

.skeleton-player-v2 .skeleton-stat {
    flex: 1;
    text-align: center;
}

.skeleton-player-v2 .skeleton-stat-value {
    height: 1.5rem;
    width: 60%;
    margin: 0 auto var(--space-1, 0.25rem);
    border-radius: var(--radius-sm, 4px);
}

.skeleton-player-v2 .skeleton-stat-label {
    height: 0.75rem;
    width: 80%;
    margin: 0 auto;
    border-radius: var(--radius-sm, 4px);
}

/* Skeleton Match Card v2 */
.skeleton-match-v2 {
    background: white;
    border-radius: var(--radius-xl, 16px);
    overflow: hidden;
    box-shadow: var(--shadow-card, 0 2px 8px rgba(0, 0, 0, 0.06));
}

.skeleton-match-v2 .skeleton-match-date {
    height: 2.5rem;
    background: linear-gradient(135deg, #e8e8e8 0%, #d8d8d8 100%);
}

.skeleton-match-v2 .skeleton-match-body {
    padding: var(--space-4, 1rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4, 1rem);
}

.skeleton-match-v2 .skeleton-team-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2, 0.5rem);
}

.skeleton-match-v2 .skeleton-team-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-match-v2 .skeleton-team-name {
    height: 1rem;
    width: 80%;
    border-radius: var(--radius-sm, 4px);
}

.skeleton-match-v2 .skeleton-score {
    width: 80px;
    height: 2.5rem;
    border-radius: var(--radius-md, 8px);
}

/* Pulse Animation for Skeleton */
.skeleton-pulse {
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

@keyframes skeletonPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Content Placeholder */
.content-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12, 3rem) var(--space-4, 1rem);
    text-align: center;
}

.content-placeholder-icon {
    font-size: 3rem;
    color: var(--color-gray-400, #ddd);
    margin-bottom: var(--space-4, 1rem);
}

.content-placeholder-title {
    font-size: var(--text-lg, 1.125rem);
    font-weight: var(--font-semibold, 600);
    color: var(--color-gray-700, #414141);
    margin-bottom: var(--space-2, 0.5rem);
}

.content-placeholder-text {
    font-size: var(--text-sm, 0.875rem);
    color: var(--color-gray-500, #bdbdbd);
    max-width: 300px;
}

/* Error State */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8, 2rem);
    text-align: center;
    background: var(--color-error-bg, #f8d7da);
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--color-error, #dc3545);
}

.error-state-icon {
    font-size: 2.5rem;
    color: var(--color-error, #dc3545);
    margin-bottom: var(--space-3, 0.75rem);
}

.error-state-title {
    font-size: var(--text-lg, 1.125rem);
    font-weight: var(--font-semibold, 600);
    color: var(--color-error-dark, #721c24);
    margin-bottom: var(--space-2, 0.5rem);
}

.error-state-text {
    font-size: var(--text-sm, 0.875rem);
    color: var(--color-error-dark, #721c24);
}

/* Success State */
.success-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8, 2rem);
    text-align: center;
    background: var(--color-success-bg, #d4edda);
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--color-success, #28a745);
}

.success-state-icon {
    font-size: 2.5rem;
    color: var(--color-success, #28a745);
    margin-bottom: var(--space-3, 0.75rem);
}

.success-state-title {
    font-size: var(--text-lg, 1.125rem);
    font-weight: var(--font-semibold, 600);
    color: var(--color-success-dark, #155724);
}
