/* ============================================
   RESPONSIVE DESIGN - SBL SERVICE
   ============================================ */

:root {
    --mobile-header-height: 180px;
}



/* Hamburger Menu - Modern Style */
.hamburger-menu {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 12px;
    z-index: 10001;
    background: transparent;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.hamburger-menu:hover {
    background: rgba(0, 180, 216, 0.08);
}

.hamburger-menu span {
    width: 26px;
    height: 3px;
    background: var(--secondary);
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
    background: var(--secondary);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
    background: var(--secondary);
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    right: 4%;
    width: 250px;
    max-width: 80vw;
    max-height: 85vh;
    height: auto;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(-15%) scale(0.95);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
    padding: 0;
}

/* Menu attivo */
.mobile-nav.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Lista link */
.mobile-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Lista elementi con effetto cascata */
.mobile-nav>ul>li {
    border-bottom: 1px solid var(--gray-100);
    opacity: 0;
    transform: translateY(10px);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Quando il menu è attivo, attiva la transizione per ogni link */
.mobile-nav.active>ul>li {
    opacity: 1;
    transform: translateY(0);
}

/* Delay progressivo per effetto cascata */
.mobile-nav.active>ul>li:nth-child(1) {
    transition-delay: 0.05s;
}

.mobile-nav.active>ul>li:nth-child(2) {
    transition-delay: 0.10s;
}

.mobile-nav.active>ul>li:nth-child(3) {
    transition-delay: 0.15s;
}

.mobile-nav.active>ul>li:nth-child(4) {
    transition-delay: 0.20s;
}

.mobile-nav.active>ul>li:nth-child(5) {
    transition-delay: 0.25s;
}

.mobile-nav.active>ul>li:nth-child(6) {
    transition-delay: 0.25s;
}

.mobile-nav.active>ul>li:nth-child(7) {
    transition-delay: 0.25s;
}

.mobile-nav.active>ul>li:nth-child(8) {
    transition-delay: 0.25s;
}

/* Aumenta i nth-child in base ai link che hai */

/* Link e dropdown toggle */
.mobile-nav>ul>li>a,
.mobile-dropdown-toggle {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.mobile-nav>ul>li>a:hover,
.mobile-dropdown-toggle:hover {
    background: var(--gray-50);
    color: var(--primary);
    padding-left: 2rem;
}

.mobile-nav>ul>li>a.active {
    color: var(--primary);
    background: var(--primary-lighter);
}

/* Mobile Dropdown */
.mobile-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--gray-50);
}

.mobile-nav li.active .mobile-dropdown {
    max-height: 500px;
}

.mobile-dropdown li a {
    display: block;
    padding: 0.8rem 1.5rem 0.8rem 2.5rem;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.mobile-dropdown li a:hover {
    background: white;
    color: var(--primary-dark);
    padding-left: 3rem;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Blocca scroll quando menu aperto */
body.menu-open {
    overflow: hidden;
}


/* ============================================
   DESKTOP RIDOTTO (968px - 1200px)
   ============================================ */
@media (max-width: 1200px) {

    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }

    /* Header adjustments - more conservative */
    .header-main {
        gap: 1rem;
        padding: 0.75rem 1.5rem;
    }

    .header-actions {
        padding: 0.6rem 1rem;
        margin-right: 0;
        gap: 0.8rem;
        flex: 0 1 auto;
    }

    .logo img {
        height: 120px;
        margin-left: 2rem;
    }

    .nav-links {
        gap: 0.4rem;
    }

    .nav-links>li>a {
        padding: 0.55rem 0.75rem;
        font-size: 0.95rem;
    }

    .cta-button {
        padding: 0.65rem 1.4rem;
        font-size: 0.9rem;
    }

    /* Hero section */
    .hero {
        min-height: 75vh;
    }

    .hero-content {
        gap: 3rem;
    }

    .hero-text {
        margin-top: 1rem;
    }

    .hero-text h1 {
        font-size: 3.2rem;
    }

    .hero-text h2 {
        font-size: 1.8rem;
    }

    .hero-text p {
        font-size: 1.1rem;
    }

    /* Hero buttons */
    .hero-buttons {
        margin-top: 2rem;
        gap: 0.8rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.85rem 2rem;
        font-size: 1rem;
    }

    /* Text section (after hero) */
    .intro-wrapper .hero-text {
        padding: 0 2rem;
    }

    .intro-wrapper .hero-text h2 {
        font-size: 1.9rem;
    }

    .intro-wrapper .hero-text p {
        font-size: 1.1rem;
        max-width: 950px;
    }

    /* Visual cards */
    .visual-grid {
        gap: 1.25rem;
    }

    .services-grid {
        gap: 1.5rem;
    }

    /* Carousel */
    .carousel-img {
        height: 460px;
    }

    .carousel-caption {
        padding: 1.2rem 2.5rem;
        width: 75%;
    }

    .carousel-caption h3 {
        font-size: 1.7rem;
    }

    .carousel-caption p {
        font-size: 1rem;
    }

    /* Carousel navigation */
    .prev,
    .next {
        width: 42px !important;
        height: 42px !important;
        font-size: 19px !important;
    }

    .carousel-dots {
        bottom: 18px !important;
    }

    .dot {
        width: 13px !important;
        height: 13px !important;
        margin: 0 5px !important;
    }

    /*Info aziendali*/
    .info-tabs-container .tab-content-area {
        width: 700px;
    }

    .info-tabs-container .tabs-nav {
        flex: 0 0 180px;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
}

/* ============================================
   TABLET (768px - 992px)
   ============================================ */
@media (max-width: 992px) {

    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }

    .hamburger-menu {
        display: flex !important;
    }

    .mobile-nav {
        display: block;

    }

    .mobile-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        margin-top: 0;
        display: block !important;
    }

    /* Gradient adjustment text ending */
    .intro-bg,
    .intro-bgGradient {
        height: 83vh !important;
        min-height: 600px;
    }

    /* Hide desktop navigation */
    .nav-container {
        display: none !important;
    }

    .header-main {
        padding: 1rem 0.5rem 1rem 1.5rem !important;
        flex-wrap: nowrap;
    }

    .header-actions {
        display: none !important;
    }

    /* Contenitore per loghi + hamburger menu su tablet */
    .logo-and-menu {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 2rem;
        width: 100%;
        flex: 1;
    }

    .logo {
        gap: 1rem !important;
        flex: 0 0 auto;
    }

    .logo img {
        height: 140px !important;
    }

    .hamburger-menu {
        flex: 0 0 auto;
        margin-right: 2rem;
        /* New Aesthetics */
        width: 60px;
        height: 60px;
        border-radius: var(--radius-md);
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 6px;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .hamburger-menu:hover {
        background: var(--gray-50);
        border-color: var(--primary);
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }

    .hamburger-menu span {
        width: 32px;
        height: 4px;
        background-color: var(--secondary);
        border-radius: 4px;
        display: block;
        transition: all 0.3s;
        transform-origin: center;
    }

    .hamburger-menu:hover span {
        background-color: var(--primary-dark);
    }

    /* Animation Active State */
    .hamburger-menu.active {
        box-shadow: var(--shadow-md);
    }

    .hamburger-menu.active span:nth-child(2) {
        opacity: 0;
        transform: translateX(10px);
    }

    .hamburger-menu.active span:nth-child(1) {
        transform: translateY(10px) rotate(45deg);
    }

    .hamburger-menu.active span:nth-child(3) {
        transform: translateY(-10px) rotate(-45deg);
    }

    .hero {
        margin-top: 50px;
        min-height: 60vh;
        padding: 2rem 0;
    }

    .hero-content {
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    .hero-text {
        text-align: center;
        padding: 1rem 5rem !important;
    }

    .hero-text h1 {
        font-size: 64px !important;
        /* Forced px */
        line-height: 1.1;
    }

    .hero-text h2 {
        font-size: 40px !important;
        /* Forced px */
        margin-bottom: 1.5rem;
    }

    .hero-text p {
        font-size: 1.5rem !important;
        line-height: 1.6;
    }

    .hero-buttons {
        justify-content: center;
        gap: 0.8rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.85rem 3.5rem !important;
        /* Allargati */
        font-size: 1rem !important;
        min-width: 220px;
        /* Min width added */
        text-align: center;
    }

    /* Reduce spacing for non-home pages */
    .hero:not(#home) {
        margin-top: 20px !important;
        padding-top: 1rem !important;
    }

    /* Ensure Home keeps its spacing */
    #home.hero {
        margin-top: 50px !important;
        padding-top: 2rem !important;
    }

    /* Web.html Technologies Grid */
    .tech-grid-container {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
        /* Reduced gap */
    }

    /* Text section */
    .intro-wrapper .hero-text {
        padding: 0 1.5rem;
    }

    .intro-wrapper .hero-text h2 {
        font-size: 1.5rem !important;
    }

    .intro-wrapper .hero-text p {
        font-size: 1rem !important;
    }

    .visual-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        margin-top: 4rem;
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }

    .certifications-item {
        flex: 0 0 33.333%;
        /* 3 items visible */
    }

    /* Carousel */
    .carousel-img {
        height: 400px !important;
    }

    .carousel-caption {
        padding: 1rem 2rem !important;
        width: 80% !important;
    }

    .carousel-caption h3 {
        font-size: 1.5rem !important;
    }

    .carousel-caption p {
        font-size: 0.95rem !important;
    }

    /* Carousel navigation */
    .prev,
    .next {
        width: 38px !important;
        height: 38px !important;
        font-size: 16px !important;
    }

    .dot {
        width: 11px !important;
        height: 11px !important;
    }

    .info-tabs-container {
        display: flex;
        flex-wrap: nowrap;
        gap: 1.5rem;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        box-sizing: border-box;
    }

    .info-tabs-container .tab-content-area {
        flex: 1 1 auto;
        min-width: 0;
        /* REMOVED FIXED MIN-WIDTH to prevent cut-off */
        width: 100%;
        box-sizing: border-box;
    }

    .info-tabs-container .tabs-nav {
        flex: 0 0 180px;
        min-width: 140px;
    }

    /* ============================================
   PARTNERS & FAQ - RESPONSIVE
   ============================================ */

    /* Container principale */
    .partners-accordion,
    .faq-accordion {
        max-width: 1000px;
        margin: 0 auto;
        padding: 0 1rem;
        box-sizing: border-box;
    }

    /* Accordion item */
    .accordion-item {
        background: white;
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--gray-200);
        overflow: hidden;
        will-change: max-height;
        transform: translateZ(0);
    }

    .accordion-content {
        padding: 0 2rem;
        background-color: white;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
        border-top: 1px solid transparent;
    }

    .accordion-header.active+.accordion-content {
        border-top-color: var(--gray-100);
        padding-bottom: 2rem;
    }

    .accordion-body {
        padding-top: 1.5rem;
    }

    /* Griglia interna accordion */
    .accordion-body-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        align-items: start;
    }

    /* ============================================
   PARTNERS GRID
   ============================================ */
    .partner-logos-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 1rem;
        align-items: center;
        justify-content: center;
    }

    .partner-logo-card {
        background: white;
        padding: 0.75rem;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-md);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        will-change: transform, box-shadow;
        backface-visibility: hidden;
    }

    .partner-logo-card:hover {
        box-shadow: var(--shadow-md);
        border-color: var(--primary-light);
        transform: translateY(-3px);
    }

    .partner-logo-card img {
        max-width: 100%;
        max-height: 80px;
        object-fit: contain;
        filter: grayscale(100%);
        opacity: 0.7;
        transition: all 0.3s ease;
    }

    .partner-logo-card:hover img {
        filter: grayscale(0%);
        opacity: 1;
    }

    /* Tech Badge */
    .tech-badge {
        background: var(--primary-lighter);
        color: var(--primary-dark);
        padding: 0.4rem 0.8rem;
        border-radius: 50px;
        font-size: 0.85rem;
        font-weight: 500;
    }

    /* Web.html Process Section Alignment */
    .process-section {
        padding: 2rem !important;
        margin-bottom: 3rem !important;
    }

    .process-section h3 {
        text-align: left !important;
        margin-left: 0 !important;
    }

    .process-item {
        align-items: flex-start !important;
    }

    /* Ensure circle numbers don't shrink */
    .process-item>div:first-child {
        min-width: 40px !important;
        flex-shrink: 0;
    }

    .process-item h4,
    .process-item p {
        text-align: left !important;
    }

    /* Carousel caption centering for tablet */
    .carousel-caption {
        width: 100% !important;
        text-align: center !important;
    }

    /* Xylophone effect - active tab as raised key/bookmark */
    .tabs-container.vertical .tabs-nav.vertical {
        position: relative !important;
    }

    .tabs-container.vertical .tab-btn {
        position: relative !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        transition: all 0.3s ease !important;
    }

    /* Active tab - expanded like a raised piano key */
    .tabs-container.vertical .tab-btn.active {
        width: auto !important;
        min-width: 100% !important;
        max-width: 320px !important;
        padding-right: 2rem !important;
        z-index: 100 !important;
        overflow: visible !important;
        white-space: normal !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
        transform: translateX(5px) !important;
    }

    /* Inactive tabs - show only short title (first word) */
    .tabs-container.vertical .tab-btn:not(.active) {
        font-size: 0 !important;
    }

    .tabs-container.vertical .tab-btn:not(.active)::before {
        content: attr(data-short-title) !important;
        font-size: 1rem !important;
    }
}

