/**
 * DealEngineAI Micro-Interactions
 * Enhanced user engagement through smooth animations and feedback
 */

/* ===== BUTTON MICRO-INTERACTIONS ===== */
.btn, .cta-button, .header-cta {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0); /* Hardware acceleration */
    will-change: transform, box-shadow;
}

/* Ripple effect on click */
.btn::before, .cta-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    pointer-events: none;
    z-index: 1;
}

.btn:active::before, .cta-button:active::before {
    width: 300px;
    height: 300px;
}

/* Button hover states with micro-movements */
.btn:hover, .cta-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn:active, .cta-button:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s;
}

/* Pulse animation for primary CTAs */
.cta-button.cta-green, .header-cta {
    animation: subtle-pulse 3s infinite;
}

@keyframes subtle-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
}

/* ===== CARD MICRO-INTERACTIONS ===== */
.card, .endpoint, .feature-card, .pricing-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.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.5s;
    pointer-events: none;
    z-index: 1;
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

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

/* ===== FORM MICRO-INTERACTIONS ===== */
.form-control, .form-select {
    transition: all 0.3s ease;
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    background: #ffffff;
}

.form-control:focus, .form-select:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    transform: scale(1.02);
    outline: none;
}

/* Floating label animation */
.form-floating {
    position: relative;
}

.form-floating label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 12px 16px;
    pointer-events: none;
    transform-origin: left top;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #64748b;
}

.form-floating input:focus + label,
.form-floating input:not(:placeholder-shown) + label {
    transform: translateY(-20px) scale(0.8);
    color: #10b981;
    background: #ffffff;
    padding: 0 8px;
}

/* Input validation feedback */
.form-control.is-valid {
    border-color: #10b981;
    animation: success-shake 0.5s ease-in-out;
}

.form-control.is-invalid {
    border-color: #ef4444;
    animation: error-shake 0.5s ease-in-out;
}

@keyframes success-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

/* ===== LOADING STATES ===== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

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

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

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

/* Progress bar animation */
.progress-bar {
    position: relative;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 2px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== NAVIGATION MICRO-INTERACTIONS ===== */
.nav-link {
    position: relative;
    transition: all 0.3s ease;
    padding: 8px 16px;
    border-radius: 6px;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: #10b981;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after {
    width: 80%;
}

.nav-link:hover {
    transform: translateY(-2px);
    background: rgba(16, 185, 129, 0.1);
}

/* Dropdown animation */
.dropdown-menu {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

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

.dropdown-item {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.dropdown-item::before {
    content: '';
    position: absolute;
    left: -100%;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.1), transparent);
    transition: left 0.5s;
}

.dropdown-item:hover::before {
    left: 100%;
}

.dropdown-item:hover {
    transform: translateX(8px);
    background: rgba(16, 185, 129, 0.05);
}

/* ===== TOGGLE SWITCHES ===== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: #10b981;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider:hover {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #10b981;
    transform: translateX(400px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    max-width: 400px;
}

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

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.warning {
    border-left-color: #f59e0b;
}

/* ===== SCROLL ANIMATIONS ===== */
.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.slide-in-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.slide-in-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* ===== TYPING ANIMATION ===== */
.typing-animation {
    overflow: hidden;
    border-right: 2px solid #10b981;
    white-space: nowrap;
    margin: 0 auto;
    animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

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

@keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: #10b981 }
}

/* ===== FLOATING ACTION BUTTON ===== */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 40px rgba(16, 185, 129, 0.5);
}

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

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

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

.skeleton-text {
    height: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 80%;
}

/* ===== INTERACTIVE ICONS ===== */
.icon-interactive {
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
}

.icon-interactive:hover {
    transform: scale(1.2) rotate(10deg);
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

/* ===== COUNT-UP ANIMATIONS ===== */
.counter {
    font-weight: bold;
    font-size: 2em;
    color: #10b981;
}

/* ===== SMOOTH SCROLLING ===== */
html {
    scroll-behavior: smooth;
}

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

/* Focus states for keyboard navigation */
.btn:focus,
.nav-link:focus,
.form-control:focus {
    outline: 2px solid #10b981;
    outline-offset: 2px;
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    .card:hover {
        transform: none; /* Disable hover effects on mobile */
    }
    
    .btn:hover {
        transform: none;
    }
    
    .fab {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}