/**
 * Micro-Interactions CSS
 * 
 * Button hover effects, smooth transitions, loading skeletons, and toast notifications
 * for enhanced user experience across the Globull Limited website.
 * 
 * @package Globull
 * @author Globull Limited
 * @since 1.0.0
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES
   ========================================================================== */

:root {
    /* Animation Timing */
    --timing-instant: 0.1s;
    --timing-fast: 0.2s;
    --timing-normal: 0.3s;
    --timing-slow: 0.5s;
    --timing-slower: 0.8s;
    
    /* Easing Functions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out-circ: cubic-bezier(0.85, 0, 0.15, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Skeleton Colors */
    --skeleton-base: #e2e8f0;
    --skeleton-shine: #f1f5f9;
    --skeleton-base-dark: #334155;
    --skeleton-shine-dark: #475569;
    
    /* Toast Colors */
    --toast-success: #10b981;
    --toast-error: #ef4444;
    --toast-warning: #f59e0b;
    --toast-info: #3b82f6;
}

/* ==========================================================================
   BUTTON HOVER EFFECTS
   ========================================================================== */

/* Base Button Transition */
.btn,
button,
[role="button"],
a.btn,
.touch-target {
    position: relative;
    overflow: hidden;
    transition: 
        transform var(--timing-fast) var(--ease-out-expo),
        box-shadow var(--timing-fast) var(--ease-out-expo),
        background-color var(--timing-fast) ease-out,
        border-color var(--timing-fast) ease-out,
        color var(--timing-fast) ease-out;
}

/* Lift Effect on Hover */
.btn-lift,
.hover-lift {
    transition: transform var(--timing-normal) var(--ease-spring),
                box-shadow var(--timing-normal) var(--ease-spring);
}

.btn-lift:hover,
.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15),
                0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.btn-lift:active,
.hover-lift:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px -3px rgba(0, 0, 0, 0.1),
                0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* Scale Effect */
.btn-scale,
.hover-scale {
    transition: transform var(--timing-fast) var(--ease-out-back);
}

.btn-scale:hover,
.hover-scale:hover {
    transform: scale(1.05);
}

.btn-scale:active,
.hover-scale:active {
    transform: scale(0.98);
}

/* Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.3) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform var(--timing-slow), opacity var(--timing-normal);
}

.btn-ripple:active::after {
    transform: scale(0, 0);
    opacity: 1;
    transition: 0s;
}

/* Shine Effect */
.btn-shine {
    position: relative;
    overflow: hidden;
}

.btn-shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: left var(--timing-slow) var(--ease-out-expo);
}

.btn-shine:hover::before {
    left: 100%;
}

/* Glow Effect */
.btn-glow:hover {
    box-shadow: 0 0 20px rgba(30, 86, 160, 0.4),
                0 0 40px rgba(30, 86, 160, 0.2);
}

.btn-glow-primary:hover {
    box-shadow: 0 0 20px rgba(30, 86, 160, 0.5),
                0 0 40px rgba(30, 86, 160, 0.3);
}

/* Primary Button Enhancement */
.btn-primary,
[class*="bg-primary"]:not(.bg-primary-100):not(.bg-primary-50) {
    position: relative;
    overflow: hidden;
}

.btn-primary::before,
[class*="bg-primary"]:not(.bg-primary-100):not(.bg-primary-50)::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transition: left var(--timing-slow) var(--ease-out-expo);
}

.btn-primary:hover::before,
[class*="bg-primary"]:not(.bg-primary-100):not(.bg-primary-50):hover::before {
    left: 100%;
}

/* Icon Rotation on Hover */
.btn-icon-rotate svg,
.btn-icon-rotate i {
    transition: transform var(--timing-normal) var(--ease-spring);
}

.btn-icon-rotate:hover svg,
.btn-icon-rotate:hover i {
    transform: rotate(15deg);
}

/* Arrow Slide on Hover */
.btn-arrow::after {
    content: '→';
    display: inline-block;
    margin-left: 0.5rem;
    transition: transform var(--timing-normal) var(--ease-out-expo);
}

.btn-arrow:hover::after {
    transform: translateX(4px);
}

/* ==========================================================================
   SMOOTH TRANSITIONS
   ========================================================================== */

/* Global Smooth Transitions */
* {
    scroll-behavior: smooth;
}

