/* ⚡ PA33 Iframe Layout Management - Header/Footer Control */

/* Hide only TOP parts of Header when in iframe, keep navbar with burger button */
body.is-iframe .it-header-slim-wrapper,
body.is-iframe .it-header-center-wrapper {
    display: none !important;
}

/* Keep the navbar wrapper with burger button VISIBLE in iframe */
body.is-iframe .it-header-navbar-wrapper {
    display: block !important;
}

/* For custom templates (PROTEZIONECIVILEREGIONEABRUZZO, REGIONECALABRIA) - keep burger button */
body.is-iframe .custom-template .simplified-header .it-nav-wrapper {
    display: block !important;
}

/* Hide only unnecessary parts of simplified header in iframe */
body.is-iframe .custom-template .simplified-header .navbar-nav.ms-auto {
    display: none !important; /* Hide title/breadcrumb part */
}

/* Hide Footer completely when in iframe */
body.is-iframe .it-footer-wrapper {
    display: none !important;
}

/* Adjust main content spacing when header is hidden */
body.is-iframe .container-fluid,
body.is-iframe .gdlr-core-container {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Keep sidebar/menu always visible in iframe */
body.is-iframe .pa-sidebar {
    display: block !important;
}

/* Expand main content area when header/footer are hidden */
body.is-iframe .pa-content {
    min-height: 100vh;
    padding-top: 1rem;
}

/* When in iframe, expand sidebar to fill available space better */
body.is-iframe .pa-sidebar {
    min-height: 100vh;
    background-color: var(--bs-light, #f8f9fa);
    border-right: 1px solid var(--bs-border-color, #dee2e6);
}

/* Enhance burger button visibility and styling in iframe mode */
body.is-iframe .custom-navbar-toggler {
    background: var(--bs-primary, #0066cc) !important;
    color: var(--bs-white) !important;
    border: 2px solid var(--bs-primary, #0066cc) !important;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.25) !important;
    transition: all 0.25s ease !important;
}

body.is-iframe .custom-navbar-toggler:hover {
    background: var(--bs-primary-600, #0056b3) !important;
    border-color: var(--bs-primary-600, #0056b3) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.35) !important;
}

/* Make navbar wrapper more prominent in iframe */
body.is-iframe .it-header-navbar-wrapper {
    background: var(--bs-light, #f8f9fa) !important;
    border-bottom: 2px solid var(--bs-primary-100, #e6f3ff) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

/* Optional: Add subtle border when in iframe for visual clarity */
body.is-iframe {
    border: 2px solid var(--bs-primary-100, #e6f3ff);
    border-radius: var(--bs-border-radius-lg, 0.5rem);
}

/* Responsive adjustments for iframe mode */
@media (max-width: 991.98px) {
    body.is-iframe .pa-content {
        padding-top: 0.5rem;
    }
    
    /* Ensure mobile menu toggle is still accessible in iframe */
    body.is-iframe .custom-navbar-toggler {
        position: fixed;
        top: 0.5rem;
        left: 0.5rem;
        z-index: 1050;
        background: var(--bs-white);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
}

/* Debug info for development (remove in production) */
body.is-iframe::before {
    content: "🪟 Modalità Iframe Attiva";
    position: fixed;
    top: 0;
    right: 0;
    background: var(--bs-info);
    color: var(--bs-white);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    z-index: 9999;
    border-radius: 0 0 0 var(--bs-border-radius);
    display: none; /* Nascosto di default, attiva per debug */
}

/* Show debug info only in development */
body.is-iframe.debug-mode::before {
    display: block;
}

/* ⚡ IFRAME ACCESSIBILITY PILL - Fixed Bottom Button (SOLO per iframe) */
.iframe-accessibility-pill {
    position: fixed;
    bottom: 80px; /* Posizionato sopra il back-to-top button */
    right: 20px;
    z-index: 1040; /* Sopra contenuto, sotto modali */
    
    /* Default nascosto (mostra solo in iframe) */
    display: none !important;
    
    /* Bootstrap Italia button styling */
    padding: 0.75rem 1rem;
    border-radius: 50px; /* Pill shape */
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    
    /* Colors */
    background-color: var(--bs-white);
    color: var(--bs-primary, #0066cc);
    border: 2px solid var(--bs-primary, #0066cc);
    
    /* Shadow for visibility */
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.25);
    
    /* Smooth transitions */
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Show ONLY when in iframe */
body.is-iframe .iframe-accessibility-pill {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
}

/* Hover effects */
.iframe-accessibility-pill:hover {
    background-color: var(--bs-primary, #0066cc);
    color: var(--bs-white);
    border-color: var(--bs-primary, #0066cc);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.35);
    text-decoration: none;
}

/* Focus states for accessibility */
.iframe-accessibility-pill:focus {
    outline: 3px solid var(--bs-focus-ring-color, rgba(0, 102, 204, 0.25));
    outline-offset: 2px;
    background-color: var(--bs-primary, #0066cc);
    color: var(--bs-white);
    text-decoration: none;
}

/* Active state */
.iframe-accessibility-pill:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
}

/* Icon styling */
.iframe-accessibility-pill .icon {
    flex-shrink: 0;
}

/* Text responsive behavior */
.iframe-accessibility-pill .pill-text {
    white-space: nowrap;
}

/* Mobile responsive adjustments */
@media (max-width: 575.98px) {
    .iframe-accessibility-pill {
        bottom: 75px;
        right: 15px;
        padding: 0.875rem 1.125rem; /* Larger touch target */
        font-size: 0.8125rem;
    }
    
    /* Hide text on very small screens, show only icon */
    .iframe-accessibility-pill .pill-text {
        display: none;
    }
    
    .iframe-accessibility-pill {
        width: 56px;
        height: 56px;
        justify-content: center;
        border-radius: 50%; /* Full circle on mobile */
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .iframe-accessibility-pill {
        border-width: 3px;
        box-shadow: none;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .iframe-accessibility-pill {
        transition: none;
    }
    
    .iframe-accessibility-pill:hover {
        transform: none;
    }
}