/* Critical Fixes for Blue Messaggio Website */

/* 1. Prevent flickering by preloading fonts and optimizing animations */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 2. Optimize page load to prevent FOUC (Flash of Unstyled Content) */
html {
    visibility: visible;
    opacity: 1;
}

/* 3. Fix Font Awesome icons not loading */
.footer-social .social-links a i,
.social-links a i {
    font-family: 'Font Awesome 6 Brands' !important;
    font-weight: 400;
    font-style: normal;
    display: inline-block;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

/* Ensure all Font Awesome icons render properly */
.fab, .fas, .far, .fal, .fad {
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
}

/* 4. Fix footer social icons specifically */
.footer-social .social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.footer-social .social-links a {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: var(--white);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.footer-social .social-links a:hover {
    background: var(--logo-yellow);
    color: var(--primary-color);
    transform: translateY(-3px);
}

/* 5. Reduce animation flickering */
.tab-item,
.service-card,
.feature-card,
.partner-item {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* 6. Smooth tab transitions without flickering */
.tab-pane {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    will-change: opacity;
}

.tab-pane.active {
    opacity: 1;
    visibility: visible;
    position: relative;
}

/* 7. Fix tabs container layout */
.tabs-right {
    position: relative;
    min-height: 400px;
}

/* 8. Optimize hero section to prevent layout shift */
.hero {
    min-height: 600px;
}

.hero-content {
    min-height: 500px;
}

/* 9. Fix chat widget icon */
.chat-widget-button i {
    font-family: 'Font Awesome 6 Free' !important;
    font-weight: 900;
}

/* 10. Prevent CLS (Cumulative Layout Shift) */
img {
    max-width: 100%;
    height: auto;
}

.hero-image img {
    aspect-ratio: 16/9;
    object-fit: contain;
}

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

/* 12. Fix header flickering on scroll */
header {
    will-change: transform, box-shadow;
    backface-visibility: hidden;
}

/* 13. Optimize dropdown menu transitions */
.dropdown-menu {
    will-change: opacity, transform;
    backface-visibility: hidden;
}

/* 14. Fix mobile menu flickering */
@media (max-width: 768px) {
    .nav-links {
        will-change: opacity, transform;
        backface-visibility: hidden;
    }
}

/* 15. Improve overall performance */
.container,
.container-large-v2 {
    contain: layout style;
}

/* 16. Fix service cards hover effect */
.service-card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 17. Optimize animations for better performance */
@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;
    }
}

/* 18. Fix footer layout on mobile */
@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }
    
    .footer-social .social-links {
        justify-content: center;
    }
}

/* 19. Ensure proper z-index stacking */
.contact-info {
    z-index: 1001;
}

header {
    z-index: 1000;
}

.chat-widget,
.chat-widget-button {
    z-index: 999;
}

/* 20. Fix comparison table responsiveness */
.comparison-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.comparison-table table {
    min-width: 100%;
    width: max-content;
}

/* 21. Professional touch - Add subtle shadows */
.service-card,
.feature-card,
.partner-item {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.service-card:hover,
.feature-card:hover,
.partner-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* 22. Fix hero stats alignment */
.hero-stats {
    display: flex;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.hero-stat {
    flex: 1;
    min-width: 120px;
}

/* 23. Improve CTA buttons */
.hero-cta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.cta-button-primary,
.cta-button-secondary {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 24. Fix logo display */
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-symbol {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* 25. Ensure consistent spacing */
section {
    padding: 4rem 0;
}

@media (max-width: 768px) {
    section {
        padding: 2rem 0;
    }
}

/* 26. Fix tab progress animation */
.tab-progress {
    position: relative;
    overflow: hidden;
}

.tab-item.active .tab-progress::after {
    animation: progress 5s linear forwards;
}

/* 27. Improve readability */
body {
    line-height: 1.6;
    letter-spacing: 0.01em;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    letter-spacing: -0.02em;
}

/* 28. Fix button states */
button,
.btn,
.cta-button {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

button:disabled,
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* 29. Improve form inputs */
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* 30. Fix mobile touch targets */
@media (max-width: 768px) {
    a,
    button,
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
}
