/* ===== UX Enhancement Styles ===== */
/* Loading states, micro-animations, skeleton loaders, accessibility */

/* ===== Loading Spinner ===== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: spin 0.8s linear infinite;
}

.loading-spinner.dark {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Button Loading State ===== */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

.btn.loading span {
    opacity: 0.7;
}

/* ===== Skeleton Loader ===== */
.skeleton {
    background: linear-gradient(90deg,
            var(--gray-200) 25%,
            var(--gray-100) 50%,
            var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
}

/* ===== Form Validation ===== */
.form-group.error input,
.form-group.error select {
    border-color: var(--danger);
    background: #fef2f2;
}

.form-group.success input,
.form-group.success select {
    border-color: var(--success);
    background: #f0fdf4;
}

.form-error {
    display: none;
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
    animation: shake 0.3s ease;
}

.form-group.error .form-error {
    display: block;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Input focus ring for accessibility */
.form-group input:focus,
.form-group select:focus,
.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

/* ===== Tooltip ===== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: var(--gray-900);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* ===== Progress Bar ===== */
.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 999px;
    transition: width 0.5s ease;
}

/* ===== Badge Pulse Animation ===== */
.badge-pulse {
    position: relative;
}

.badge-pulse::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Success Checkmark Animation ===== */
.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.success-checkmark .check-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--success);
    animation: scale-in 0.3s ease;
}

.success-checkmark .check-icon::after {
    content: '✓';
    font-size: 40px;
    color: white;
    animation: check-draw 0.3s ease 0.2s both;
}

@keyframes scale-in {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

@keyframes check-draw {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== Card Hover Effects ===== */
.card-hover {
    transition: var(--transition);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* ===== Smooth Page Transition ===== */
.page-enter {
    animation: page-enter 0.4s ease;
}

@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Accessibility ===== */
/* Focus visible for keyboard users */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --primary: #0066cc;
        --gray-500: #555555;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* ===== Touch Feedback (Mobile) ===== */
@media (hover: none) {

    .btn:active,
    .card-item:active,
    .nav-item:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* ===== Empty State Animation ===== */
.empty-state-icon {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ===== Toast Improvements ===== */
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-icon {
    font-size: 18px;
}

.toast-success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.toast-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast-info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* ===== Scroll Progress Indicator ===== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--gradient-primary);
    z-index: 9999;
    transition: width 0.1s linear;
}

/* ===== Notification Badge ===== */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Interactive Card Flip ===== */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.flip-card-back {
    transform: rotateY(180deg);
}

/* ===== Glassmorphism Card ===== */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}