/* ========================================
   HOMEPAGE RESPONSIVE STYLES
   Mobile-first approach for Index.razor
   ======================================== */

/* ========================================
   MOBILE - UP TO 575px (Small phones)
   ======================================== */
@media (max-width: 575px) {
    /* Hero Section - Microsoft Style */
    .hero-microsoft {
        padding: 3rem 0 4rem 0 !important;
        min-height: auto !important;
    }

    /* Force single column layout on hero */
    .hero-microsoft .container > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 2rem !important;
    }

    /* Hero text content */
    .hero-microsoft h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }

    .hero-microsoft p {
        font-size: 1rem !important;
        line-height: 1.5 !important;
        margin-bottom: 1.5rem !important;
    }

    /* Hero buttons */
    .hero-microsoft a[href="#servizi"],
    .hero-microsoft a[href="/contatti"] {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.95rem !important;
        width: 100%;
        justify-content: center !important;
    }

    /* Hero button container */
    .hero-microsoft div[style*="display: flex"] {
        flex-direction: column !important;
        width: 100%;
    }

    /* Hero image container */
    .hero-microsoft > div > div > div:last-child {
        display: none !important;
    }

    /* Hide decorative elements on mobile */
    .hero-microsoft > div[style*="position: absolute"] {
        display: none !important;
    }

    /* Secondary Navigation */
    #secondary-nav {
        top: 60px !important;
    }

    #secondary-nav ul {
        justify-content: flex-start !important;
        padding: 0.5rem 0 !important;
        gap: 0.5rem !important;
    }

    #secondary-nav li a {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.85rem !important;
    }

    /* Services Section */
    #servizi {
        padding: 2.5rem 0 !important;
    }

    #servizi h2 {
        font-size: 1.75rem !important;
        margin-bottom: 0.75rem !important;
    }

    #servizi > div > div:first-child p {
        font-size: 1rem !important;
        line-height: 1.5 !important;
    }

    /* Service Cards Grid - Force Single Column */
    #servizi > div > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
        margin-bottom: 2rem !important;
    }

    /* Individual Service Card */
    #servizi .container > div[style*="grid-template-columns"] > div[style*="background: white"] {
        padding: 1.5rem !important;
    }

    /* Service Card Headings */
    #servizi h3 {
        font-size: 1.35rem !important;
        margin: 0.75rem 0 !important;
    }

    /* Service Card Text */
    #servizi p {
        font-size: 0.95rem !important;
        line-height: 1.5 !important;
        margin-bottom: 1rem !important;
    }

    /* Service Card Category Label */
    #servizi span[style*="text-transform: uppercase"] {
        font-size: 0.7rem !important;
        letter-spacing: 0.5px !important;
    }

    /* Service Card Features */
    #servizi div[style*="flex-direction: column"] > div[style*="display: flex"] {
        padding: 0.75rem !important;
        gap: 0.75rem !important;
    }

    #servizi div[style*="flex-direction: column"] > div img {
        height: 32px !important;
    }

    #servizi div[style*="flex-direction: column"] > div > div {
        flex: 1;
    }

    #servizi div[style*="font-weight: 700"] {
        font-size: 0.95rem !important;
    }

    #servizi div[style*="font-size: 0.85rem"] {
        font-size: 0.8rem !important;
    }

    /* Service Card Links */
    #servizi a[href*="#"] {
        font-size: 0.9rem !important;
    }

    /* Partners Section */
    #partners {
        padding: 2.5rem 0 !important;
    }

    #partners h2 {
        font-size: 1.75rem !important;
        margin-bottom: 0.75rem !important;
    }

    #partners > div > div:first-child p {
        font-size: 1rem !important;
    }

    /* Partner Cards Grid - Force Single Column */
    #partners > div > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    /* Partner Card */
    #partners div[style*="background: white"] {
        padding: 1.5rem !important;
    }

    #partners div[style*="background: white"] img {
        height: 40px !important;
        margin-bottom: 1rem !important;
    }

    #partners h3 {
        font-size: 1.25rem !important;
        margin-bottom: 0.75rem !important;
    }

    #partners div[style*="background: white"] p {
        font-size: 0.95rem !important;
        line-height: 1.5 !important;
        margin-bottom: 1rem !important;
    }

    #partners span[style*="background: #f0f0f0"] {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    #partners a[style*="color: #0078d4"] {
        font-size: 0.9rem !important;
    }
}

/* ========================================
   MOBILE - 576px TO 767px (Large phones)
   ======================================== */
