/* ========================================
   COMPREHENSIVE INTERACTIVE ANIMATION SYSTEM
   For CAR2U CAR RENTALS JITRA
   Enhanced for Maximum User Engagement
   ======================================== */

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

/* Interactive Hover States for All Elements */
* {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Interactive Links */
a {
    position: relative;
    transition: all 0.3s ease;
}

a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transition: width 0.3s ease;
}

a:hover::after {
    width: 100%;
}

/* Interactive Buttons */
button, .btn, input[type="submit"], input[type="button"] {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button::before, .btn::before, input[type="submit"]::before, input[type="button"]::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 ease;
}

button:hover::before, .btn:hover::before, input[type="submit"]:hover::before, input[type="button"]:hover::before {
    left: 100%;
}

/* Interactive Cards */
.card, .car-card, .animated-card {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.card:hover::before, .car-card:hover::before, .animated-card:hover::before {
    left: 100%;
}

/* Interactive Images */
img {
    transition: all 0.3s ease;
}

img:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Interactive Form Elements */
input, textarea, select {
    transition: all 0.3s ease;
    position: relative;
}

input:focus, textarea:focus, select:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

/* Interactive Navigation */
.nav-links a {
    position: relative;
    transition: all 0.3s ease;
}

.nav-links a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
    transition: width 0.3s ease;
    z-index: -1;
}

.nav-links a:hover::before {
    width: 100%;
}

.nav-links a:hover {
    transform: translateY(-2px);
    color: #3b82f6;
}

/* ========================================
   HEADER ANIMATIONS
   ======================================== */

/* Subtle Header Entry Animation */
.site-topbar {
    animation: headerSlideIn 0.6s ease-out;
}

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

/* Logo Gentle Animation */
.brand {
    animation: logoFadeIn 0.8s ease-out 0.2s both;
}

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

/* Navigation Links Staggered Animation */
.nav-links a {
    animation: navLinkFadeIn 0.5s ease-out both;
}

.nav-links a:nth-child(1) { animation-delay: 0.3s; }
.nav-links a:nth-child(2) { animation-delay: 0.4s; }
.nav-links a:nth-child(3) { animation-delay: 0.5s; }
.nav-links a:nth-child(4) { animation-delay: 0.6s; }
.nav-links a:nth-child(5) { animation-delay: 0.7s; }

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

/* Enhanced Link Hover Effects */
.nav-links a {
    position: relative;
    transition: all 0.3s ease;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transition: width 0.3s ease;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-links a:hover {
    transform: translateY(-2px);
    color: #3b82f6;
}

/* User Profile Gentle Animation */
.user-profile, .profile-section {
    animation: profileSlideIn 0.6s ease-out 0.4s both;
}

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

/* Button Hover Enhancement */
.btn, button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn::before, button::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 ease;
}

.btn:hover::before, button:hover::before {
    left: 100%;
}

.btn:hover, button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

/* ========================================
   TEXT ANIMATIONS
   ======================================== */

/* Typing Animation */
@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--primary, #3b82f6); }
}

