/**
 * HXCode Skeleton Loading States
 * Minimal, professional loading indicators
 */

/* ============================================
   CSS Custom Properties (Theme Variables)
   ============================================ */
:root {
    --skeleton-base: #e9ecef;
    --skeleton-highlight: #f8f9fa;
    --skeleton-duration: 1.5s;
    --skeleton-border-radius: 4px;
    --skeleton-gap: 12px;
}

/* ============================================
   Core Skeleton Animation
   ============================================ */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 0%,
        var(--skeleton-base) 40%,
        var(--skeleton-highlight) 50%,
        var(--skeleton-base) 60%,
        var(--skeleton-base) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer var(--skeleton-duration) ease-in-out infinite;
    border-radius: var(--skeleton-border-radius);
    pointer-events: none;
    user-select: none;
}

/* ============================================
   Session List Skeleton
   ============================================ */
.skeleton-session-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.skeleton-session-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.skeleton-session-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-session-title {
    height: 18px;
    width: 60%;
    max-width: 200px;
}

.skeleton-session-meta {
    height: 14px;
    width: 80%;
    max-width: 300px;
}

.skeleton-session-actions {
    display: flex;
    gap: 5px;
}

.skeleton-session-button {
    width: 50px;
    height: 24px;
    border-radius: 3px;
}

/* ============================================
   Chat Message Skeleton (Thinking Indicator)
   ============================================ */
.skeleton-chat-message {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 80%;
    align-self: flex-start;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Animated thinking dots */
.skeleton-thinking-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.skeleton-thinking-dot {
    width: 8px;
    height: 8px;
    background-color: #999;
    border-radius: 50%;
    animation: skeleton-bounce 1.4s ease-in-out infinite;
}

.skeleton-thinking-dot:nth-child(1) {
    animation-delay: 0s;
}

.skeleton-thinking-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.skeleton-thinking-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes skeleton-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Alternative text-based thinking indicator */
.skeleton-thinking-text {
    color: #666;
    font-size: 0.9em;
    font-style: italic;
}

/* ============================================
   Login Screen Skeleton
   ============================================ */
.skeleton-login {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

.skeleton-login-title {
    height: 40px;
    width: 150px;
}

.skeleton-login-subtitle {
    height: 20px;
    width: 300px;
    max-width: 90vw;
}

.skeleton-login-button {
    height: 44px;
    width: 200px;
    border-radius: 22px;
}

/* ============================================
   Utility Classes
   ============================================ */

/* Hide with fade-out transition */
.skeleton-fadeout {
    animation: skeleton-fadeout 0.3s ease-out forwards;
}

@keyframes skeleton-fadeout {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Show skeleton with aria-busy state */
[aria-busy="true"] {
    position: relative;
}

/* Accessible loading indicator */
.skeleton-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 600px) {
    .skeleton-session-title {
        width: 70%;
    }

    .skeleton-session-meta {
        width: 90%;
    }

    .skeleton-login-subtitle {
        width: 250px;
    }
}

/* ============================================
   Reduced Motion Support
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
        background: var(--skeleton-base);
    }

    .skeleton-thinking-dot {
        animation: none;
        opacity: 0.6;
    }
}

/* ============================================
   Dark Mode Support (Future-ready)
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --skeleton-base: #2a2a2a;
        --skeleton-highlight: #3a3a3a;
    }

    .skeleton-chat-message {
        background-color: #2a2a2a;
    }

    .skeleton-thinking-dot {
        background-color: #666;
    }
}