@media (min-width: 576px) and (max-width: 767px) {
    /* Hero Section */
    .hero-microsoft {
        padding: 4rem 0 5rem 0 !important;
        min-height: auto !important;
    }

    .hero-microsoft .container > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 2.5rem !important;
    }

    .hero-microsoft h1 {
        font-size: 2.5rem !important;
        line-height: 1.2 !important;
    }

    .hero-microsoft p {
        font-size: 1.1rem !important;
    }

    /* Show hero image on larger phones */
    .hero-microsoft > div > div > div:last-child {
        display: block !important;
    }

    .hero-microsoft img {
        height: 250px !important;
    }

    /* Service Cards - Single Column */
    #servizi > div > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 2rem !important;
    }

    /* Partner Cards - Single Column */
    #partners > div > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 2rem !important;
    }
}

/* ========================================
   TABLET - 768px TO 991px
   ======================================== */
@media (min-width: 768px) and (max-width: 991px) {
    /* Hero Section */
    .hero-microsoft {
        padding: 5rem 0 6rem 0 !important;
        min-height: auto !important;
    }

    .hero-microsoft .container > div[style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 3rem !important;
    }

    .hero-microsoft h1 {
        font-size: 2.75rem !important;
        text-align: center !important;
    }

    .hero-microsoft p {
        font-size: 1.15rem !important;
        text-align: center !important;
    }

    .hero-microsoft > div > div > div:first-child {
        text-align: center !important;
    }

    .hero-microsoft div[style*="display: flex"][style*="gap: 1rem"] {
        justify-content: center !important;
    }

    /* Service Cards - 2 Columns */
    #servizi > div > div[style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem !important;
    }

    /* Make last 2 cards span full width if there are odd number */
    #servizi > div > div[style*="grid-template-columns"] > div:nth-last-child(-n+2):nth-child(odd) {
        grid-column: 1 / -1 !important;
    }

    /* Partner Cards - 2 Columns */
    #partners > div > div[style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem !important;
    }

    /* Center last partner card if odd number */
    #partners > div > div[style*="grid-template-columns"] > div:nth-last-child(1):nth-child(odd) {
        grid-column: 1 / -1 !important;
        max-width: 50%;
        margin: 0 auto;
    }
}

/* ========================================
   SMALL DESKTOP - 992px TO 1199px
   ======================================== */
@media (min-width: 992px) and (max-width: 1199px) {
    /* Hero Section */
    .hero-microsoft {
        padding: 5rem 0 7rem 0 !important;
        min-height: 550px !important;
    }

    .hero-microsoft h1 {
        font-size: 3rem !important;
    }

    .hero-microsoft p {
        font-size: 1.2rem !important;
    }

    .hero-microsoft img {
        height: 280px !important;
    }

    /* Service Cards - 2 Columns */
    #servizi > div > div[style*="grid-template-columns"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem !important;
    }

    #servizi h3 {
        font-size: 1.6rem !important;
    }

    /* Partner Cards - 3 Columns (keep original) */
    #partners > div > div[style*="grid-template-columns"] {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2rem !important;
    }
}

/* ========================================
   GENERAL MOBILE IMPROVEMENTS
   ======================================== */
@media (max-width: 991px) {
    /* Ensure container has proper padding */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Fix icon sizes in service cards */
    .hero-microsoft i,
    #servizi i,
    #partners i {
        font-size: 1rem !important;
    }

    /* Improve button touch targets */
    .hero-microsoft a,
    #servizi a,
    #partners a {
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
    }

    /* Better spacing for text elements */
    .hero-microsoft,
    #servizi,
    #partners {
        overflow-x: hidden !important;
    }

    /* Fix box shadows for better mobile performance */
    [style*="box-shadow"] {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
}

/* ========================================
   ACCESSIBILITY & TOUCH IMPROVEMENTS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Touch device optimizations */
    .hero-microsoft a,
    #servizi a,
    #partners a {
        min-height: 48px !important;
        padding: 0.75rem 1.5rem !important;
    }

    /* Remove hover effects on touch devices */
    .hero-microsoft a:hover,
    #servizi a:hover,
    #partners a:hover {
        transform: none !important;
    }
}

/* ========================================
   LANDSCAPE MOBILE PHONES
   ======================================== */
@media (max-width: 767px) and (orientation: landscape) {
    .hero-microsoft {
        min-height: auto !important;
        padding: 2rem 0 3rem 0 !important;
    }

    #servizi,
    #partners {
        padding: 2rem 0 !important;
    }
}

/* ========================================
   VERY SMALL DEVICES (< 360px)
   ======================================== */
