/* ============================================================
   SAFARI / iOS COMPATIBILITY FIXES
   scuolapa.com - Audit CSS 17 Aprile 2026
   ============================================================
   Risolve 5 criticita:
   1. Form input cursor iOS
   2. Media queries breakpoints Safari
   3. Flexbox height issues
   4. Viewport units Safari mobile
   5. Prefissi WebKit mancanti
   ============================================================ */

/* ============================================================
   1. FIX INPUT CURSOR iOS (CRITICA)
   Safari iOS ha problemi con il posizionamento del cursore
   nei campi input, specialmente in layout responsive.
   font-size: 16px previene lo zoom automatico su iOS.
   ============================================================ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
textarea,
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0;
    background-color: white;
    font-size: 16px; /* previene auto-zoom iOS su focus */
    -webkit-text-size-adjust: 100%;
    /* Fix cursore fuori dal campo su iOS */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Auto-scroll quando la tastiera iOS copre l'input */
input:focus,
textarea:focus,
select:focus {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-user-select: text;
    user-select: text;
}

/* Fix per select dropdown su iOS */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23333'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}


/* ============================================================
   2. MEDIA QUERIES BREAKPOINTS SAFARI (CRITICA)
   Safari ha minimum screen width di circa 500px.
   Breakpoints ottimizzati per tutti i dispositivi Apple.
   ============================================================ */

/* Desktop large */
@media screen and (max-width: 1200px) {
    .form-wrapper {
        padding: 20px;
    }
}

/* Tablet + iPad */
@media screen and (max-width: 992px) {
    .card.has-bkg-grey {
        padding: 15px;
    }

    .hero-section .display-4 {
        font-size: 1.8rem;
    }
}

/* Landscape phone */
@media screen and (max-width: 768px) {
    .form-wrapper {
        padding: 15px;
    }

    .hero-section .col-lg-6 {
        text-align: center;
    }

    .hero-section img {
        margin-top: 20px;
    }

    /* Fix overflow orizzontale su mobile */
    body {
        overflow-x: hidden;
    }

    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
}

/* Mobile portrait - CRITICO per Safari (min screen ~500px) */
@media screen and (max-width: 480px) {
    .form-wrapper {
        width: 100%;
        padding: 15px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    }

    .card.has-bkg-grey.p-big {
        padding: 10px;
    }

    .title-xxlarge {
        font-size: 1.4rem;
    }

    .title-xxxlarge {
        font-size: 1.6rem;
    }

    .hero-section .display-4 {
        font-size: 1.5rem;
    }

    .hero-section .lead {
        font-size: 0.95rem;
    }

    /* Fix bottoni che escono dallo schermo */
    .btn, .btn-lg, .btn-primary {
        max-width: 100%;
        white-space: normal;
        word-wrap: break-word;
    }

    /* Fix immagini dashboard */
    .hero-section img,
    .img-fluid {
        max-width: 100%;
        height: auto;
    }

    /* Fix form di registrazione su schermi piccoli */
    .select-wrapper {
        width: 100%;
    }

    /* Fix card features */
    .feature-card {
        padding: 20px !important;
    }
}

/* iPhone SE e schermi molto piccoli */
@media screen and (max-width: 375px) {
    .form-wrapper {
        padding: 10px;
    }

    .card.has-bkg-grey.p-big {
        padding: 8px;
    }

    h1, .title-xxxlarge {
        font-size: 1.3rem;
    }

    .btn {
        font-size: 0.85rem;
        padding: 8px 16px;
    }
}


/* ============================================================
   3. FLEXBOX HEIGHT ISSUES (CRITICA)
   Safari ha problemi noti con height: 100% e min-height
   nei container flex. L'altezza dei figli flexbox non viene
   trattata come esplicitamente definita dal container padre.
   ============================================================ */

/* Fix container flex principali */
.form-container,
.steppers-content,
.it-page-sections-container {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    min-height: 0; /* previene il collapse su Safari */
}

/* Fix elementi dentro flex container */
.form-element,
.cmp-card,
.card-body {
    min-height: 0;
    -webkit-flex: 1 1 auto;
    flex: 1 1 auto;
}

/* Fix loader container (usato in molte pagine) */
.loader-containerx {
    display: -webkit-flex;
    display: flex;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-align-items: center;
    align-items: center;
}

/* Fix hero section */
.hero-section,
.it-hero-wrapper {
    min-height: 0;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}


/* ============================================================
   4. VIEWPORT UNITS SAFARI MOBILE
   Safari mobile ha comportamenti inconsistenti con vh e vw
   a causa della barra indirizzi dinamica che cambia altezza.
   ============================================================ */

/* Fallback per altezza viewport - sezioni full-height */
.full-height-form,
.hero-section {
    height: 100vh;
    height: -webkit-fill-available;
    /*min-height: 100vh;*/
}

/* Fix per map container (la-tua-fermata.php) */
#map {
    height: 100vh;
    height: -webkit-fill-available;
    min-height: 400px; /* fallback minimo */
}

/* Fix modal che usano 100vh */
.modal-content.modal-dimensions {
    max-height: 90vh;
    max-height: -webkit-fill-available;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}


/* ============================================================
   5. PREFISSI WEBKIT MANCANTI
   Proprieta CSS che richiedono ancora prefissi per Safari.
   ============================================================ */

/* Smooth scrolling per aree scrollabili iOS */
.scrollable-area,
.card-body,
.modal-body,
.it-page-sections-container {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Fix immagini in flex container */
.flex-image,
.feature-card img,
.img-fluid {
    max-width: 100%;
    height: auto;
    -webkit-flex-shrink: 1;
    flex-shrink: 1;
    min-width: 0;
}

/* Animazioni con prefissi WebKit */
@-webkit-keyframes spin {
    0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}

/* Fix per position: sticky su Safari */
.it-header-wrapper,
.it-header-navbar-wrapper {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Touch action per evitare delay 300ms su iOS */
a, button, input[type="submit"], .btn {
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    touch-action: manipulation;
}

/* Fix font rendering su Safari/Retina */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}


/* ============================================================
   SAFARI FEATURE DETECTION
   Codice specifico solo per Safari/WebKit via @supports
   ============================================================ */

@supports (-webkit-appearance: none) {
    /* Fix specifico Safari per gap in flexbox (supportato solo da Safari 14.1+) */
    .d-flex.gap-3 {
        gap: 1rem;
    }

    /* Hardware acceleration per animazioni smooth su Safari */
    .safari-specific,
    .loaderx {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}
