/* Skeleton Loading Styles */

.skeleton {
    background: linear-gradient(90deg, 
        rgba(40, 32, 26, 0.4) 25%, 
        rgba(60, 48, 38, 0.6) 50%, 
        rgba(40, 32, 26, 0.4) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.light-mode .skeleton {
    background: linear-gradient(90deg, 
        rgba(230, 230, 230, 0.8) 25%, 
        rgba(245, 245, 245, 1) 50%, 
        rgba(230, 230, 230, 0.8) 75%
    );
}

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

/* Message Skeleton */
.skeleton-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}

.skeleton-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-content {
    flex: 1;
    max-width: 70%;
}

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

.skeleton-line:last-child {
    width: 60%;
}

/* Market Card Skeleton */
.skeleton-market-card {
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.skeleton-market-title {
    height: 14px;
    width: 80px;
    margin-bottom: 8px;
}

.skeleton-market-value {
    height: 24px;
    width: 120px;
    margin-bottom: 8px;
}

.skeleton-market-change {
    height: 14px;
    width: 100px;
}

/* Settings Skeleton */
.skeleton-settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.skeleton-settings-text {
    flex: 1;
}

.skeleton-settings-label {
    height: 16px;
    width: 150px;
    margin-bottom: 6px;
}

.skeleton-settings-desc {
    height: 12px;
    width: 200px;
}

.skeleton-toggle {
    width: 50px;
    height: 26px;
    border-radius: 13px;
}

/* Chat History Skeleton */
.skeleton-history-item {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
}

.skeleton-history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.skeleton-history-badge {
    height: 20px;
    width: 80px;
}

.skeleton-history-date {
    height: 12px;
    width: 120px;
    margin-top: 4px;
}

.skeleton-history-count {
    height: 14px;
    width: 100px;
    margin-top: 8px;
}

/* Profile Photo Skeleton */
.skeleton-profile-photo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
}

/* Input Skeleton */
.skeleton-input {
    height: 40px;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Button Skeleton */
.skeleton-button {
    height: 44px;
    border-radius: 10px;
    width: 100%;
}

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

/* Responsive */
@media (max-width: 768px) {
    .skeleton-content {
        max-width: 85%;
    }
}


/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 20, 16, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-overlay-content {
    text-align: center;
    color: var(--text-primary);
}

.loading-spinner-large {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(212, 175, 55, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-overlay-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

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

/* ============================================
   LOADING BUTTON STATE
   ============================================ */

button.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

/* Dark spinner for light backgrounds */
.btn-primary .loading-spinner,
.auth-btn .loading-spinner {
    border-color: rgba(26, 20, 16, 0.3);
    border-top-color: var(--dark-bg);
}

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

.loading-skeleton {
    min-height: 100px;
    position: relative;
}

/* ============================================
   PROFILE SKELETON
   ============================================ */

.skeleton-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

/* ============================================
   LIST SKELETON
   ============================================ */

.skeleton-list-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.skeleton-list-item:last-child {
    border-bottom: none;
}

/* ============================================
   SMOOTH TRANSITIONS
   ============================================ */

.skeleton-message,
.skeleton-market-card,
.skeleton-history-item,
.skeleton-settings-row,
.skeleton-profile,
.skeleton-list-item {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   LIGHT MODE ADJUSTMENTS
   ============================================ */

.light-mode .loading-overlay {
    background: rgba(245, 238, 225, 0.95);
}

.light-mode .loading-spinner-large {
    border-color: rgba(212, 175, 55, 0.3);
    border-top-color: var(--primary);
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
    .loading-spinner-large {
        width: 50px;
        height: 50px;
    }
    
    .loading-overlay-text {
        font-size: 16px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .skeleton,
    .loading-spinner,
    .loading-spinner-large {
        animation: none;
    }
    
    .skeleton {
        background: rgba(40, 32, 26, 0.4);
    }
    
    .light-mode .skeleton {
        background: rgba(230, 230, 230, 0.8);
    }
}

/* ============================================
   LOADING STATES FOR SPECIFIC ELEMENTS
   ============================================ */

/* Chat input loading */
.chat-input.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Send button loading */
.send-btn.loading {
    background: var(--primary-dark);
}

/* Nav item loading */
.nav-item.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Card loading */
.market-card.loading {
    opacity: 0.7;
}
