/**
 * Wali Wheels - Site Optimizations CSS
 * Ottimizzazioni globali per prestazioni, accessibilità e interattività
 * Versione 1.0 - Ottimizzazioni Complete
 */

/* ===== OTTIMIZZAZIONI ACCESSIBILITÀ ===== */

/* Skip to content link - Moderno e accessibile */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: white;
    padding: 12px 20px;
    text-decoration: none;
    border-radius: 8px;
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.skip-link:focus {
    top: 6px;
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* Miglioramenti layout generale */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Spaziature moderne e consistenti */
.section-spacing {
    padding: 80px 0;
}

.section-spacing-sm {
    padding: 60px 0;
}

.section-spacing-lg {
    padding: 120px 0;
}

/* Grid system moderno */
.grid-modern {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-modern-sm {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-modern-lg {
    display: grid;
    gap: 3rem;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

/* Focus management */
.focus-visible {
    outline: 3px solid #40E0D0 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 3px rgba(64, 224, 208, 0.3) !important;
}

/* Keyboard navigation indicator */
.keyboard-navigation *:focus {
    outline: 3px solid #40E0D0 !important;
    outline-offset: 2px !important;
}

/* Screen reader only content */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ===== OTTIMIZZAZIONI PRESTAZIONI ===== */

/* Lazy loading images */
img.lazy {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img.lazy.loaded {
    opacity: 1;
}

/* Image placeholders */
.image-placeholder {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.2rem;
    min-height: 200px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Theme color for supported browsers */
:root {
    --theme-color: #0f172a;
}

meta[name="theme-color"] {
    content: var(--theme-color);
}

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

/* ===== OTTIMIZZAZIONI INTERATTIVITÀ ===== */

/* Microinteractions avanzate */
.interactive-element {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.interactive-element:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Effetto ripple moderno */
.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::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;
    pointer-events: none;
}

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

/* Effetto magnetico per pulsanti */
.magnetic-effect {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Animazioni di entrata fluide */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

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

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

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

/* Loading states eleganti */
.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; }
}

/* Toast notifications moderne */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    border-left: 4px solid #40E0D0;
}

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

/* Floating action button */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #40E0D0, #36c9b0);
    color: white;
    border: none;
    box-shadow: 0 8px 25px rgba(64, 224, 208, 0.4);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(64, 224, 208, 0.6);
}

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

.interactive-element:active {
    transform: translateY(0) scale(0.98);
}

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

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.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 currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    max-width: 400px;
}

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

.toast-success {
    background: linear-gradient(135deg, #40E0D0 0%, #36c9b0 100%);
}

.toast-error {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
}

.toast-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.toast-warning {
    background: linear-gradient(135deg, #feca57 0%, #ff9ff3 100%);
}

/* ===== OTTIMIZZAZIONI FORM ===== */

/* Form validation styles */
.form-field {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: #40E0D0;
    box-shadow: 0 0 0 3px rgba(64, 224, 208, 0.1);
}

.form-field.error input,
.form-field.error textarea,
.form-field.error select {
    border-color: #ff6b6b;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.field-error {
    color: #ff6b6b;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-error::before {
    content: '⚠️';
    font-size: 1rem;
}

/* Form auto-save indicator */
.form-autosave {
    position: relative;
}

.form-autosave::after {
    content: '💾 Salvato automaticamente';
    position: absolute;
    top: -30px;
    right: 0;
    background: #40E0D0;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.form-autosave.saving::after {
    content: '💾 Salvando...';
    opacity: 1;
}

.form-autosave.saved::after {
    content: '✅ Salvato!';
    opacity: 1;
}

/* ===== OTTIMIZZAZIONI NAVIGAZIONE ===== */

/* Page transitions */
.page-transition {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.page-transition.entered {
    opacity: 1;
    transform: translateY(0);
}

/* Smooth page loading */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.page-loading.show {
    opacity: 1;
    visibility: visible;
}

.page-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #40E0D0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===== OTTIMIZZAZIONI IMMAGINI ===== */

/* WebP support */
.webp-supported .webp-image {
    display: block;
}

.webp-supported .fallback-image {
    display: none;
}

.webp-supported .webp-image {
    display: none;
}

.webp-supported .fallback-image {
    display: block;
}

/* Progressive image loading */
.progressive-image {
    position: relative;
    overflow: hidden;
}

.progressive-image img {
    transition: opacity 0.3s ease;
}

.progressive-image img.loading {
    opacity: 0;
}

.progressive-image img.loaded {
    opacity: 1;
}

.progressive-image .placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.2rem;
}

/* ===== OTTIMIZZAZIONI RESPONSIVE ===== */

/* Mobile-first approach */
@media (max-width: 768px) {
    .toast {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .form-field input,
    .form-field textarea,
    .form-field select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .skip-link {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .interactive-element:hover {
        transform: translateY(-1px) scale(1.01);
    }
}

/* Desktop optimizations */
@media (min-width: 1025px) {
    .interactive-element:hover {
        transform: translateY(-3px) scale(1.03);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .image-placeholder {
        background-image: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    }
}

/* ===== OTTIMIZZAZIONI ANIMAZIONI ===== */

/* Entrance animations */
.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
}

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

.slide-up {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s ease;
}

.slide-up.entered {
    opacity: 1;
    transform: translateY(0);
}

.scale-in {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s ease;
}

.scale-in.entered {
    opacity: 1;
    transform: scale(1);
}

/* Staggered animations */
.stagger-children > * {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.stagger-children.entered > * {
    opacity: 1;
    transform: translateY(0);
}

.stagger-children.entered > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.entered > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.entered > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.entered > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.entered > *:nth-child(5) { transition-delay: 0.5s; }

/* ===== OTTIMIZZAZIONI ACCESSIBILITÀ AVANZATE ===== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .interactive-element {
        border: 2px solid currentColor;
    }
    
    .form-field input,
    .form-field textarea,
    .form-field select {
        border-width: 3px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .image-placeholder {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        color: #ecf0f1;
    }
    
    .toast {
        background: #2c3e50;
        color: #ecf0f1;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .fade-in,
    .slide-up,
    .scale-in,
    .interactive-element {
        transition: none;
        animation: none;
    }
    
    .interactive-element:hover {
        transform: none;
    }
}

/* ===== OTTIMIZZAZIONI PERFORMANCE ===== */

/* Hardware acceleration */
.hardware-accelerated {
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* Optimized transforms */
.optimized-transform {
    transform: translate3d(0, 0, 0);
    will-change: transform;
}

/* Efficient animations */
.efficient-animation {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* ===== OTTIMIZZAZIONI DEBUG ===== */

/* Performance monitoring */
.performance-indicator {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: monospace;
    z-index: 1000;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.performance-indicator:hover {
    opacity: 1;
}

/* Error boundary styling */
.error-boundary {
    border: 2px solid #ff6b6b;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    background: rgba(255, 107, 107, 0.1);
}

.error-boundary h3 {
    color: #ff6b6b;
    margin: 0 0 0.5rem 0;
}

.error-boundary pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.875rem;
}

/* ===== OTTIMIZZAZIONI FINALI ===== */

/* Print styles */
@media print {
    .skip-link,
    .toast,
    .performance-indicator,
    .interactive-element:hover {
        display: none !important;
    }
    
    .page-transition {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Focus visible for all browsers */
*:focus-visible {
    outline: 3px solid #40E0D0 !important;
    outline-offset: 2px !important;
}

/* Ensure proper contrast ratios */
.text-high-contrast {
    color: #000;
    background: #fff;
}

.text-high-contrast.dark {
    color: #fff;
    background: #000;
}

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

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

/* Optimized hover states */
@media (hover: hover) {
    .hover-effect:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
}

@media (hover: none) {
    .hover-effect:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Touch device optimizations */
@media (pointer: coarse) {
    .touch-target {
        min-height: 44px;
        min-width: 44px;
    }
    
    .touch-friendly {
        padding: 12px 16px;
        margin: 8px 0;
    }
}

/* Pagine legali - desktop e mobile */
.legal-content {
    min-height: 60vh;
}
.legal-content .back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s;
}
.legal-content .back-link:hover {
    color: #00ff88;
}
.legal-article {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
}
.legal-article h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.legal-article h2 {
    font-size: 1.35rem;
    margin: 2rem 0 1rem;
}
.legal-article p {
    margin-bottom: 1rem;
    line-height: 1.7;
}
.legal-updated {
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    margin-bottom: 2rem !important;
}
@media (max-width: 768px) {
    .legal-article {
        padding: 1.5rem 1rem;
    }
    .legal-article h1 { font-size: 1.75rem; }
    .legal-article h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
}







