/**
 * UI Components - Loading Skeletons, Toasts, and UI Polish
 * Professional production-ready components
 */

/* ============================================
   LOADING SKELETONS
   ============================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}

.skeleton-text:last-child {
    width: 80%;
}

.skeleton-title {
    height: 2em;
    width: 60%;
    margin-bottom: 1em;
    border-radius: 8px;
}

.skeleton-card {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(147, 112, 219, 0.2);
    border-radius: 16px;
}

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

.skeleton-image {
    width: 100%;
    height: 200px;
    border-radius: 12px;
}

/* Card skeleton layout */
.skeleton-card-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Grid skeleton */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    max-width: 400px;
}

.toast {
    background: rgba(26, 31, 58, 0.98);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(147, 112, 219, 0.3);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 1rem;
    pointer-events: auto;
    animation: toast-slide-in 0.3s ease-out;
    min-width: 300px;
    max-width: 400px;
}

.toast.removing {
    animation: toast-slide-out 0.3s ease-out forwards;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(calc(100% + 1rem));
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(calc(100% + 1rem));
        opacity: 0;
    }
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #ffffff;
}

.toast-message {
    font-size: 0.9rem;
    color: #c0c0c0;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.2rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.toast-close:hover {
    color: #fff;
}

/* Toast variants */
.toast.success {
    border-color: rgba(74, 222, 128, 0.5);
}

.toast.success .toast-icon {
    color: #4ade80;
}

.toast.error {
    border-color: rgba(255, 107, 107, 0.5);
}

.toast.error .toast-icon {
    color: #ff6b6b;
}

.toast.warning {
    border-color: rgba(255, 212, 59, 0.5);
}

.toast.warning .toast-icon {
    color: #ffd43b;
}

.toast.info {
    border-color: rgba(100, 149, 237, 0.5);
}

.toast.info .toast-icon {
    color: #6495ED;
}

/* Progress bar for auto-dismiss */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #9370DB, #DAA520);
    border-radius: 0 0 12px 12px;
    animation: toast-progress 5s linear forwards;
}

@keyframes toast-progress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Mobile toast positioning */
@media (max-width: 768px) {
    .toast-container {
        top: auto;
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }

    .toast {
        min-width: 0;
        max-width: none;
    }

    @keyframes toast-slide-in {
        from {
            transform: translateY(calc(100% + 1rem));
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    @keyframes toast-slide-out {
        from {
            transform: translateY(0);
            opacity: 1;
        }
        to {
            transform: translateY(calc(100% + 1rem));
            opacity: 0;
        }
    }
}

/* ============================================
   SMOOTH ANIMATIONS (60fps)
   ============================================ */

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

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

.slide-up {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Micro-interactions */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(147, 112, 219, 0.3);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(147, 112, 219, 0.5);
}

.hover-scale {
    transition: transform 0.2s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

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

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(147, 112, 219, 0.3);
    border-top-color: #9370DB;
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

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

.loading-spinner-large {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #9370DB;
    border-radius: 50%;
    animation: loading-dots 1.4s infinite ease-in-out both;
}

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

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(147, 112, 219, 0.2);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #9370DB, #DAA520);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.progress-fill.indeterminate {
    width: 50%;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

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

/* ============================================
   BADGES AND PILLS
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: rgba(147, 112, 219, 0.2);
    border: 1px solid rgba(147, 112, 219, 0.3);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #9370DB;
}

.badge.success {
    background: rgba(74, 222, 128, 0.2);
    border-color: rgba(74, 222, 128, 0.3);
    color: #4ade80;
}

.badge.error {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

.badge.warning {
    background: rgba(255, 212, 59, 0.2);
    border-color: rgba(255, 212, 59, 0.3);
    color: #ffd43b;
}

/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #888;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #c0c0c0;
    margin-bottom: 0.5rem;
}

.empty-state-description {
    font-size: 1rem;
    color: #888;
    margin-bottom: 1.5rem;
}

.empty-state-action {
    margin-top: 1.5rem;
}

/* ============================================
   DIVIDERS
   ============================================ */

.divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(147, 112, 219, 0.3) 50%,
        transparent 100%
    );
    margin: 2rem 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(147, 112, 219, 0.3) 50%,
        transparent 100%
    );
}
