/* ==========================================================
   Responsive Overrides — PC + Smartphone (mobile-first)
   Non tocca il codice PHP! Solo override CSS.
   ========================================================== */
* { box-sizing: border-box; }

/* ---------- VIEWPORT FORZATO (su browser vecchi) ---------- */
@viewport { width: device-width; zoom: 1.0; }
@-ms-viewport { width: device-width; zoom: 1.0; }

/* ---------- BASE RESPONSIVE BODY / HTML ---------- */
html, body {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}
body {
    width: 100% !important;
    max-width: 100% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ---------- CONTENITORI: NIENTE LARGHEZZE FISSE > 100% ---------- */
div[style*="width:"], section[style*="width:"], main[style*="width:"] {
    max-width: 100% !important;
}
div[style*="min-width:"] {
    min-width: 0 !important;
}

/* ---------- IMMAGINI E MEDIA ---------- */
img, picture, video, iframe, svg {
    max-width: 100% !important;
    height: auto !important;
}

/* ---------- TABELLE RESPONSIVE ---------- */
table {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
}
table td, table th {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 80px;
}

/* ---------- FORM E INPUT ---------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="tel"],
input[type="url"],
textarea,
select {
    max-width: 100% !important;
    width: 100% !important;
    min-height: 44px !important;
    font-size: 16px !important; /* no zoom su iOS */
    padding: 10px 12px !important;
    -webkit-appearance: none;
    appearance: none;
}
textarea { min-height: 120px !important; }
input[type="checkbox"], input[type="radio"] {
    width: 20px !important;
    height: 20px !important;
    min-height: 20px !important;
    min-width: 20px !important;
}

/* ---------- BOTTONI ---------- */
button,
input[type="submit"],
input[type="button"],
input[type="reset"],
a[class*="btn"],
a[role="button"],
[onclick]:not(table):not(tr):not(td):not(div[style*="display:grid"]):not(li) {
    min-height: 44px !important;
    padding: 10px 16px !important;
    font-size: 16px !important;
    max-width: 100% !important;
    word-wrap: break-word;
    white-space: normal !important;
}
button, input[type=submit], a.btn-like {
    width: 100%;
    margin-top: 6px;
}

/* ==========================================================
   SCHERMI GRANDI (>= 960px PC)
   ========================================================== */
@media (min-width: 960px) {
    button, input[type=submit], a.btn-like {
        width: auto;
    }
    table { display: table; }
    .desktop-only { display: block !important; }
    .mobile-only { display: none !important; }
}

/* ==========================================================
   TABLET (520px — 959px)
   ========================================================== */
@media (max-width: 959px) and (min-width: 520px) {
    body { font-size: 15px; }
}

/* ==========================================================
   SMARTPHONE (<= 519px)
   ========================================================== */
@media (max-width: 519px) {
    body {
        padding: 8px 10px !important;
        font-size: 15px;
        line-height: 1.45;
    }
    div[style*="grid-template-columns:"],
    div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
    }
    div[style*="display:flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    div[style*="padding:"],
    section[style*="padding:"],
    fieldset {
        padding: 12px 10px !important;
    }
    h1 { font-size: 22px !important; }
    h2 { font-size: 19px !important; }
    h3 { font-size: 17px !important; }
    h4 { font-size: 16px !important; }
    label { font-size: 15px !important; }
    p { font-size: 15px !important; }
    td, th { padding: 8px 6px !important; font-size: 14px; }
    pre, code {
        overflow-x: auto;
        white-space: pre-wrap;
        word-wrap: break-word;
        max-width: 100%;
    }
    iframe { width: 100% !important; }
}

/* ==========================================================
   PAGINE SPECIFICHE ADMIN (event-edit.php + checkin.php)
   ========================================================== */
@media (max-width: 780px) {
    /* Campi admin larghi troppo → colonna singola */
    .row-full, div.row-full[style*="width:100%"],
    div[style*="display:grid"] div,
    div[style*="display: flex;"] div[style*="min-width"] {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-width: 0 !important;
    }
    input[style*="width: 500px"],
    input[style*="width:500px"],
    input[style*="width: 600px"],
    textarea[style*="width: 600px"],
    textarea[style*="width: 800px"],
    div[style*="width: 900px"],
    div[style*="width: 1000px"],
    div[style*="width: 1100px"],
    div[style*="width: 1200px"] {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ---------- HEADER / NAVBAR se troppo stretta ---------- */
header, nav, .header, .navbar, #header, #top {
    max-width: 100% !important;
}

/* ---------- HINT / MESSAGGI PICCOLI ---------- */
.hint, .hint-row, .row-full.hint {
    font-size: 13px !important;
    padding: 8px 10px !important;
}

/* ---------- NIENTE SCROLL ORIZZONTALE MAI ---------- */
html, body, #__next, main, .app, .container, .wrapper {
    overflow-x: hidden !important;
}
