/**
 * Dentalvarehuset Micro-Interactions
 * Loading states, hover effects, focus states, transitions
 *
 * Follows WCAG 2.1 AA guidelines for accessibility
 * Last Updated: 2026-02-28
 */

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

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1.25rem;
    height: 1.25rem;
    top: 50%;
    left: 50%;
    margin-left: -0.625rem;
    margin-top: -0.625rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(204, 0, 98, 0.05) 0%,
        rgba(204, 0, 98, 0.1) 50%,
        rgba(204, 0, 98, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}

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

/* Pulse Loading */
.pulse-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   BUTTON INTERACTIONS
   ============================================ */

/* Smooth Button Hover */
.btn, button, [type="button"], [type="submit"] {
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Button Active Feedback */
.btn:active,
button:active,
[type="button"]:active,
[type="submit"]:active {
    transform: scale(0.97);
}

/* Focus Ring Enhancement */
.btn:focus-visible,
button:focus-visible,
[type="button"]:focus-visible,
[type="submit"]:focus-visible,
a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(204, 0, 98, 0.3);
    border-color: rgb(204, 0, 98);
}

/* ============================================
   LINK HOVER EFFECTS
   ============================================ */

/* Underline Slide Effect */
.link-underline {
    position: relative;
    text-decoration: none;
}

.link-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(135deg, rgb(204, 0, 98) 0%, rgb(180, 0, 80) 100%);
    transition: width 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.link-underline:hover::after {
    width: 100%;
}

/* Arrow Slide Effect */
.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.link-arrow:hover {
    transform: translateX(4px);
}

.link-arrow svg {
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.link-arrow:hover svg {
    transform: translateX(4px);
}

/* ============================================
   CARD HOVER EFFECTS
   ============================================ */

/* Card Lift Effect */
.card-hover {
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
    transform: translateY(-4px);
}

/* Image Scale on Card Hover */
.card-scale-image {
    overflow: hidden;
}

.card-scale-image img,
.card-scale-image .image-placeholder {
    transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-scale-image:hover img,
.card-scale-image:hover .image-placeholder {
    transform: scale(1.05);
}

/* ============================================
   INPUT FIELD INTERACTIONS
   ============================================ */

/* Focus State */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgb(204, 0, 98);
    box-shadow: 0 0 0 3px rgba(204, 0, 98, 0.1);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

/* Floating Label Effect */
.floating-label-group {
    position: relative;
}

.floating-label-group input:focus + label,
.floating-label-group input:not(:placeholder-shown) + label,
.floating-label-group textarea:focus + label,
.floating-label-group textarea:not(:placeholder-shown) + label {
    transform: translateY(-1.5rem) scale(0.875);
    color: rgb(204, 0, 98);
}

.floating-label-group label {
    position: absolute;
    left: 0.75rem;
    top: 0.75rem;
    pointer-events: none;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left top;
}

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

.toast {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
    animation: slideIn 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.toast-success {
    border-left: 4px solid rgb(34, 197, 94);
}

.toast.toast-error {
    border-left: 4px solid rgb(239, 68, 68);
}

.toast.toast-info {
    border-left: 4px solid rgb(59, 130, 246);
}

.toast.toast-warning {
    border-left: 4px solid rgb(251, 191, 36);
}

.toast.toast-hiding {
    animation: slideOut 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================
   MODAL / DIALOG ANIMATIONS
   ============================================ */

.modal-backdrop {
    animation: fadeIn 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content {
    animation: scaleIn 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* ============================================
   DROPDOWN / MENU ANIMATIONS
   ============================================ */

.dropdown-menu {
    transform-origin: top;
    animation: dropdownOpen 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dropdownOpen {
    from {
        transform: scaleY(0.95);
        opacity: 0;
    }
    to {
        transform: scaleY(1);
        opacity: 1;
    }
}

/* ============================================
   CART BADGE ANIMATION
   ============================================ */

.cart-badge {
    transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-badge.badge-updated {
    animation: cartPulse 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes cartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ============================================
   ADD TO CART ANIMATION
   ============================================ */

@keyframes flyToCart {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(var(--fly-x), var(--fly-y)) scale(0.5);
        opacity: 0.8;
    }
    100% {
        transform: translate(var(--fly-x), var(--fly-y)) scale(0.2);
        opacity: 0;
    }
}

.product-added-animation {
    animation: flyToCart 600ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ============================================
   STAGGERED ANIMATIONS FOR LISTS
   ============================================ */

.stagger-in > * {
    opacity: 0;
    animation: staggerIn 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0ms; }
.stagger-in > *:nth-child(2) { animation-delay: 50ms; }
.stagger-in > *:nth-child(3) { animation-delay: 100ms; }
.stagger-in > *:nth-child(4) { animation-delay: 150ms; }
.stagger-in > *:nth-child(5) { animation-delay: 200ms; }
.stagger-in > *:nth-child(6) { animation-delay: 250ms; }
.stagger-in > *:nth-child(7) { animation-delay: 300ms; }
.stagger-in > *:nth-child(8) { animation-delay: 350ms; }

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

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

.page-transition-enter {
    animation: pageIn 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition-exit {
    animation: pageOut 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

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

/* Only show focus ring when using keyboard */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Respect prefers-reduced-motion */
@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 adjustments */
@media (prefers-contrast: high) {
    .btn:hover,
    button:hover {
        outline: 2px solid currentColor;
        outline-offset: 2px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Transition Utilities */
.transition-fast { transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1); }
.transition-normal { transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1); }
.transition-slow { transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1); }

/* Hover Utilities */
.hover-lift:hover { transform: translateY(-2px); }
.hover-scale:hover { transform: scale(1.02); }
.hover-glow:hover { box-shadow: 0 0 20px rgba(204, 0, 98, 0.3); }

/* No Interaction */
.no-pointer { pointer-events: none; }
.no-select { user-select: none; }
