/**
 * TripSplit - Enhanced UI Animations and Interactive Design
 * Comprehensive CSS animations and transitions for better user experience
 */

/* ===== KEYFRAME ANIMATIONS ===== */

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    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);
    }
}

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

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -30px, 0);
    }
    70% {
        transform: translate3d(0, -15px, 0);
    }
    90% {
        transform: translate3d(0, -4px, 0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

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

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.8), 0 0 30px rgba(59, 130, 246, 0.6);
    }
}

@keyframes slideModal {
    from {
        opacity: 0;
        transform: scale(0.7) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes progressBar {
    from {
        width: 0%;
    }
    to {
        width: var(--progress-width, 100%);
    }
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* ===== ANIMATION CLASSES ===== */

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.5s ease-out forwards;
}

.animate-slide-in-left {
    animation: slideInLeft 0.5s ease-out forwards;
}

.animate-slide-in-up {
    animation: slideInUp 0.5s ease-out forwards;
}

.animate-slide-in-down {
    animation: slideInDown 0.5s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.4s ease-out forwards;
}

.animate-bounce {
    animation: bounce 1s ease-in-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

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

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-modal {
    animation: slideModal 0.3s ease-out forwards;
}

.animate-progress {
    animation: progressBar 1.5s ease-out forwards;
}

.animate-typing {
    animation: typing 2s steps(40, end), blink 0.75s step-end infinite;
    overflow: hidden;
    white-space: nowrap;
    border-left: 2px solid;
}

/* ===== STAGGERED ANIMATIONS ===== */

.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.6s ease-out forwards;
}

.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; }
.stagger-children > *:nth-child(9) { animation-delay: 0.9s; }
.stagger-children > *:nth-child(10) { animation-delay: 1.0s; }

/* ===== INTERACTIVE ELEMENTS ===== */

/* Enhanced Button Animations */
.btn-animated {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    transform: translateZ(0);
}

.btn-animated::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-animated:hover::before {
    left: 100%;
}

.btn-animated:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.btn-animated:active {
    transform: translateY(0);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 1000;
}

.fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

.fab:active {
    transform: scale(0.95);
}

/* Card Hover Effects */
.card-interactive {
    transition: all 0.3s ease;
    cursor: pointer;
}

.card-interactive:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

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

.card-image {
    transition: transform 0.3s ease;
    overflow: hidden;
}

/* Input Focus Effects */
.input-animated {
    position: relative;
    transition: all 0.3s ease;
}

.input-animated:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-animated::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.input-animated:focus::after {
    width: 100%;
}

/* Loading Animations */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '.';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% {
        color: rgba(0, 0, 0, 0);
        text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0), 0.5em 0 0 rgba(0, 0, 0, 0);
    }
    40% {
        color: black;
        text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0), 0.5em 0 0 rgba(0, 0, 0, 0);
    }
    60% {
        text-shadow: 0.25em 0 0 black, 0.5em 0 0 rgba(0, 0, 0, 0);
    }
    80%, 100% {
        text-shadow: 0.25em 0 0 black, 0.5em 0 0 black;
    }
}

/* Progress Indicators */
.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-circle {
    transition: stroke-dashoffset 0.35s;
    transform-origin: 50% 50%;
}