/* Card Hover Effects */
.card,
.card-hover,
[class*="rounded-xl"][class*="shadow"],
[class*="rounded-2xl"][class*="shadow"] {
    transition: 
        transform var(--timing-normal) var(--ease-out-expo),
        box-shadow var(--timing-normal) var(--ease-out-expo),
        border-color var(--timing-fast) ease-out;
}

.card:hover,
.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
                0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Link Underline Animation */
.link-underline {
    position: relative;
    text-decoration: none;
}

.link-underline::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: currentColor;
    transition: width var(--timing-normal) var(--ease-out-expo);
}

.link-underline:hover::after {
    width: 100%;
}

/* Image Zoom on Hover */
.img-zoom {
    overflow: hidden;
}

.img-zoom img {
    transition: transform var(--timing-slow) var(--ease-out-expo);
}

.img-zoom:hover img {
    transform: scale(1.08);
}

/* Fade In Animation */
.fade-in {
    animation: fadeIn var(--timing-normal) var(--ease-out-expo) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide In Animations */
.slide-in-left {
    animation: slideInLeft var(--timing-normal) var(--ease-out-expo) forwards;
}

.slide-in-right {
    animation: slideInRight var(--timing-normal) var(--ease-out-expo) forwards;
}

.slide-in-up {
    animation: slideInUp var(--timing-normal) var(--ease-out-expo) forwards;
}

.slide-in-down {
    animation: slideInDown var(--timing-normal) var(--ease-out-expo) forwards;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger Animation */
.stagger-children > * {
    animation: fadeIn var(--timing-normal) var(--ease-out-expo) forwards;
    opacity: 0;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.8s; }

/* Form Input Focus Effects */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    transition: 
        border-color var(--timing-fast) ease-out,
        box-shadow var(--timing-fast) ease-out,
        background-color var(--timing-fast) ease-out;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus,
select:focus {
    box-shadow: 0 0 0 3px rgba(30, 86, 160, 0.15);
}

/* Checkbox/Radio Animation */
input[type="checkbox"],
input[type="radio"] {
    transition: transform var(--timing-instant) var(--ease-spring);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    animation: checkPop var(--timing-fast) var(--ease-spring);
}

@keyframes checkPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ==========================================================================
   LOADING SKELETONS
   ========================================================================== */

/* Base Skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-shine) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
}

.dark .skeleton {
    background: linear-gradient(
        90deg,
        var(--skeleton-base-dark) 25%,
        var(--skeleton-shine-dark) 50%,
        var(--skeleton-base-dark) 75%
    );
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton Variants */
.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1em;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 8px;
}

.skeleton-image-square {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 8px;
}

.skeleton-button {
    height: 44px;
    width: 120px;
    border-radius: 8px;
}

.skeleton-card {
    padding: 1.5rem;
    border-radius: 1rem;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark .skeleton-card {
    background: #1e293b;
}

/* Skeleton Card Content */
.skeleton-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Pulse Animation Alternative */
.skeleton-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    background-color: var(--skeleton-base);
}

.dark .skeleton-pulse {
    background-color: var(--skeleton-base-dark);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* List Skeleton */
.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.skeleton-list-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

/* Toast Container */
#toast-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Toast Positions */
#toast-container.top-right {
    top: 0;
    right: 0;
    align-items: flex-end;
}

#toast-container.top-left {
    top: 0;
    left: 0;
    align-items: flex-start;
}

#toast-container.bottom-right {
    bottom: 0;
    right: 0;
    align-items: flex-end;
}

#toast-container.bottom-left {
    bottom: 0;
    left: 0;
    align-items: flex-start;
}

#toast-container.top-center {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
}

#toast-container.bottom-center {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
}

/* Toast Base */
.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
                0 4px 6px -4px rgba(0, 0, 0, 0.1),
                0 0 0 1px rgba(0, 0, 0, 0.05);
    pointer-events: auto;
    max-width: 380px;
    min-width: 300px;
    animation: toastSlideIn var(--timing-normal) var(--ease-out-expo);
    transform-origin: center right;
}

.dark .toast {
    background: #1e293b;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3),
                0 4px 6px -4px rgba(0, 0, 0, 0.2),
                0 0 0 1px rgba(255, 255, 255, 0.05);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.toast.toast-exit {
    animation: toastSlideOut var(--timing-fast) var(--ease-in-out-circ) forwards;
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(100%) scale(0.9);
    }
}

