/* UI Polish CSS - Loading States and Toast Notifications */

/* Loading Spinners */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.spinner-border {
    border-style: solid;
    border-color: currentColor;
    border-right-color: transparent;
    border-radius: 50%;
}

/* Global Loader Overlay */
#global-loader {
    backdrop-filter: blur(4px);
}

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

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

/* Toast Notifications */
#toast-container {
    max-width: 400px;
    pointer-events: none;
}

#toast-container > div {
    pointer-events: auto;
    margin-bottom: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Toast Animation */
@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* Loading Button States */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button[data-loading="true"] {
    position: relative;
    color: transparent;
}

button[data-loading="true"]::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 0.6s linear infinite;
}

/* Progress Bar */
.progress-bar {
    position: relative;
    height: 4px;
    background-color: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-bar.indeterminate .progress-bar-fill {
    width: 30%;
    animation: indeterminate-progress 1.5s infinite;
}

@keyframes indeterminate-progress {
    0% {
        left: -30%;
    }
    100% {
        left: 100%;
    }
}

/* Loading Dots */
.loading-dots {
    display: inline-flex;
    align-items: center;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: currentColor;
    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;
    }
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: #9ca3af;
}

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

.empty-state-description {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* Error States */
.error-state {
    background-color: #fef2f2;
    border: 1px solid #fee2e2;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
}

.error-state-icon {
    color: #ef4444;
    margin-bottom: 0.5rem;
}

.error-state-message {
    color: #991b1b;
    font-weight: 500;
}

/* Pulse Animation for New Content */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Mobile Responsiveness */
@media (max-width: 640px) {
    #toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        max-width: none;
    }

    #global-loader > div {
        width: 90%;
        max-width: 300px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .skeleton {
        background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    }

    .empty-state-title {
        color: #f3f4f6;
    }

    .empty-state-description {
        color: #9ca3af;
    }

    .error-state {
        background-color: #7f1d1d;
        border-color: #991b1b;
    }

    .error-state-message {
        color: #fecaca;
    }
}