/**
 * Loading States and Spinner Styles
 * In-or-Out Game Enhancement
 */

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none !important; /* Force hidden by default to prevent infinite loading */
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.active {
    display: flex !important; /* Override the default hidden state */
    opacity: 1;
    visibility: visible;
}

/* Spinner Container */
.spinner-container {
    text-align: center;
    color: white;
}

/* Main Spinner */
.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    position: relative;
}

.spinner-circle {
    width: 100%;
    height: 100%;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #00D4FF;
    border-right-color: #FF0099;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

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

/* Loading Text */
.loading-text {
    font-size: 18px;
    font-weight: 500;
    margin-top: 10px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Inline Button Loading States */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

/* Small inline spinners */
.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

/* Loading dots animation */
.loading-dots {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 20px;
}

.loading-dots span {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #00D4FF;
    animation: loading-dots 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    left: 8px;
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    left: 32px;
    animation-delay: -0.16s;
    background: #FF0099;
}

.loading-dots span:nth-child(3) {
    left: 56px;
    animation-delay: 0;
}

@keyframes loading-dots {
    0%, 80%, 100% {
        transform: translateY(-50%) scale(0);
    }
    40% {
        transform: translateY(-50%) scale(1);
    }
}

/* Connection status indicator */
.connection-status {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-20px);
}

.connection-status.show {
    opacity: 1;
    transform: translateY(0);
}

.connection-status.connecting {
    background: rgba(255, 153, 0, 0.9);
}

.connection-status.connected {
    background: rgba(76, 175, 80, 0.9);
}

.connection-status.disconnected {
    background: rgba(244, 67, 54, 0.9);
}

.connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Loading skeleton for content */
.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 25%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.1) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
    height: 20px;
    margin: 10px 0;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .loading-overlay {
        background: rgba(0, 0, 0, 0.85);
    }
    
    .spinner {
        width: 50px;
        height: 50px;
    }
    
    .loading-text {
        font-size: 16px;
    }
    
    .connection-status {
        top: auto;
        bottom: 10px;
        right: 10px;
    }
}