@media (max-width: 359px) {
    .hero-microsoft h1 {
        font-size: 1.75rem !important;
    }

    .hero-microsoft p {
        font-size: 0.95rem !important;
    }

    .hero-microsoft a {
        font-size: 0.9rem !important;
        padding: 0.65rem 1.25rem !important;
    }

    #servizi h2,
    #partners h2 {
        font-size: 1.5rem !important;
    }

    #servizi h3,
    #partners h3 {
        font-size: 1.2rem !important;
    }
}

/* ========================================
   FOOTER RESPONSIVE FIXES
   ======================================== */
@media (max-width: 991px) {
    /* Footer grid - 2 columns on tablet */
    .footer .container > div[style*="grid-template-columns"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem !important;
    }
}

@media (max-width: 575px) {
    /* Footer - single column on mobile */
    .footer {
        padding: 2.5rem 0 1.5rem 0 !important;
    }

    .footer .container > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 2rem !important;
        margin-bottom: 2rem !important;
    }

    .footer h3,
    .footer h4 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .footer p {
        font-size: 0.85rem !important;
    }

    .footer a {
        font-size: 0.85rem !important;
    }

    /* Footer bottom section */
    .footer > div > div[style*="border-top"] {
        padding-top: 1.5rem !important;
        flex-direction: column !important;
        gap: 1rem !important;
        text-align: center;
    }

    .footer > div > div[style*="border-top"] > div {
        justify-content: center !important;
    }
}

/* ========================================
   NAVIGATION DROPDOWN MOBILE FIXES
   ======================================== */
@media (max-width: 768px) {
    /* Fix navigation dropdown on mobile */
    .navbar nav .nav-dropdown {
        position: relative;
        width: 100%;
    }

    /* Make dropdown button full-width on mobile */
    .navbar nav .nav-dropdown-toggle {
        width: 100%;
        text-align: left;
        justify-content: space-between;
        display: flex;
        align-items: center;
    }

    /* Dropdown menu mobile adjustments - HIDE when closed */
    .navbar nav .nav-dropdown-menu {
        display: none !important;
        position: static !important;
        left: 0 !important;
        transform: none !important;
        min-width: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        z-index: 9999 !important;
    }

    /* When dropdown is active - SHOW */
    .navbar nav .nav-dropdown.active .nav-dropdown-menu {
        display: flex !important;
        flex-direction: column !important;
        transform: none !important;
        max-height: 600px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        pointer-events: auto !important;
        padding: 1rem !important;
        border-top: 1px solid var(--border-color) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Product categories - single column on mobile */
    .navbar nav .nav-dropdown-menu .nav-product-category {
        width: 100%;
    }

    /* Product grid - single column on mobile */
    .navbar nav .nav-dropdown-menu .nav-category-products {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    /* Product links - better touch targets */
    .navbar nav .nav-dropdown-menu .nav-category-products a {
        padding: 0.75rem !important;
        min-height: 44px;
    }

    /* Product images - smaller on mobile */
    .navbar nav .nav-dropdown-menu .nav-category-products img {
        height: 32px !important;
        width: auto !important;
    }

    /* Product names */
    .navbar nav .nav-dropdown-menu .product-name {
        font-size: 0.9rem !important;
    }

    /* Product descriptions */
    .navbar nav .nav-dropdown-menu .product-description {
        font-size: 0.75rem !important;
    }

    /* Category headers */
    .navbar nav .nav-dropdown-menu .nav-category-header {
        font-size: 0.75rem !important;
        padding: 0.5rem 0 !important;
    }

    /* Dropdown footer */
    .navbar nav .nav-dropdown-menu .nav-dropdown-footer {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
    }

    /* "All Products" link */
    .navbar nav .nav-dropdown-menu .nav-all-products {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
    }
}

/* ========================================
   VERY SMALL MOBILE NAVIGATION
   ======================================== */
@media (max-width: 575px) {
    /* Even more compact on very small screens */
    .navbar nav .nav-dropdown-menu {
        padding: 0.75rem !important;
        max-height: 350px !important;
    }

    .navbar nav .nav-dropdown-menu .nav-category-products a {
        padding: 0.5rem !important;
        gap: 0.5rem !important;
    }

    .navbar nav .nav-dropdown-menu .nav-category-products img {
        height: 28px !important;
    }

    .navbar nav .nav-dropdown-menu .product-name {
        font-size: 0.85rem !important;
    }

    .navbar nav .nav-dropdown-menu .product-description {
        font-size: 0.7rem !important;
    }

    .navbar nav .nav-dropdown-menu .nav-category-header {
        font-size: 0.7rem !important;
    }
}
