/**
 * Loading Indicators CSS
 *
 * Comprehensive loading indicators and animations for TradeJournal
 *
 * @package TradeJournal
 * @version 1.0.0
 */

/* ===== LOADING INDICATORS ===== */

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

.loading-overlay.dark-mode {
    background: rgba(0, 0, 0, 0.8);
}

/* ===== SPINNER ANIMATIONS ===== */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

.spinner.dark-mode {
    border-color: #333;
    border-top-color: #fff;
}

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

/* ===== 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 #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

.btn.loading.btn-sm::after {
    width: 12px;
    height: 12px;
    margin-left: -6px;
    margin-top: -6px;
}

.btn.loading.btn-lg::after {
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
}

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

.form-group.loading input,
.form-group.loading select,
.form-group.loading textarea {
    position: relative;
    background-image: linear-gradient(90deg, #f0f0f0 25%, transparent 25%, transparent 50%, #f0f0f0 50%, #f0f0f0 75%, transparent 75%);
    background-size: 20px 20px;
    background-position: 0 0;
    animation: loading-shimmer 1.5s infinite;
}

.dark-mode .form-group.loading input,
.dark-mode .form-group.loading select,
.dark-mode .form-group.loading textarea {
    background-image: linear-gradient(90deg, #333 25%, transparent 25%, transparent 50%, #333 50%, #333 75%, transparent 75%);
}

@keyframes loading-shimmer {
    0% { background-position: -20px 0; }
    100% { background-position: 20px 0; }
}

/* ===== CONTENT LOADING PLACEHOLDERS ===== */

.content-placeholder {
    animation: fadeIn 0.3s ease-in-out;
}

.content-placeholder .placeholder-item {
    background: #f0f0f0;
    border-radius: 4px;
    margin-bottom: 10px;
    animation: pulse 1.5s ease-in-out infinite;
}

.content-placeholder .placeholder-item.large {
    height: 20px;
    width: 100%;
}

.content-placeholder .placeholder-item.medium {
    height: 16px;
    width: 80%;
}

.content-placeholder .placeholder-item.small {
    height: 12px;
    width: 60%;
}

.content-placeholder .placeholder-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f0f0f0;
    animation: pulse 1.5s ease-in-out infinite;
}

.dark-mode .content-placeholder .placeholder-item,
.dark-mode .content-placeholder .placeholder-avatar {
    background: #333;
}

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

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

/* ===== LOADING BARS ===== */

.loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #007cba 0%, #00a0d2 50%, #007cba 100%);
    transform: translateX(-100%);
    animation: loading-bar 1.5s ease-in-out infinite;
    z-index: 10000;
}

@keyframes loading-bar {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}

/* ===== SKELETON LOADING ===== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.skeleton.card {
    height: 200px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.skeleton.text {
    height: 16px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton.text.large {
    height: 20px;
    width: 80%;
}

.skeleton.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
}

.dark-mode .skeleton {
    background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    background-size: 200% 100%;
}

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

/* ===== PROGRESS INDICATORS ===== */

.progress-container {
    position: relative;
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #007cba, #00a0d2);
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar::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: progress-shine 2s infinite;
}

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

.dark-mode .progress-container {
    background: #444;
}

/* ===== INLINE LOADING ===== */

.inline-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top-color: #007cba;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.inline-loader.small {
    width: 12px;
    height: 12px;
    border-width: 1px;
}

.inline-loader.large {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

.dark-mode .inline-loader {
    border-color: #333;
    border-top-color: #fff;
}

/* ===== LOADING STATES FOR SPECIFIC COMPONENTS ===== */

.trade-form.loading .form-section {
    opacity: 0.6;
    pointer-events: none;
}

.contest-card.loading {
    position: relative;
}

.contest-card.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.contest-card.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #007cba;
    border-top: 3px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

/* ===== RESPONSIVE LOADING ===== */

@media (max-width: 768px) {
    .spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }

    .btn.loading::after {
        width: 14px;
        height: 14px;
        margin-left: -7px;
        margin-top: -7px;
    }

    .loading-overlay {
        backdrop-filter: none;
    }
}

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

.dark-mode .loading-overlay {
    background: rgba(0, 0, 0, 0.9);
}

.dark-mode .spinner {
    border-color: #333;
    border-top-color: #007cba;
}

.dark-mode .btn.loading::after {
    border-color: #333;
    border-top-color: #fff;
}

/* ===== LOADING TOASTS ===== */

.loading-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #007cba;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: flex;
    align-items: center;
    font-size: 14px;
    animation: slideInRight 0.3s ease-out;
}

.loading-toast .spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
    margin-left: 10px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.loading-toast.hide {
    animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}