/**
 * AI Auto Tool - UI Optimizations & Performance Enhancements
 * 
 * CSS optimizations for better UI/UX including loading states,
 * skeleton screens, smooth transitions, and performance improvements
 * 
 * @package AI Auto Tool
 * @version 2.3.0
 */

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

/* Enable GPU acceleration for animations */
.aiautotool-transition,
.aiautotool-button,
.aiautotool-card,
.ft-submit {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Optimize rendering with contain property */
.aiautotool-container,
.aiautotool-card,
.ft-card {
    contain: layout style paint;
}

/* Reduce repaints on scroll */
.aiautotool-scroll-container {
    transform: translateZ(0);
}

/* ============================================
   LOADING STATES & SKELETON SCREENS
   ============================================ */

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

.aiautotool-skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0px,
        #e8e8e8 40px,
        #f0f0f0 80px
    );
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    min-height: 20px;
}

.aiautotool-skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.aiautotool-skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1em;
}

.aiautotool-skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: 6px;
}

.aiautotool-skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

/* Loading spinner optimized with GPU acceleration */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.aiautotool-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 135, 92, 0.2);
    border-top-color: var(--aiautotool-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    will-change: transform;
}

.aiautotool-spinner-large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* Pulse animation for loading states */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.aiautotool-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================
   SMOOTH TRANSITIONS & ANIMATIONS
   ============================================ */

/* Standard transition duration */
:root {
    --transition-fast: 0.15s;
    --transition-normal: 0.3s;
    --transition-slow: 0.5s;
    --easing-standard: cubic-bezier(0.4, 0, 0.2, 1);
    --easing-decelerate: cubic-bezier(0, 0, 0.2, 1);
    --easing-accelerate: cubic-bezier(0.4, 0, 1, 1);
}

/* Smooth transitions for interactive elements */
.aiautotool-button,
.ft-submit,
.ft-input-big,
.aiautotool-card,
.api-key-status {
    transition: all var(--transition-normal) var(--easing-standard);
}

/* Hover effects with smooth transitions */
.aiautotool-button:hover,
.ft-submit:hover {
    transform: translateY(-2px) translateZ(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.aiautotool-button:active,
.ft-submit:active {
    transform: translateY(0) translateZ(0);
    transition-duration: var(--transition-fast);
}

/* Focus states with smooth transitions */
.ft-input-big:focus,
input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--aiautotool-color);
    box-shadow: 0 0 0 3px rgba(0, 135, 92, 0.1);
    transition: all var(--transition-normal) var(--easing-standard);
}

/* ============================================
   FADE IN ANIMATIONS
   ============================================ */

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

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

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

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

.aiautotool-fade-in {
    animation: fadeIn var(--transition-normal) var(--easing-standard);
}

.aiautotool-fade-in-up {
    animation: fadeInUp var(--transition-slow) var(--easing-decelerate);
}

.aiautotool-fade-in-down {
    animation: fadeInDown var(--transition-slow) var(--easing-decelerate);
}

.aiautotool-slide-in-right {
    animation: slideInRight var(--transition-normal) var(--easing-standard);
}

/* Stagger animation for lists */
.aiautotool-stagger > * {
    animation: fadeInUp var(--transition-slow) var(--easing-decelerate) backwards;
}

.aiautotool-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.aiautotool-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.aiautotool-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.aiautotool-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.aiautotool-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.aiautotool-stagger > *:nth-child(n+6) { animation-delay: 0.3s; }

/* ============================================
   IMPROVED LOADING OVERLAYS
   ============================================ */

.aiautotool-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal) var(--easing-standard);
}

.aiautotool-loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.aiautotool-loading-content {
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    min-width: 200px;
    animation: fadeInUp var(--transition-normal) var(--easing-decelerate);
}

.aiautotool-loading-content .aiautotool-spinner {
    margin: 0 auto 15px;
}

.aiautotool-loading-content h3 {
    margin: 0 0 10px;
    font-size: 18px;
    color: var(--text-primary);
}

.aiautotool-loading-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================
   LAZY LOADING FOR IMAGES
   ============================================ */

img[data-src] {
    opacity: 0;
    transition: opacity var(--transition-normal) var(--easing-standard);
}

img[data-src].loaded,
img.loaded {
    opacity: 1;
}

/* Placeholder for images while loading */
img[data-src]::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    border-radius: 4px;
}

/* ============================================
   TOOLTIP ENHANCEMENTS
   ============================================ */

.aiautotool-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.aiautotool-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    padding: 8px 12px;
    background: #333;
    color: #fff;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast) var(--easing-standard),
                transform var(--transition-fast) var(--easing-standard);
    z-index: 1000;
}

.aiautotool-tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

/* ============================================
   RESPONSIVE IMPROVEMENTS
   ============================================ */

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

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

.aiautotool-card-hover {
    transition: all var(--transition-normal) var(--easing-standard);
}

.aiautotool-card-hover:hover {
    transform: translateY(-4px) translateZ(0);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ============================================
   BUTTON STATES
   ============================================ */

.aiautotool-button-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.aiautotool-button-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.aiautotool-progress {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.aiautotool-progress-bar {
    height: 100%;
    background: var(--gradient);
    transition: width var(--transition-normal) var(--easing-standard);
    will-change: width;
}

/* ============================================
   NOTIFICATION TOASTS
   ============================================ */

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

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

.aiautotool-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    animation: slideInNotification var(--transition-normal) var(--easing-standard);
    max-width: 400px;
}

.aiautotool-notification.hide {
    animation: slideOutNotification var(--transition-fast) var(--easing-accelerate) forwards;
}

.aiautotool-notification-success {
    border-left: 4px solid #28a745;
}

.aiautotool-notification-error {
    border-left: 4px solid #dc3545;
}

.aiautotool-notification-warning {
    border-left: 4px solid #ffc107;
}

.aiautotool-notification-info {
    border-left: 4px solid #17a2b8;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

.aiautotool-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.aiautotool-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.aiautotool-scrollbar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
    transition: background var(--transition-fast) var(--easing-standard);
}

.aiautotool-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