/* Toast Icon */
.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-icon svg {
    width: 16px;
    height: 16px;
}

/* Toast Content */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #0f172a;
    margin-bottom: 0.125rem;
}

.dark .toast-title {
    color: #f8fafc;
}

.toast-message {
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.4;
}

.dark .toast-message {
    color: #94a3b8;
}

/* Toast Close Button */
.toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    transition: background-color var(--timing-fast) ease-out,
                color var(--timing-fast) ease-out;
}

.toast-close:hover {
    background-color: #f1f5f9;
    color: #475569;
}

.dark .toast-close:hover {
    background-color: #334155;
    color: #e2e8f0;
}

/* Toast Types */
.toast-success .toast-icon {
    background-color: #d1fae5;
    color: var(--toast-success);
}

.dark .toast-success .toast-icon {
    background-color: rgba(16, 185, 129, 0.2);
}

.toast-error .toast-icon {
    background-color: #fee2e2;
    color: var(--toast-error);
}

.dark .toast-error .toast-icon {
    background-color: rgba(239, 68, 68, 0.2);
}

.toast-warning .toast-icon {
    background-color: #fef3c7;
    color: var(--toast-warning);
}

.dark .toast-warning .toast-icon {
    background-color: rgba(245, 158, 11, 0.2);
}

.toast-info .toast-icon {
    background-color: #dbeafe;
    color: var(--toast-info);
}

.dark .toast-info .toast-icon {
    background-color: rgba(59, 130, 246, 0.2);
}

/* Toast Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    border-radius: 0 0 0.75rem 0.75rem;
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-top-color: #1e56a0;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.dark .spinner {
    border-color: #475569;
    border-top-color: #3b82f6;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Spinner Sizes */
.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

.spinner-xl {
    width: 56px;
    height: 56px;
    border-width: 4px;
}

/* Dots Loading */
.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background-color: #1e56a0;
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   SCROLL ANIMATIONS (Intersection Observer)
   ========================================================================== */

/* Elements to animate on scroll */
[data-animate] {
    opacity: 0;
    transition: 
        opacity var(--timing-slow) var(--ease-out-expo),
        transform var(--timing-slow) var(--ease-out-expo);
}

[data-animate="fade-up"] {
    transform: translateY(30px);
}

[data-animate="fade-down"] {
    transform: translateY(-30px);
}

[data-animate="fade-left"] {
    transform: translateX(30px);
}

[data-animate="fade-right"] {
    transform: translateX(-30px);
}

[data-animate="zoom-in"] {
    transform: scale(0.9);
}

[data-animate="zoom-out"] {
    transform: scale(1.1);
}

/* Animated State */
[data-animate].animated {
    opacity: 1;
    transform: translate(0) scale(1);
}

/* Delay Variants */
[data-delay="100"] { transition-delay: 0.1s; }
[data-delay="200"] { transition-delay: 0.2s; }
[data-delay="300"] { transition-delay: 0.3s; }
[data-delay="400"] { transition-delay: 0.4s; }
[data-delay="500"] { transition-delay: 0.5s; }

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .skeleton {
        animation: none;
        background: var(--skeleton-base);
    }
    
    .dark .skeleton {
        background: var(--skeleton-base-dark);
    }
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS
   ========================================================================== */

@media (max-width: 768px) {
    /* Reduce hover effects on touch devices */
    @media (hover: none) {
        .btn-lift:hover,
        .hover-lift:hover,
        .card:hover,
        .card-hover:hover {
            transform: none;
            box-shadow: inherit;
        }
    }
    
    /* Adjust toast position for mobile */
    #toast-container {
        padding: 0.75rem;
    }
    
    #toast-container.top-right,
    #toast-container.top-left,
    #toast-container.top-center {
        top: 0;
        left: 0;
        right: 0;
        transform: none;
        align-items: stretch;
    }
    
    #toast-container.bottom-right,
    #toast-container.bottom-left,
    #toast-container.bottom-center {
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        align-items: stretch;
    }
    
    .toast {
        max-width: none;
        min-width: auto;
    }
    
    @keyframes toastSlideIn {
        from {
            opacity: 0;
            transform: translateY(-100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    @keyframes toastSlideOut {
        from {
            opacity: 1;
            transform: translateY(0);
        }
        to {
            opacity: 0;
            transform: translateY(-100%);
        }
    }
}