/* ============================================
   MOBILE LARGE (480px - 768px)
   ============================================ */
@media (max-width: 768px) {

    .top-bar {
        font-size: 0.85rem;
    }

    .top-bar-container {
        flex-direction: column;
        gap: 0.2rem;
        text-align: center;
        padding: 0.2rem 1rem;
    }

    .top-info {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.8rem;
    }

    .intro-bg,
    .intro-bgGradient {
        height: 65vh !important;
        /* Leggermente più alto per compensare il fade */
    }

    .header-main {
        padding: 1rem 1.5rem 1rem 1rem !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
    }

    /* Contenitore per loghi + hamburger menu */
    .logo-and-menu {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 2rem;
        flex: 1;
        width: 100%;
    }

    .logo-and-menu .hamburger-menu {
        margin-left: auto;
        margin-right: 0rem;
    }

    .logo {
        flex: 0 0 auto;
    }

    .logo img {
        height: 100px !important;
    }

    .header-actions {
        flex: 0 0 auto;
        justify-content: flex-end !important;
    }

    .header-actions .cta-button {
        display: none !important;
    }

    .hamburger-menu {
        margin-left: 0 !important;
    }

    /* Hero Section */
    .hero {
        min-height: auto;
    }

    .hero-content {
        display: block;
        min-width: 0px;
    }

    .hero-text {
        text-align: center;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .hero-text h1 {
        font-size: 52px !important;
        line-height: 1.2;
    }

    .hero-text h2 {
        font-size: 36px !important;
    }

    .hero-text p {
        font-size: 1.35rem !important;
        line-height: 1.6;
        padding: 0 0.5rem;
    }

    /* Riduco tutti i titoli h2 su mobile */
    h2,
    .section-header h2 {
        font-size: 1.5rem !important;
    }

    /* Riduco i titoli h3 */
    h3 {
        font-size: 1.25rem !important;
    }

    .hero-buttons {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .btn-primary,
    .btn-secondary {
        width: auto;
        min-width: 250px;
        /* Slightly wider */
        max-width: 90%;
        padding: 0.9rem 2.5rem !important;
        font-size: 1rem !important;
        text-align: center;
        position: relative !important;
        /* For absolute arrow */
        justify-content: center !important;
        /* Center text */
    }

    /* Arrow icon absolute positioning */
    .btn-primary span {
        position: absolute !important;
        right: 1.5rem !important;
        top: 50%;
        transform: translateY(-50%);
    }

    /* Reduce spacing for non-home pages */
    .hero:not(#home) {
        margin-top: 15px !important;
        padding-top: 0.5rem !important;
    }

    /* Ensure Home keeps its spacing */
    #home.hero {
        margin-top: 30px !important;
        padding-top: 1.5rem !important;
    }

    /* Web.html Technologies Grid - 2 columns for mobile large */
    .tech-grid-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    .visual-grid {
        display: none !important;
    }

    /* Fix Carousel Width - Full Width on Mobile */
    .carousel-section {
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-bottom: 0 !important;
    }

    .carousel-container {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        height: auto !important;
        aspect-ratio: auto !important;
        max-height: none !important;
    }

    /* Carousel navigation - touch friendly */
    .prev,
    .next {
        width: 36px !important;
        height: 36px !important;
        font-size: 14px !important;
    }

    .carousel-dots {
        bottom: 10px !important;
    }

    .dot {
        width: 10px !important;
        height: 10px !important;
        margin: 0 4px !important;
    }

    .certifications-item {
        flex: 0 0 33.333%;
        /* 3 items visible */
    }

    .certifications-carousel {
        mask-image: linear-gradient(to right, transparent, black 2%, black 98%, transparent) !important;
        -webkit-mask-image: linear-gradient(to right, transparent, black 2%, black 98%, transparent) !important;
    }

    /* Text section */
    .intro-wrapper .hero-text {
        padding: 0 3rem;
    }

    .intro-wrapper .hero-text h2 {
        font-size: 1.3rem !important;
        padding: 0 3rem;
    }

    .intro-wrapper .hero-text p {
        font-size: 1.2rem;
        line-height: 1.6;
        padding: 0 3rem;
    }

    .partners-accordion,
    .faq-accordion {
        max-width: 100%;
        padding: 0 0.75rem;
    }

    /* Stack Tabs on Mobile Large (and smaller) */
    .info-tabs-container {
        flex-direction: column !important;
        width: 100% !important;
        /* Override clamp(900px, 100%, 1200px) from style.css */
        min-width: 0 !important;
        max-width: 100% !important;
        padding: 0 0.5rem !important;
        box-sizing: border-box;
    }

    .info-tabs-container .tabs-nav {
        width: 100% !important;
        flex: 0 0 auto !important;
        overflow-x: auto;
        margin-bottom: 1rem;
        display: flex;
        flex-direction: row;
        gap: 0.2rem;
        /* Minimal gap */
        justify-content: center;
        /* Center tabs */
        flex-wrap: wrap;
        /* Allow tabs to wrap to next line */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .info-tabs-container .tabs-nav::-webkit-scrollbar {
        display: none;
    }

    /* Fix tab-link styles to prevent shifting and make them smaller */
    .info-tabs-container .tab-link {
        padding: 0.6rem 0.8rem !important;
        /* Much smaller padding */
        font-size: 0.8rem !important;
        /* Smaller font */
        white-space: nowrap;
        flex-shrink: 0;
        transform: none !important;
        /* Prevent transform shift */
        border-radius: 6px !important;
    }

    .info-tabs-container .tab-link:hover {
        transform: none !important;
        /* Prevent hover shift */
    }

    .info-tabs-container .tab-link.active {
        transform: none !important;
        /* Prevent active shift */
    }

    .info-tabs-container .tab-content-area {
        width: 100% !important;
        /* Override fixed 872px from style.css */
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 1.5rem 1rem !important;
        /* Reduced horizontal padding */
        box-sizing: border-box;
        /* Fixed Height Logic: Stack all panes */
        display: grid;
        grid-template-areas: "stack";
    }

    .info-tabs-container .tab-content-area .tab-pane {
        grid-area: stack;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
        height: auto;
        /* Allow natural height */
    }

    .info-tabs-container .tab-content-area .tab-pane.active {
        opacity: 1;
        visibility: visible;
        position: relative;
        z-index: 1;
    }

    /* Fix for servizi.html vertical tabs */
    .tabs-container.vertical {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden;
        display: block !important;
        /* Disable flex on mobile to prevent flex behaviors */
    }

    .tabs-container.vertical .tab-content-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 0 !important;
        overflow-x: hidden;
        box-sizing: border-box;
        flex: none !important;
        /* Disable flex sizing */
    }

    .tabs-container.vertical .tab-content {
        padding: 1.5rem !important;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .tabs-container.vertical .software-grid {
        grid-template-columns: 1fr !important;
        /* Force single column */
        gap: 1rem;
        width: 100%;
    }

    /* Make servizi.html tabs smaller to fit in viewport */
    .tabs-nav.vertical {
        flex-wrap: wrap !important;
        /* Allow wrapping */
        justify-content: center !important;
        /* Center tabs */
        gap: 0.2rem !important;
    }

    .tabs-nav.vertical .tab-btn {
        padding: 0.6rem 0.8rem !important;
        /* Smaller padding */
        font-size: 0.8rem !important;
        /* Smaller font */
        flex-shrink: 0;
    }

    /* CRITICAL: Ensure mobile dropdown is not constrained by parent */
    .tabs-container.vertical .mobile-tabs-dropdown,
    .tabs-container.vertical .mobile-service-selector,
    .tabs-container.vertical .service-card-active {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    /* Fix for azienda.html tabs (uses .tabs-container with .tab-btn) */
    .tabs-container:not(.vertical) .tabs-nav {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.2rem !important;
    }

    .tabs-container:not(.vertical) .tab-btn {
        padding: 0.6rem 0.8rem !important;
        font-size: 0.8rem !important;
        flex-shrink: 0;
    }


    .accordion-body-grid {
        display: grid;
        grid-template-columns: 1fr;
        /* Una colonna sola sui piccoli */
        gap: 1rem;
        /* leggero gap */
    }

    /* Fix for Web.html Expanding Panels - Stack vertically on mobile */
    .panels-container {
        flex-direction: column !important;
        height: auto !important;
        min-height: 500px;
        /* Ensure enough space */
    }

    .panel {
        width: 100% !important;
        flex: 0 0 60px !important;
        /* Fixed small height for collapsed */
        margin-bottom: 0.5rem;
        /* Spacing between bars */
        padding: 0 1rem !important;
        /* Fix disappearing text by removing large padding */
        justify-content: center !important;
        /* Center text vertically */
    }

    .panel.active {
        flex: 0 0 350px !important;
        /* Fixed large height for expanded */
    }

    .panel h3 {
        font-size: 1.2rem;
        /* Smaller title */
        margin-bottom: 0.5rem;
    }

    /* Reset rotation for collapsed panels on mobile - Use Absolute Centering */
    .panel:not(.active) h3 {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        /* Center perfectly without rotation */
        width: 100% !important;
        text-align: left !important;
        margin: 0 !important;
        padding-left: 2rem !important;
        /* Add padding to match left alignment visually */
        z-index: 10 !important;
        white-space: nowrap !important;
    }

    /* Ensure content doesn't interfere when collapsed */
    .panel:not(.active) .panel-content {
        display: none !important;
    }

    /* Adjust content positioning for vertical expanding */
    .panel-content {
        position: relative !important;
        /* Flow naturally */
        bottom: auto !important;
        left: 0 !important;
        right: 0 !important;
        padding: 0 !important;
        margin-top: 1rem;
    }

    .panel.active .panel-content {
        opacity: 1;
        transition-delay: 0.6s;
        /* Wait longer for expansion to clear title */
    }


    /* Fix for Web.html Technology Grid - Single Column */
    .tech-grid-container {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Fix for Arrow Steps Carousel - Stack vertically on mobile */
    .arrow-steps-container {
        flex-direction: column !important;
        gap: 0 !important;
        margin-top: 2rem !important;
        padding: 0 1rem;
        /* Ensure container has padding */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .arrow-step {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: -1.5rem !important;
        /* Slight vertical overlap */
        clip-path: polygon(0% 0%, 100% 0%, 100% calc(100% - 1.5rem), 50% 100%, 0% calc(100% - 1.5rem)) !important;
        /* Point down */
        padding: 1.5rem 1rem 3rem 1rem !important;
        /* Extra bottom padding for arrow */
        flex: none !important;
    }

    .arrow-step:first-child {
        padding-left: 1rem !important;
        /* Reset specific padding */
        border-radius: 8px 8px 0 0 !important;
        clip-path: polygon(0% 0%, 100% 0%, 100% calc(100% - 1.5rem), 50% 100%, 0% calc(100% - 1.5rem)) !important;
    }

    .arrow-step:last-child {
        margin-bottom: 0 !important;
        clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%) !important;
        /* Flat bottom */
        border-radius: 0 0 8px 8px !important;
        padding-bottom: 1.5rem !important;
    }

    .arrow-step .step-number {
        margin-bottom: 0.5rem !important;
        width: 32px !important;
        height: 32px !important;
        font-size: 1rem !important;
    }

    .arrow-step .step-title {
        font-size: 1rem !important;
        margin-bottom: 0.2rem !important;
    }

    .arrow-step .step-desc {
        font-size: 0.85rem !important;
    }


    .partner-logos-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        /* colonne fluide */
        gap: 0.6rem;
        /* margine tra i loghi */
        justify-items: center;
        /* centra i loghi */
        align-items: center;
    }


    .partner-logo-card {
        padding: 0.5rem;
        min-height: 60px;
        /* altezza minima */
    }

    .partner-logo-card img {
        max-height: 60px;
        /* limita altezza per evitare overflow */
        object-fit: contain;
    }

    .tech-badge {
        font-size: 0.8rem;
        padding: 0.35rem 0.7rem;
    }

    .accordion-content {
        padding: 0 1rem;
    }

    .accordion-body {
        padding-top: 1rem;
    }

    .partner-logos-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.8rem;
    }

    .partner-logo-card {
        height: 70px;
        padding: 0.5rem;
    }

    .tech-badge {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
}

@media (max-width: 480px) {

    .intro-bgGradient {
        height: 60vh;
    }

    .tech-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .accordion-content {
        padding: 0 0.5rem;
    }

    /* Services */
    .services {
        padding: 3rem 1.5rem !important;
    }

    .services-grid {
        grid-template-columns: 1fr !important;
    }

    .accordion-body-grid {
        display: grid;
        grid-template-columns: 1fr;
        /* Una colonna sola sui piccoli */
        gap: 1rem;
        /* leggero gap */
    }


    .partner-logos-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        /* colonne fluide */
        gap: 0.6rem;
        /* margine tra i loghi */
        justify-items: center;
        /* centra i loghi */
        align-items: center;
    }


    .partner-logo-card {
        padding: 0.5rem;
        min-height: 60px;
        /* altezza minima */
    }

    .partner-logo-card img {
        max-height: 60px;
        /* limita altezza per evitare overflow */
        object-fit: contain;
    }

    .tech-badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr !important;
        padding: 2rem 1.5rem !important;
    }

    footer {
        padding: 2rem 1.5rem !important;
    }
}

/* ============================================
   MOBILE SMALL (< 480px)
   ============================================ */
@media (max-width: 480px) {

    :root {
        --mobile-header-height: 220px;
    }

    /* Top bar ultra compact */
    .top-bar {
        font-size: 0.75rem !important;
    }

    /* Header */
    .logo img {
        height: 100px !important;
    }

    /* Hero */

    .hero-text {
        padding-left: 90%;
        padding-right: 90%;
    }

    .hero-text h1 {
        font-size: 2.1rem !important;
        /* Aumentato da 1.5rem */
    }

    .hero-text h2 {
        font-size: 1.6rem !important;
        /* Aumentato da 1.3rem */
    }

    .hero-text p {
        font-size: 1.05rem !important;
        /* Aumentato da 0.95rem */
    }

    h2,
    .section-header h2 {
        font-size: 1.6rem !important;
        /* Aumentato da 1.3rem */
    }

    h3 {
        font-size: 1.3rem !important;
        /* Aumentato da 1.1rem */
    }

    /* Mobile menu narrower */
    .mobile-nav {
        width: 50%;
        max-width: none;
    }

    .hamburger-menu {
        padding: 8px;
    }

    /* Carousel - Mobile Stacked Layout */
    .carousel-container {
        height: auto !important;
        aspect-ratio: auto !important;
        max-height: none !important;
    }

    .carousel-slide {
        display: block !important;
        position: relative !important;
    }

    .carousel-img {
        height: 250px !important;
        width: 100% !important;
        object-fit: cover !important;
    }

    .carousel-caption {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        /* Darker gradient: almost black at top, fading to transparent */
        background: linear-gradient(to bottom, rgba(15, 15, 15, 0.98) 0%, rgba(15, 15, 15, 0.7) 50%, rgba(15, 15, 15, 0) 90%) !important;
        padding: 2rem 1.5rem !important;
        text-align: center;
        border-radius: 0 !important;
        margin-bottom: 0 !important;
        backdrop-filter: none !important;

        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        /* Text at top */
        pointer-events: none;
        /* Let clicks pass through if needed */
    }

    .carousel-caption h3 {
        font-size: 1.4rem !important;
        margin-bottom: 0.5rem !important;
    }

    .carousel-caption p {
        font-size: 1rem !important;
    }

    /* Carousel navigation - compact */
    .prev,
    .next {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }

    .carousel-dots {
        bottom: 8px !important;
    }

    .dot {
        width: 8px !important;
        height: 8px !important;
        margin: 0 3px !important;
    }

    .certifications-item {
        flex: 0 0 50%;
        /* 2 items visible */
    }

    /* Text section - ultra compact */
    .intro-wrapper .hero-text {
        padding: 0 0.75rem;
    }

    .intro-wrapper .hero-text h2 {
        font-size: 1.2rem !important;
        line-height: 1.3 !important;
    }

    .intro-wrapper .hero-text p {
        font-size: 0.9rem !important;
        line-height: 1.5 !important;
    }

    /* Buttons */
    .btn-primary,
    .btn-secondary {
        min-width: 180px;
        font-size: 0.95rem !important;
        padding: 0.9rem 2rem !important;
    }

    /* Footer */
    .footer-content {
        gap: 2rem !important;
    }

    .footer-section h3 {
        font-size: 1.1rem !important;
    }

    .footer-section a,
    .footer-section p {
        font-size: 0.9rem !important;
    }
}

/* =========================================
   Mobile Standard (≤480px)
   ========================================= */
@media (max-width: 480px) {

    /* Fix Carousel Width */
    .carousel-section {
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-bottom: 0 !important;
    }

    .carousel-container {
        height: auto !important;
        aspect-ratio: auto !important;
        max-height: none !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .info-tabs-container {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        padding: 0 0.25rem !important;
        box-sizing: border-box;
    }

    .info-tabs-container .tabs-nav {
        gap: 0.15rem !important;
        justify-content: center;
        flex-wrap: wrap;
    }

    .info-tabs-container .tab-link {
        padding: 0.5rem 0.6rem !important;
        font-size: 0.75rem !important;
    }

    .info-tabs-container .tab-content-area {
        width: 100% !important;
        max-width: 100% !important;
        padding: 1rem 0.75rem !important;
    }

    /* Servizi.html vertical tabs */
    .tabs-container.vertical {
        width: 100% !important;
        max-width: 100% !important;
    }

    .tabs-nav.vertical {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.15rem !important;
    }

    .tabs-nav.vertical .tab-btn {
        padding: 0.5rem 0.6rem !important;
        font-size: 0.75rem !important;
    }

    .tabs-container.vertical .tab-content {
        padding: 1rem 0.75rem !important;
    }

}