/* Notification Animations */
.notification {
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.hide {
    transform: translateX(100%);
}

/* Modal Animations */
.modal-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-content {
    transform: scale(0.7) translateY(-50px);
    opacity: 0;
    transition: all 0.3s ease;
}

.modal-content.show {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Sidebar Animations */
.sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.sidebar.open {
    transform: translateX(0);
}

/* Tab Animations */
.tab-content {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.tab-content.active {
    opacity: 1;
    transform: translateY(0);
}

/* Accordion Animations */
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-content.open {
    max-height: 500px;
}

/* Dropdown Animations */
.dropdown-menu {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s ease;
    pointer-events: none;
}

.dropdown-menu.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Tooltip Animations */
.tooltip {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.tooltip.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ===== RESPONSIVE ANIMATIONS ===== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 768px) {
    .animate-fade-in {
        animation-duration: 0.4s;
    }
    
    .btn-animated:hover {
        transform: none;
    }
    
    .card-interactive:hover {
        transform: none;
    }
}

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

.transition-all {
    transition: all 0.3s ease;
}

.transition-fast {
    transition: all 0.15s ease;
}

.transition-slow {
    transition: all 0.5s ease;
}

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }

.duration-100 { animation-duration: 0.1s; }
.duration-200 { animation-duration: 0.2s; }
.duration-300 { animation-duration: 0.3s; }
.duration-500 { animation-duration: 0.5s; }
.duration-700 { animation-duration: 0.7s; }
.duration-1000 { animation-duration: 1s; }

/* ===== SPECIAL EFFECTS ===== */

/* Gradient Text Animation */
.gradient-text {
    background: linear-gradient(-45deg, #667eea, #764ba2, #667eea, #764ba2);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Floating Elements */
.float {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
    width: 300px;
    height: 300px;
}

/* Parallax Effect */
.parallax {
    transform: translateZ(0);
    transition: transform 0.1s ease-out;
}

/* Morphing Shapes */
.morph {
    transition: border-radius 0.5s ease;
}

.morph:hover {
    border-radius: 50%;
}

/* Text Reveal Animation */
.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    transition: transform 0.5s ease;
}

.text-reveal.animate span {
    transform: translateY(0);
}

/* Image Zoom Effect */
.image-zoom {
    overflow: hidden;
}

.image-zoom img {
    transition: transform 0.5s ease;
}

.image-zoom:hover img {
    transform: scale(1.1);
}

/* Glitch Effect */
.glitch {
    position: relative;
    color: white;
    font-size: 4em;
    letter-spacing: 0.5em;
    animation: glitch-skew 1s infinite linear alternate-reverse;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    animation: glitch-anim 0.5s infinite linear alternate-reverse;
    color: #ff0000;
    z-index: -1;
}

.glitch::after {
    animation: glitch-anim2 1s infinite linear alternate-reverse;
    color: #00ffff;
    z-index: -2;
}

@keyframes glitch-anim {
    0% {
        clip: rect(42px, 9999px, 44px, 0);
        transform: skew(0.85deg);
    }
    5% {
        clip: rect(12px, 9999px, 59px, 0);
        transform: skew(0.4deg);
    }
    10% {
        clip: rect(48px, 9999px, 29px, 0);
        transform: skew(0.1deg);
    }
    15% {
        clip: rect(42px, 9999px, 73px, 0);
        transform: skew(0.7deg);
    }
    20% {
        clip: rect(63px, 9999px, 27px, 0);
        transform: skew(0.4deg);
    }
    25% {
        clip: rect(34px, 9999px, 55px, 0);
        transform: skew(0.2deg);
    }
    30% {
        clip: rect(86px, 9999px, 73px, 0);
        transform: skew(0.8deg);
    }
    35% {
        clip: rect(20px, 9999px, 20px, 0);
        transform: skew(1deg);
    }
    40% {
        clip: rect(26px, 9999px, 60px, 0);
        transform: skew(0.6deg);
    }
    45% {
        clip: rect(25px, 9999px, 42px, 0);
        transform: skew(0.2deg);
    }
    50% {
        clip: rect(69px, 9999px, 99px, 0);
        transform: skew(0.5deg);
    }
    55% {
        clip: rect(77px, 9999px, 67px, 0);
        transform: skew(0.3deg);
    }
    60% {
        clip: rect(87px, 9999px, 82px, 0);
        transform: skew(0.9deg);
    }
    65% {
        clip: rect(40px, 9999px, 87px, 0);
        transform: skew(0.2deg);
    }
    70% {
        clip: rect(50px, 9999px, 55px, 0);
        transform: skew(0.4deg);
    }
    75% {
        clip: rect(13px, 9999px, 85px, 0);
        transform: skew(0.7deg);
    }
    80% {
        clip: rect(90px, 9999px, 78px, 0);
        transform: skew(0.4deg);
    }
    85% {
        clip: rect(24px, 9999px, 33px, 0);
        transform: skew(0.1deg);
    }
    90% {
        clip: rect(61px, 9999px, 52px, 0);
        transform: skew(0.8deg);
    }
    95% {
        clip: rect(86px, 9999px, 84px, 0);
        transform: skew(0.7deg);
    }
    100% {
        clip: rect(1px, 9999px, 81px, 0);
        transform: skew(0.1deg);
    }
}

@keyframes glitch-anim2 {
    0% {
        clip: rect(65px, 9999px, 100px, 0);
        transform: skew(0.8deg);
    }
    5% {
        clip: rect(52px, 9999px, 74px, 0);
        transform: skew(0.7deg);
    }
    10% {
        clip: rect(79px, 9999px, 85px, 0);
        transform: skew(0.6deg);
    }
    15% {
        clip: rect(75px, 9999px, 5px, 0);
        transform: skew(0.3deg);
    }
    20% {
        clip: rect(67px, 9999px, 61px, 0);
        transform: skew(0.4deg);
    }
    25% {
        clip: rect(14px, 9999px, 79px, 0);
        transform: skew(0.5deg);
    }
    30% {
        clip: rect(1px, 9999px, 66px, 0);
        transform: skew(0.3deg);
    }
    35% {
        clip: rect(86px, 9999px, 30px, 0);
        transform: skew(0.2deg);
    }
    40% {
        clip: rect(23px, 9999px, 98px, 0);
        transform: skew(0.8deg);
    }
    45% {
        clip: rect(85px, 9999px, 72px, 0);
        transform: skew(0.9deg);
    }
    50% {
        clip: rect(71px, 9999px, 75px, 0);
        transform: skew(0.4deg);
    }
    55% {
        clip: rect(2px, 9999px, 48px, 0);
        transform: skew(0.1deg);
    }
    60% {
        clip: rect(30px, 9999px, 16px, 0);
        transform: skew(0.6deg);
    }
    65% {
        clip: rect(59px, 9999px, 50px, 0);
        transform: skew(0.2deg);
    }
    70% {
        clip: rect(41px, 9999px, 33px, 0);
        transform: skew(0.7deg);
    }
    75% {
        clip: rect(34px, 9999px, 29px, 0);
        transform: skew(0.4deg);
    }
    80% {
        clip: rect(22px, 9999px, 67px, 0);
        transform: skew(0.6deg);
    }
    85% {
        clip: rect(45px, 9999px, 94px, 0);
        transform: skew(0.3deg);
    }
    90% {
        clip: rect(38px, 9999px, 89px, 0);
        transform: skew(0.5deg);
    }
    95% {
        clip: rect(91px, 9999px, 81px, 0);
        transform: skew(0.2deg);
    }
    100% {
        clip: rect(6px, 9999px, 3px, 0);
        transform: skew(0.4deg);
    }
}

@keyframes glitch-skew {
    0% {
        transform: skew(2deg);
    }
    10% {
        transform: skew(-1deg);
    }
    20% {
        transform: skew(0deg);
    }
    30% {
        transform: skew(1deg);
    }
    40% {
        transform: skew(-1deg);
    }
    50% {
        transform: skew(0deg);
    }
    60% {
        transform: skew(-2deg);
    }
    70% {
        transform: skew(0deg);
    }
    80% {
        transform: skew(-1deg);
    }
    90% {
        transform: skew(2deg);
    }
    100% {
        transform: skew(1deg);
    }
}

/* ===== DARK MODE ANIMATIONS ===== */

@media (prefers-color-scheme: dark) {
    .animate-glow {
        animation: glowDark 2s ease-in-out infinite;
    }
    
    @keyframes glowDark {
        0%, 100% {
            box-shadow: 0 0 5px rgba(147, 197, 253, 0.5);
        }
        50% {
            box-shadow: 0 0 20px rgba(147, 197, 253, 0.8), 0 0 30px rgba(147, 197, 253, 0.6);
        }
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.will-change-auto {
    will-change: auto;
}

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

@media (prefers-reduced-motion: reduce) {
    .animate-fade-in,
    .animate-slide-in-right,
    .animate-slide-in-left,
    .animate-slide-in-up,
    .animate-slide-in-down,
    .animate-scale-in,
    .animate-bounce,
    .animate-pulse,
    .animate-shake,
    .animate-spin,
    .animate-glow,
    .animate-modal,
    .animate-progress,
    .animate-typing {
        animation: none !important;
    }
    
    .transition-all,
    .transition-fast,
    .transition-slow {
        transition: none !important;
    }
}

/* Focus indicators for keyboard navigation */
.focus-visible:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    animation: pulse 1s ease-in-out;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .animate-glow {
        animation: none;
        border: 2px solid currentColor;
    }
    
    .gradient-text {
        background: none;
        -webkit-text-fill-color: currentColor;
        color: currentColor;
    }
}