/* MOBILE CONTENT VISIBILITY FIX - ENSURES NO CONTENT IS CUT OFF */

/* CRITICAL: Ensure all content is visible below header on mobile */
@media (max-width: 991px) {
    
    /* Force all sections to have minimum top spacing */
    section {
        margin-top: 0 !important;
    }
    
    /* First section on pages with padding */
    main.main-with-padding > section:first-child,
    main.main-with-padding > .container:first-child,
    main.main-with-padding > .row:first-child {
        padding-top: 3rem !important;
        margin-top: 0 !important;
    }
    
    /* Hero sections should start immediately after header */
    main.main-no-padding > section:first-child.hero-section,
    main.main-no-padding > section:first-child[class*="hero"],
    main.main-no-padding > .hero-section:first-child,
    main.main-no-padding > [class*="hero"]:first-child {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    /* Regular sections on no-padding pages */
    main.main-no-padding > section:first-child:not([class*="hero"]) {
        padding-top: 2rem !important;
        margin-top: 0 !important;
    }
    
    /* Ensure containers have proper spacing */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Fix any potential overlapping content */
    .py-5 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    .section-padding {
        padding-top: 4rem !important;
        padding-bottom: 4rem !important;
    }
    
    /* Ensure cards and content blocks are properly spaced */
    .card,
    .service-card,
    .portfolio-card,
    .blog-card,
    .testimonial-card {
        margin-bottom: 1.5rem !important;
    }
    
    /* Fix headings that might be cut off */
    h1, .h1, .display-1, .display-2, .display-3, .display-4 {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* Ensure text content is readable */
    p, .lead {
        margin-bottom: 1rem !important;
    }
    
    /* Fix any absolute positioned elements */
    .position-absolute {
        position: relative !important;
    }
    
    /* Ensure modals work properly on mobile */
    .modal-dialog {
        margin: 1rem !important;
    }
    
    /* Fix floating elements */
    .floating-actions {
        bottom: 20px !important;
        right: 15px !important;
    }
}

/* Tablet specific fixes */
@media (max-width: 768px) {
    main.main-with-padding > section:first-child {
        padding-top: 2.5rem !important;
    }
    
    .py-5 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }
}

/* Small mobile specific fixes */
@media (max-width: 480px) {
    main.main-with-padding > section:first-child {
        padding-top: 2rem !important;
    }
    
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* HIDE DESKTOP HEADER ON MOBILE - CRITICAL FIX */
@media (max-width: 991px) {
    /* Hide the desktop header completely on mobile */
    .d-none.d-lg-block {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    /* Hide responsive header components on mobile */
    .main-header,
    .desktop-header,
    .top-bar,
    .main-nav {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
    }
}

/* EMERGENCY VISIBILITY FIX - If content is still hidden */
@media (max-width: 991px) {
    /* Force minimum height for main content */
    main {
        min-height: calc(100vh - 85px) !important;
    }
    
    /* Ensure first element is always visible */
    main > *:first-child {
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* Ensure all text is visible */
    * {
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Fix any transform issues */
    .transform-none-mobile {
        transform: none !important;
    }
}

/* Page-specific fixes */
@media (max-width: 991px) {
    /* About page */
    .about-page section:first-child {
        padding-top: 3rem !important;
    }
    
    /* Services page */
    .services-page section:first-child {
        padding-top: 3rem !important;
    }
    
    /* Portfolio page */
    .portfolio-page section:first-child {
        padding-top: 3rem !important;
    }
    
    /* Contact page */
    .contact-page section:first-child {
        padding-top: 3rem !important;
    }
    
    /* Blog page */
    .blog-page section:first-child {
        padding-top: 3rem !important;
    }
}

/* Debugging helper - Remove in production */
@media (max-width: 991px) {
    /* Uncomment to see content boundaries */
    /*
    main > section:first-child {
        border: 2px solid red !important;
    }
    
    .tirupati-header {
        border: 2px solid blue !important;
    }
    */
}