.typing-animation {
    overflow: hidden;
    border-right: 2px solid var(--primary, #3b82f6);
    white-space: nowrap;
    margin: 0 auto;
    animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

/* Text Glow Animation */
@keyframes textGlow {
    0%, 100% { 
        text-shadow: 0 0 5px rgba(59, 130, 246, 0.3), 0 0 10px rgba(59, 130, 246, 0.2);
    }
    50% { 
        text-shadow: 0 0 10px rgba(59, 130, 246, 0.6), 0 0 20px rgba(59, 130, 246, 0.4), 0 0 30px rgba(59, 130, 246, 0.2);
    }
}

.text-glow {
    animation: textGlow 3s ease-in-out infinite;
}

/* Text Slide In Animation */
@keyframes slideInFromLeft {
    0% { 
        transform: translateX(-100px); 
        opacity: 0; 
    }
    100% { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

@keyframes slideInFromRight {
    0% { 
        transform: translateX(100px); 
        opacity: 0; 
    }
    100% { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

@keyframes slideInFromTop {
    0% { 
        transform: translateY(-50px); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

@keyframes slideInFromBottom {
    0% { 
        transform: translateY(50px); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

.slide-in-left {
    animation: slideInFromLeft 0.8s ease-out;
}

.slide-in-right {
    animation: slideInFromRight 0.8s ease-out;
}

.slide-in-top {
    animation: slideInFromTop 0.8s ease-out;
}

.slide-in-bottom {
    animation: slideInFromBottom 0.8s ease-out;
}

/* Text Fade In Animation */
@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    0% {
        opacity: 0;
        transform: translateY(-30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    0% {
        opacity: 0;
        transform: translateX(-30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    0% {
        opacity: 0;
        transform: translateX(30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.8s ease-out;
}

.fade-in-down {
    animation: fadeInDown 0.8s ease-out;
}

.fade-in-left {
    animation: fadeInLeft 0.8s ease-out;
}

.fade-in-right {
    animation: fadeInRight 0.8s ease-out;
}

/* Text Bounce Animation */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Text Pulse Animation */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

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

/* ========================================
   BUTTON ANIMATIONS
   ======================================== */

/* Button Hover Effects */
@keyframes buttonShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

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

@keyframes buttonBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Enhanced Button Styles */
.animated-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    background-size: 200% 200%;
    animation: buttonShimmer 3s ease-in-out infinite;
}

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

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

.animated-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
    animation: buttonGlow 1.5s ease-in-out infinite;
}

.animated-btn:active {
    transform: translateY(-1px) scale(1.02);
    animation: buttonBounce 0.6s ease;
}

/* Button Loading Animation */
@keyframes buttonLoading {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: buttonLoading 1s linear infinite;
}

/* ========================================
   CARD ANIMATIONS
   ======================================== */

/* Card Hover Effects */
@keyframes cardFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes cardGlow {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 8px 25px rgba(59, 130, 246, 0.2), 0 12px 35px rgba(0, 0, 0, 0.15);
    }
}

.animated-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

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

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

.animated-card:hover {
    transform: translateY(-8px) scale(1.02);
    animation: cardGlow 2s ease-in-out infinite;
}

/* Card Entrance Animation */
@keyframes cardSlideIn {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-entrance {
    animation: cardSlideIn 0.6s ease-out;
}

/* ========================================
   FORM ANIMATIONS
   ======================================== */

/* Input Focus Animation */
@keyframes inputFocus {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    100% {
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    }
}

.animated-input {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.animated-input:focus {
    animation: inputFocus 0.3s ease-out;
    transform: translateY(-2px);
}

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

.input-error {
    animation: shake 0.5s ease-in-out;
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* ========================================
   LOADING ANIMATIONS
   ======================================== */

/* Spinner Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(59, 130, 246, 0.1);
    border-left: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Dots Loading Animation */
@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;
    }
}

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

/* ========================================
   BACKGROUND ANIMATIONS
   ======================================== */

/* Floating Elements */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes floatReverse {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(20px);
    }
}

.floating {
    animation: float 6s ease-in-out infinite;
}

.floating-reverse {
    animation: floatReverse 6s ease-in-out infinite;
}

/* Gradient Background Animation */
@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.gradient-bg {
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* ========================================
   SCROLL ANIMATIONS
   ======================================== */

/* Reveal on Scroll */
.reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

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

/* Animation Delays */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* Animation Durations */
.duration-fast { animation-duration: 0.3s; }
.duration-normal { animation-duration: 0.6s; }
.duration-slow { animation-duration: 1s; }

/* Animation Iterations */
.animate-once { animation-iteration-count: 1; }
.animate-infinite { animation-iteration-count: infinite; }

/* Hover Pause */
.pause-on-hover:hover {
    animation-play-state: paused;
}

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

@media (max-width: 768px) {
    .animated-btn:hover {
        transform: translateY(-2px) scale(1.02);
    }
    
    .animated-card:hover {
        transform: translateY(-4px) scale(1.01);
    }
    
    .slide-in-left,
    .slide-in-right {
        animation: slideInFromTop 0.8s ease-out;
    }
}

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

/* ========================================
   CUSTOM ANIMATIONS FOR CAR2U
   ======================================== */

/* Car Icon Animation */
@keyframes carDrive {
    0% { transform: translateX(-100px) rotate(0deg); }
    50% { transform: translateX(0) rotate(5deg); }
    100% { transform: translateX(100px) rotate(0deg); }
}

.car-driving {
    animation: carDrive 3s ease-in-out infinite;
}

/* Rental Badge Animation */
@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
}

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

/* Success Checkmark Animation */
@keyframes checkmarkDraw {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.checkmark-draw {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: checkmarkDraw 0.6s ease-in-out forwards;
}

/* Price Highlight Animation */
@keyframes priceHighlight {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(16, 185, 129, 0.1);
    }
}

.price-highlight {
    animation: priceHighlight 2s ease-in-out infinite;
}

/* ========================================
   SCROLL-TRIGGERED ANIMATIONS
   ======================================== */

/* Reveal on Scroll with Intersection Observer */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-on-scroll.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered Animation for Lists */
.stagger-item {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger-item.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   INTERACTIVE FEEDBACK ANIMATIONS
   ======================================== */

/* Click Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::after {
    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%);
    animation: ripple 0.6s ease-out;
}

/* Success Feedback */
@keyframes successBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.success-feedback {
    animation: successBounce 0.6s ease-in-out;
}

/* Error Feedback */
@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.error-feedback {
    animation: errorShake 0.5s ease-in-out;
}

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

/* Skeleton Loading */
@keyframes skeleton {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

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

/* ========================================
   MICRO-INTERACTIONS
   ======================================== */

/* Hover Lift Effect */
.hover-lift {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Scale on Hover */
.hover-scale {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Rotate on Hover */
.hover-rotate {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* Glow Effect */
.hover-glow {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

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

/* Page Enter Animation */
@keyframes pageEnter {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-enter {
    animation: pageEnter 0.6s ease-out;
}

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

/* Focus Indicators */
.focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Reduced Motion Support */
@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;
    }
}

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

/* GPU Acceleration for Smooth Animations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Optimize for Mobile */
@media (max-width: 768px) {
    .animated-btn:hover {
        transform: translateY(-2px) scale(1.02);
    }
    
    .animated-card:hover {
        transform: translateY(-4px) scale(1.01);
    }
    
    .hover-lift:hover {
        transform: translateY(-3px);
    }
}
