/**
 * Alpha-Trader Dashboard - Loading States CSS
 * Skeleton loaders, shimmer effects, and empty/error states
 */

/* ============================================
   SHIMMER ANIMATION
   ============================================ */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ============================================
   SKELETON BASE
   ============================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-surface, #121218) 25%,
        var(--bg-hover, #242432) 50%,
        var(--bg-surface, #121218) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite ease-in-out;
    border-radius: var(--radius-md, 6px);
}

/* Skeleton variants */
.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 70%;
    margin-bottom: 0;
}

.skeleton-text-sm {
    height: 12px;
}

.skeleton-text-lg {
    height: 18px;
}

.skeleton-title {
    height: 20px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-number {
    height: 32px;
    width: 120px;
}

.skeleton-number-lg {
    height: 48px;
    width: 160px;
}

.skeleton-badge {
    height: 24px;
    width: 80px;
    border-radius: var(--radius-full, 9999px);
}

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

.skeleton-icon {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm, 4px);
}

.skeleton-button {
    height: 36px;
    width: 100px;
    border-radius: var(--radius-md, 6px);
}

.skeleton-card {
    padding: 16px;
    background: var(--bg-surface, #121218);
    border-radius: var(--radius-lg, 8px);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

/* ============================================
   POSITION SKELETON
   ============================================ */
.skeleton-position {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-surface, #121218);
    border-radius: var(--radius-lg, 8px);
    margin-bottom: 8px;
}

.skeleton-position-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skeleton-position-pnl {
    width: 80px;
    text-align: right;
}

/* ============================================
   EDGE SKELETON
   ============================================ */
.skeleton-edge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-surface, #121218);
    border-radius: var(--radius-md, 6px);
    margin-bottom: 6px;
}

.skeleton-edge-bar {
    flex: 1;
    height: 8px;
    border-radius: var(--radius-full, 9999px);
}

/* ============================================
   TABLE SKELETON
   ============================================ */
.skeleton-table-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

/* ============================================
   LOADING SPINNER
   ============================================ */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    border-top-color: var(--alpha-teal, #00D4AA);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 1.5px;
}

.loading-spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(4px);
    border-radius: inherit;
    z-index: 10;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.loading-text {
    font-size: var(--text-sm, 0.875rem);
    color: var(--text-muted, #64748B);
}

/* ============================================
   ERROR STATE
   ============================================ */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    min-height: 200px;
}

.error-state-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: var(--danger, #EF4444);
    opacity: 0.8;
}

.error-state-title {
    font-size: var(--text-base, 1rem);
    font-weight: 600;
    color: var(--text-primary, #F8FAFC);
    margin-bottom: 8px;
}

.error-state-message {
    font-size: var(--text-sm, 0.875rem);
    color: var(--text-muted, #64748B);
    max-width: 280px;
    margin-bottom: 16px;
}

.error-state-retry {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-hover, #242432);
    border: 1px solid var(--border-default, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 6px);
    color: var(--text-secondary, #CBD5E1);
    font-size: var(--text-sm, 0.875rem);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast, 150ms) var(--ease-default, ease);
}

.error-state-retry:hover {
    background: var(--bg-active, #2A2A3A);
    border-color: var(--border-strong, rgba(255, 255, 255, 0.12));
}

.error-state-retry svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    min-height: 200px;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    color: var(--text-dim, #475569);
    opacity: 0.6;
}

.empty-state-title {
    font-size: var(--text-base, 1rem);
    font-weight: 600;
    color: var(--text-secondary, #CBD5E1);
    margin-bottom: 8px;
}

.empty-state-message {
    font-size: var(--text-sm, 0.875rem);
    color: var(--text-muted, #64748B);
    max-width: 280px;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: var(--z-toast, 900);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-floating, #1A1A24);
    border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
    border-radius: var(--radius-lg, 8px);
    box-shadow: var(--shadow-xl, 0 16px 32px rgba(0, 0, 0, 0.4));
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: all var(--duration-base, 250ms) var(--ease-spring, cubic-bezier(0.175, 0.885, 0.32, 1.275));
}

.toast.visible {
    opacity: 1;
    transform: translateX(0);
}

.toast.exiting {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    color: var(--success, #10B981);
}

.toast-error .toast-icon {
    color: var(--danger, #EF4444);
}

.toast-warning .toast-icon {
    color: var(--warning, #F59E0B);
}

.toast-info .toast-icon {
    color: var(--info, #3B82F6);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: var(--text-sm, 0.875rem);
    font-weight: 600;
    color: var(--text-primary, #F8FAFC);
}

.toast-message {
    font-size: var(--text-xs, 0.75rem);
    color: var(--text-muted, #64748B);
    margin-top: 2px;
}

.toast-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-dim, #475569);
    cursor: pointer;
    border-radius: var(--radius-sm, 4px);
    transition: all var(--duration-fast, 150ms);
}

.toast-close:hover {
    background: var(--bg-hover, #242432);
    color: var(--text-secondary, #CBD5E1);
}

.toast-close svg {
    width: 14px;
    height: 14px;
}

/* Toast with border accent */
.toast-success {
    border-left: 3px solid var(--success, #10B981);
}

.toast-error {
    border-left: 3px solid var(--danger, #EF4444);
}

.toast-warning {
    border-left: 3px solid var(--warning, #F59E0B);
}

.toast-info {
    border-left: 3px solid var(--info, #3B82F6);
}

/* ============================================
   LOADING PULSE (for content areas)
   ============================================ */
@keyframes pulse-loading {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.8;
    }
}

.loading-pulse {
    animation: pulse-loading 1.5s ease-in-out infinite;
}

/* ============================================
   STAGGERED LOADING ANIMATION
   ============================================ */
.stagger-load > * {
    opacity: 0;
    transform: translateY(10px);
    animation: staggerFadeIn 0.3s ease forwards;
}

@keyframes staggerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stagger-load > *:nth-child(1) { animation-delay: 0ms; }
.stagger-load > *:nth-child(2) { animation-delay: 50ms; }
.stagger-load > *:nth-child(3) { animation-delay: 100ms; }
.stagger-load > *:nth-child(4) { animation-delay: 150ms; }
.stagger-load > *:nth-child(5) { animation-delay: 200ms; }
.stagger-load > *:nth-child(6) { animation-delay: 250ms; }
.stagger-load > *:nth-child(7) { animation-delay: 300ms; }
.stagger-load > *:nth-child(8) { animation-delay: 350ms; }
