/*
    STYLE
*/

/* Google Fonts Poppins is now loaded via <link> in head_pages.php with display=swap */
body {
    font-family: 'Poppins', sans-serif;
    background: #fafafa;
}

p {
    font-family: 'Poppins', sans-serif;
    font-size: 1.0em;
    font-weight: 200;
    line-height: 1.4em;
    color: #999;
}


/*restringo lo spazio  tra le celle in tabella */
.table td, .table th {
padding: 0.35rem;
}
/*dimensione carattere tabelle*/
.table-sm td,.table-sm th{
	font-size:0.88em
}

/* scrollbars — desktop: 8px con thumb in palette app (agganciabile col mouse).
   Tablet/touch: nascosta, lo scroll avviene via swipe (app è tablet-first). */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: #0059B2;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #004a96;
}
::-webkit-scrollbar-track {
  background: #eef2f7;
}

@media (hover: none) and (pointer: coarse) {
  ::-webkit-scrollbar { width: 0; height: 0; }
  * { scrollbar-width: none; }
}

a,
a:hover,
a:focus {
    color: inherit;
    text-decoration: none;
    transition: all 0.3s;
}

.navbar {
    padding: 10px 5px;
    background: #fff;
    border: none;
    border-radius: 0;
    margin-bottom: 5px;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.navbar-btn {
    box-shadow: none;
    border: none;
}

/* Accessibilità: focus visibile da tastiera (WCAG 2.4.7).
   Non si rimuove l'outline di default — si differenzia solo da :focus generico
   (mouse) per non mostrare il ring sui click del mouse. */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #0059B2;
    outline-offset: 2px;
}

/* Righe tabella cliccabili — feedback hover + cursore.
   Applicare la classe a <tr> con onclick per uniformare il comportamento. */
.fides-row-clickable { cursor: pointer; }
.fides-row-clickable:hover { background-color: rgba(0, 89, 178, 0.05); }

/* Empty state — icona attenuata sopra titolo + sottotitolo.
   Vedi UI Rules → Stati vuoti per il pattern completo. */
.fides-empty-state-icon { opacity: 0.5; }

/* Flash di riga aggiornata via AJAX (UX Patterns §Micro-interazioni tabelle).
   Bootstrap .table-success cura il caso <tr>/<td>; questa classe fallback
   applica il fade per elementi non-table (es. .esito-item) — viene aggiunta
   e rimossa da Fides.flashRow() in fides-utils.js. */
.fides-row-flash:not(tr):not(td) {
    background-color: #d4edda !important;
    transition: background-color 0.4s ease-out;
}

.line {
    width: 100%;
    height: 1px;
    border-bottom: 1px dashed #ddd;
    margin: 40px 0;
}

/* ---------------------------------------------------
    SIDEBAR STYLE
----------------------------------------------------- */

.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: 370px;
    max-width: 370px;
    background: #0059B2;
    color: #fff;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Desktop: .active = menu collassato fuori schermo. Su mobile (≤968px) .active = aperto (vedi media query). */
@media (min-width: 969px) {
    #sidebar.active {
        margin-left: -370px;
    }
}

#sidebar .sidebar-header {
    padding: 5px;
    background: #0059B2;
}

.fides-sidebar-close {
    display: none;
}

#sidebar ul.components {
    padding: 5px 0;
    border-bottom: 1px solid #47748b;
}

#sidebar ul p {
    color: #fff;
    padding: 10px;
}

#sidebar ul li a {
    padding: 10px;
    font-size: 1.1em;
    display: block;
}

#sidebar ul li a:hover {
    color: #0059B2;
    background: #fff;
}

#sidebar ul li.active>a,
a[aria-expanded="true"] {
    color: #fff;
    background: #0059B2;
}


/************************************/


#sidebarright {
    min-width: 280px;
    max-width: 800px;
    background: #fff;
    color: #0059B2;
    transition: all 0.3s;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}







a[data-toggle="collapse"] {
    position: relative;
}

.dropdown-toggle::after {
    display: block;
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

ul ul a {
    font-size: 0.9em !important;
    padding-left: 30px !important;
    background: #0059B2;
}

ul.CTAs {
    padding: 20px;
}

ul.CTAs a {
    text-align: center;
    font-size: 0.9em !important;
    display: block;
    border-radius: 5px;
    margin-bottom: 5px;
}

a.download {
    background: #fff;
    color: #0059B2;
}

a.article,
a.article:hover {
    background: #0059B2 !important;
    color: #fff !important;
}

/* ---------------------------------------------------
    CONTENT STYLE
----------------------------------------------------- */

#content {
    width: 100%;
    padding: 20px;
    min-height: 100vh;
    transition: all 0.3s;
}

/* ---------------------------------------------------
    MEDIAQUERIES
----------------------------------------------------- */

@media (max-width: 968px) {
    /* Menu sinistro: overlay fisso; il toggle in #content resta raggiungibile via backdrop/X */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(370px, 90vw);
        max-width: 90vw;
        margin-left: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }
    #sidebar.active {
        margin-left: 0;
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.2);
    }
    .fides-sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }
    .fides-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1039;
        background: rgba(0, 0, 0, 0.35);
        border: 0;
        padding: 0;
        cursor: pointer;
    }
    .fides-sidebar-backdrop.is-visible {
        display: block;
    }
    body.fides-sidebar-nav-open {
        overflow: hidden;
    }
    .wrapper > #content {
        width: 100%;
        flex: 1 1 100%;
        min-width: 0;
    }
    #sidebarCollapse span {
        display: none;
    }
}

/* Linguetta MENU solo su index.php: la selezione pratica apre già il drawer destro.
   Le pagine pratica (sidebarright_menu.php) mantengono .fides-drawer-handle visibile. */
@media (max-width: 1024px) {
    .fides-index-page .fides-index-drawer-handle {
        display: none !important;
    }
}


.upload-btn-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
  text-align:center;
  float:center;
}

.btn_border {
  border: 2px solid gray;
  color: gray;
  background-color: white;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: bold;
}

.upload-btn-wrapper input[type=file]  {
  font-size: 100px;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
}
.upload-btn-wrapper  input[type=submit] {
  font-size: 100px;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
}

.btn {
  border: 2px solid ;
  /*color: gray; */
  /*background-color: white;*/
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
}

/* =============================================================================
 * .auth-card — stili condivisi tra login.php e change_password.php
 * Le pagine aggiungono solo le proprie regole specifiche (es. width della card,
 * strength meter, reason banner, ecc.).
 * ============================================================================= */
.auth-card .input-group-text { background-color: #f8f9fa; }
.auth-card .input-group-prepend .input-group-text { border-right: 0; }
.auth-card .form-control { border-left: 0; }
.auth-card .form-control:focus {
  box-shadow: none;
  border-color: #ced4da;
}
.auth-card .input-group:focus-within .input-group-text,
.auth-card .input-group:focus-within .form-control {
  border-color: #80bdff;
  box-shadow: 0 0 0 0.15rem rgba(0, 123, 255, 0.15);
}
.auth-card .password-toggle {
  border-left: 0;
  color: #6c757d;
  cursor: pointer;
}
.auth-card .password-toggle:hover,
.auth-card .password-toggle:focus {
  color: #0059B2;
  background-color: #e9ecef;
}
.auth-card .btn-submit {
  padding: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.auth-card .btn-submit .spinner-border {
  display: none;
  vertical-align: -0.15em;
  margin-right: 0.4rem;
}
.auth-card .btn-submit.is-loading .spinner-border { display: inline-block; }
.auth-card .btn-submit.is-loading .btn-label-default { display: none; }
.auth-card .btn-submit .btn-label-loading { display: none; }
.auth-card .btn-submit.is-loading .btn-label-loading { display: inline; }
.auth-card .caps-warning {
  display: none;
  font-size: 0.78rem;
  color: #856404;
  margin-top: -0.5rem;
  margin-bottom: 0.75rem;
}
.auth-card .caps-warning.active { display: block; }
.auth-card .alert-auth {
  padding: 0.6rem 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  gap: 0.5rem;
}
.auth-card .alert-auth i {
  flex-shrink: 0;
  margin-top: 2px;
}

/* =============================================================================
 * Modern auth pages (login, change_password, appauth) — Twilio-inspired layout
 * Attivare con <body class="auth-bg"> e .auth-card-modern al posto di .card.
 * ============================================================================= */
body.auth-bg {
  background: linear-gradient(135deg, #002a5c 0%, #0059B2 60%, #0073e6 100%);
  background-attachment: fixed;
  min-height: 100vh;
  margin: 0;
}
.auth-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  /* Safe-area iPhone con home indicator: `env(safe-area-inset-bottom)` vale 0
   * sui browser/dispositivi che non lo supportano → nessun effetto altrove. */
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}
.auth-card-modern {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 440px;
  padding: 2.25rem 2rem;
}
.auth-card-modern.auth-card-wide { max-width: 520px; }
.auth-logo { text-align: center; margin-bottom: 0.75rem; }
.auth-logo img { max-width: 160px; height: auto; }
.auth-title {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 500;
  color: #212529;
  letter-spacing: -0.2px;
  margin: 0.25rem 0 0.4rem;
}
.auth-subtitle {
  text-align: center;
  color: #6c757d;
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

/* Floating-label input */
.float-field {
  position: relative;
  margin-bottom: 1rem;
}
.float-field input {
  width: 100%;
  padding: 1.4rem 0.85rem 0.5rem;
  font-size: 1rem;
  line-height: 1.25;
  border: 1px solid #ced4da;
  border-radius: 6px;
  background: #fff;
  color: #212529;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}
.float-field input:focus {
  outline: none;
  border-color: #0059B2;
  box-shadow: 0 0 0 3px rgba(0, 89, 178, 0.15);
}
.float-field label {
  position: absolute;
  top: 1rem;
  left: 0.75rem;
  color: #6c757d;
  font-size: 1rem;
  pointer-events: none;
  background: #fff;
  padding: 0 0.3rem;
  transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease;
}
.float-field input:focus + label,
.float-field input:not(:placeholder-shown) + label {
  top: -0.55rem;
  font-size: 0.75rem;
  color: #0059B2;
}
.float-field input[readonly] + label {
  top: -0.55rem;
  font-size: 0.75rem;
  color: #6c757d;
}
.float-field.has-toggle input { padding-right: 2.75rem; }
.float-field .password-toggle {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: #6c757d;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.float-field .password-toggle:hover,
.float-field .password-toggle:focus {
  color: #0059B2;
  background: #e9ecef;
  outline: none;
}

/* Primary CTA */
.btn-auth-primary {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #0059B2;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  letter-spacing: 0.2px;
  text-align: center;
}
.btn-auth-primary:hover:not(:disabled) { background: #004a96; }
.btn-auth-primary:focus { outline: 3px solid rgba(0, 89, 178, 0.3); outline-offset: 0; }
.btn-auth-primary:disabled { background: #8aafd6; cursor: not-allowed; }
.btn-auth-primary .spinner-border {
  display: none;
  vertical-align: -0.15em;
  margin-right: 0.4rem;
}
.btn-auth-primary.is-loading .spinner-border { display: inline-block; }
.btn-auth-primary.is-loading .btn-label-default { display: none; }
.btn-auth-primary .btn-label-loading { display: none; }
.btn-auth-primary.is-loading .btn-label-loading { display: inline; }

/* Secondary link */
.auth-link-secondary {
  display: inline-block;
  font-size: 0.9rem;
  color: #0059B2;
  margin-bottom: 1.25rem;
  text-decoration: none;
}
.auth-link-secondary:hover,
.auth-link-secondary:focus {
  color: #004a96;
  text-decoration: underline;
}

/* Caps lock warning + alerts dentro auth-card-modern */
.auth-card-modern .caps-warning {
  display: none;
  font-size: 0.8rem;
  color: #856404;
  background: #fff8e1;
  border: 1px solid #ffe58f;
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  margin: -0.25rem 0 1rem;
}
.auth-card-modern .caps-warning.active { display: block; }
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin-top: 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.auth-alert i { margin-top: 2px; flex-shrink: 0; }
.auth-alert-danger  { background: #fdecea; color: #721c24; border-color: #f5c6cb; }
.auth-alert-success { background: #e8f5e9; color: #155724; border-color: #c3e6cb; }
.auth-alert-warning { background: #fff8e1; color: #6d4c00; border-color: #ffe58f; }
.auth-alert-info    { background: #e8f4fd; color: #004085; border-color: #b8daff; }

/* Cloudflare Turnstile — centratura nel container. Il sizing del widget è
 * delegato a `data-size="normal"` (attributo del div .cf-turnstile): widget
 * a larghezza fissa (300x65). Evitato `flexible` perché il widget legge le
 * dimensioni del parent frame cross-origin per auto-resize, scatenando
 * SecurityError/CSP noise nella console (Safari + spec-compliant browsers).
 * Non stilizziamo l'iframe interno perché ne può cambiare la struttura DOM
 * ad ogni release del widget Cloudflare. */
.auth-turnstile {
  display: flex;
  justify-content: center;
  margin-top: 0.25rem;
  min-height: 65px;
}
/* Hint testuale sotto al widget — guida l'utente sullo stato della verifica */
.auth-turnstile-hint {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: #6c757d;
  margin: -0.5rem 0 0.75rem;
  justify-content: center;
}
/* Stati `data-state` allineati con `STATE` in public/login.php (Turnstile callbacks):
 * pending (default), ok, err. Modificare entrambi i punti se si rinomina uno stato. */
.auth-turnstile-hint[data-state="ok"]  { color: #155724; }
.auth-turnstile-hint[data-state="err"] { color: #721c24; }

/* Orari di accesso mostrati quando il servizio è chiuso */
.auth-outage-subtitle {
  font-size: 0.9rem;
  color: #495057;
  margin: 0.5rem 0 0.5rem;
}
.auth-outage-hours {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 280px;
  font-size: 0.88rem;
  color: #212529;
  text-align: left;
}
.auth-outage-hours li {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid #f0f0f0;
}
.auth-outage-hours li:last-child { border-bottom: none; }

/* Banner di pre-scadenza sessione (mostrato negli ultimi 5 min) */
#fidesSessionWarn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1080; /* sopra modali Bootstrap (1050) */
  display: none;
  align-items: center;
  gap: 0.6rem;
  background: #fff8e1;
  color: #6d4c00;
  border: 1px solid #ffe58f;
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  max-width: calc(100vw - 2rem);
}
#fidesSessionWarn.is-visible { display: flex; }
#fidesSessionWarn i { color: #b58800; }
#fidesSessionWarn strong { color: #5a3e00; }
#fidesSessionWarn .btn { white-space: nowrap; }
/* Stato scaduta — colori più allarmati (rosso) per distinguere dal warning */
#fidesSessionWarn.is-expired {
  background: #fdecea;
  color: #721c24;
  border-color: #f5c6cb;
}
#fidesSessionWarn.is-expired i { color: #c0392b; }

/* Stato "servizio non disponibile" sulla pagina di login */
.auth-outage {
  text-align: center;
  padding: 0.75rem 0 0.25rem;
}
.auth-outage-icon {
  color: #0059B2;
  font-size: 2.25rem;
  margin-bottom: 1rem;
  opacity: 0.85;
}
.auth-outage-title {
  font-size: 1.2rem;
  font-weight: 500;
  color: #212529;
  margin: 0;
  line-height: 1.3;
}

/* Footer minimale */
.auth-footer {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.78);
  text-align: center;
}
.auth-footer a { color: rgba(255, 255, 255, 0.95); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .auth-card-modern { padding: 1.75rem 1.25rem; }
  .auth-title { font-size: 1.4rem; }
}

/* =============================================================================
 * INDEX — elenco pratiche: occupa l’altezza viewport (non la larghezza totale).
 * Con drawer destro aperto l’elenco resta nella colonna centrale.
 * ============================================================================= */
.fides-index-page .wrapper {
  min-height: 100dvh;
}
.fides-index-page .wrapper > #content {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.fides-index-page #elenco_pratiche {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.fides-index-page #elenco_pratiche .table-responsive {
  flex: 1 1 auto;
  min-height: 0;
}
.fides-index-page #frmelenco_pratiche {
  width: 100%;
  height: 100% !important;
  min-height: 280px;
  border: 0;
}

/* =============================================================================
 * INDEX — toolbar elenco pratiche (index.php)
 * Mobile/tablet: 2 righe compatte. Desktop: una riga orizzontale.
 * ============================================================================= */
.fides-index-nav {
  padding: 0;
  margin-bottom: 0.5rem;
}
.fides-index-nav .container-fluid.fides-index-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.5rem;
  width: 100%;
}
.fides-index-menu-btn {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
}
.fides-index-search-wrap {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 10rem;
}
.fides-index-search-wrap .form-control {
  flex: 1 1 auto;
  width: 100%;
  min-width: 6rem;
  min-height: 44px;
}
.fides-index-search-btn {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
}
.fides-index-actions {
  display: flex;
  flex: 1 1 100%;
  gap: 0.5rem;
}
.fides-index-action-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
  min-height: 44px;
  padding: 0.35rem 0.5rem;
  border: 1px solid #dee2e6;
  border-radius: 0.35rem;
  background: #fff;
  color: #0059B2;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
}
.fides-index-action-btn:hover,
.fides-index-action-btn:focus {
  background: #eef2f7;
  color: #004080;
  text-decoration: none;
}
.fides-index-action-btn .fas {
  font-size: 1.1rem;
}
.fides-index-action-badge {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
@media (min-width: 1025px) {
  .fides-index-nav .container-fluid.fides-index-toolbar {
    flex-wrap: nowrap;
    align-items: center;
  }
  .fides-index-actions {
    flex: 0 0 auto;
    max-width: none;
  }
  .fides-index-action-btn {
    flex: 0 1 auto;
    min-width: 7rem;
  }
}
@media (max-width: 1024px) {
  .fides-index-nav .container-fluid.fides-index-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "menu search"
      "actions actions";
    align-items: stretch;
  }
  .fides-index-menu-btn {
    grid-area: menu;
  }
  .fides-index-search-wrap {
    grid-area: search;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .fides-index-actions {
    grid-area: actions;
    flex: none;
    width: 100%;
  }
  .fides-index-page #sidebarRightToggle.fides-index-sidebar-toggle-legacy {
    display: none !important;
  }
  .fides-index-page #content {
    padding: 8px;
  }
  .fides-index-page #elenco_pratiche .table-responsive {
    height: calc(100dvh - var(--fides-index-chrome-height, 7.5rem));
    min-height: 280px;
  }
}

/* Bottone collapse sidebar destro — usato in index.php, note_esiti.php, sidebarright_menu.php */
.fides-sidebar-toggle-btn {
  border: 0;
  background-color: #ddd;
  max-width: 20px;
  padding: 5px;
}
.fides-sidebar-toggle-btn-abs {
  right: 0;
  top: 15px;
  position: absolute;
}

/* Header pratica (dettaglio_pratica.php) — striscia compatta con badge */
.fides-pratica-header .badge {
  font-size: 0.85em;
  padding: 0.4em 0.65em;
}
.fides-pratica-badges { gap: 0.35rem; }

/* Card-body del mandato — viewer/text occupano tutta l'altezza disponibile.
   Fallback `vh` per browser senza supporto `dvh`; `dvh` (dynamic viewport)
   evita che la barra mobile di Safari/Chrome schiacci il viewer.
   `min-height` protegge i casi edge (viewport molto basse o iframe height
   che collassa). `min-height: 0` sui figli flex permette al viewer di
   scrollare senza overflow del parent. */
.fides-mandato-body {
  min-height: 500px;
  height: calc(100vh - 240px);
  height: calc(100dvh - 240px);
  display: flex;
  flex-direction: column;
}
.fides-mandato-body > iframe,
.fides-mandato-body > pre { flex: 1 1 auto; margin: 0; min-height: 0; }

/* Iframe viewer mandato PDF (dettaglio_pratica.php) */
.fides-mandato-iframe {
  width: 100%;
  border: none;
}

/* Visualizzazione testo mandato (dettaglio_pratica.php) */
.fides-mandato-text {
  background: #fff;
  color: #333;
  padding: 15px;
  border: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.95em;
  overflow: auto;
}

/* Semafori scadenza riga (elenco_posizioni_multiple.php, treeview pratiche) */
.fides-row-scaduta { color: #fff; background-color: #FF0000; }
.fides-row-warning { color: #000; background-color: #FFFF00; }

/* =============================================================================
 * TABLET OPTIMIZATIONS (≤1024px viewport)
 * Si attiva su iPad/Android tablet e finestre desktop ristrette.
 * Desktop tradizionale (>1024px) non viene toccato.
 * ============================================================================= */
@media (max-width: 1024px) {
  /* Densità maggiore per i card in #content: il padding default Bootstrap
     (1.25rem) spreca spazio orizzontale prezioso accanto a #sidebar (370px)
     + #sidebarright (min 280px). Scope ristretto a #content per non toccare
     altri card (es. dentro modali). */
  #content .card-body { padding: 0.75rem; }
  #content .card-header { padding: 0.5rem 0.75rem; }
  /* Mandato: riduco il calcolo di altezza per compensare la striscia header
     pratica + densità ridotta. */
  #content .fides-mandato-body { height: calc(100dvh - 200px); }

  /* Modali con inline `min-width` / `width:X%` (es. menu.php, sidebarright_menu.php,
     index.php, pagamenti.php) eccedono la viewport tablet. Forziamo fluid sizing
     con !important per battere gli style inline. */
  .modal-dialog {
    width: auto !important;
    max-width: calc(100vw - 1rem) !important;
    min-width: 0 !important;
    margin: 0.5rem auto !important;
  }
  /* 100dvh (dynamic viewport height) si aggiorna quando appare la tastiera
     virtuale; 100vh resta come fallback per browser senza supporto dvh.
     Scope ristretto a `.modal-dialog > .modal-content > .modal-body`: alcuni
     file pagina riusano `class="modal-body"` come wrapper interno dentro un
     iframe child (es. invio_coordinate.php, genera_effetti.php), dove 100vh
     corrisponde all'altezza ridotta dell'iframe — la regola applicata lì
     causava scrollbar/clipping del contenuto (vedi PR #490). */
  .modal-dialog > .modal-content > .modal-body {
    max-height: calc(100vh - 8rem);
    max-height: calc(100dvh - 8rem);
    overflow-y: auto;
  }

  /* Sidebar destra (index.php usa <div id="sidebarright"> standalone):
     overlay full-width sotto 1024px. La toolbar pages-pratica usa invece
     <dialog id="drawerRight"> (vedi sotto). */
  #sidebarright {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 90vw;
    max-width: 500px;
    z-index: 1030;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
  }
  #sidebarright.fides-sidebarright-open {
    display: flex;
  }

  /* Toggle button storico di index.php (#sidebarRightToggle): sta nel flex
     flow accanto al sidebar. Quando #sidebarright diventa overlay
     (position:fixed sopra), il button verrebbe coperto e l'utente non
     potrebbe più chiudere l'overlay. Lo fissiamo top-right con z-index
     sopra il sidebar → resta sempre tappabile. Le pagine pratica usano
     invece <dialog id="drawerRight"> (vedi sotto) e questa regola non
     le riguarda. */
  .fides-sidebar-toggle-btn {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 1031;
  }
}

/* Drawer destro nativo — sidebarright_menu.php (pratica pages).
   Su desktop display:contents rende il <dialog> trasparente al layout
   e #sidebarright dentro funge da flex item del wrapper di pagina.
   Su tablet :not(:modal) lo nasconde finché showModal() non lo promuove.
   index.php desktop: colonna flex come originale; toggle .fides-sidebarright-open apre/chiude
   (Bootstrap .d-flex altrimenti ignora display:none). */
#drawerRight[open] {
  display: contents;
}
@media (min-width: 1025px) {
  .fides-index-page #drawerRight #sidebarright:not(.fides-sidebarright-open) {
    display: none !important;
    min-width: 0 !important;
    max-width: 0 !important;
    width: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: none !important;
  }
  .fides-index-page #drawerRight #sidebarright.fides-sidebarright-open {
    display: flex !important;
    flex-direction: column;
    align-self: stretch;
    min-width: 280px;
    max-width: 800px;
    min-height: 100dvh;
  }
}

.fides-drawer-handle { display: none; }
.fides-drawer-close-form { display: none; margin: 0; }

@media (max-width: 1024px) {
  #drawerRight {
    display: revert;
  }
  #drawerRight:not(:modal) { display: none; }

  #drawerRight:modal {
    padding: 0;
    border: 0;
    margin: 0;
    margin-left: auto;
    margin-right: 0;
    inset: 0 0 0 auto;
    height: 100dvh;
    max-height: 100dvh;
    width: 320px;
    max-width: 85vw;
    background: transparent;
    overflow: visible;
    transition:
      transform 0.3s ease,
      overlay 0.3s ease allow-discrete,
      display 0.3s ease allow-discrete;
    transform: translateX(0);
  }
  @starting-style {
    #drawerRight:modal { transform: translateX(100%); }
  }

  #drawerRight::backdrop {
    background: rgba(0, 0, 0, 0.35);
    transition:
      background-color 0.3s ease,
      display 0.3s ease allow-discrete,
      overlay 0.3s ease allow-discrete;
  }
  @starting-style {
    #drawerRight:modal::backdrop { background: rgba(0, 0, 0, 0); }
  }

  /* Override delle regole #sidebarright soprastanti (overlay per index.php):
     dentro al drawer il sidebar deve riempire il <dialog>, non posizionarsi fixed. */
  #drawerRight #sidebarright {
    display: flex;
    position: static;
    top: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    height: 100%;
    max-width: none;
    z-index: auto;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.18);
    border-left: 0;
  }

  .fides-drawer-handle,
  #drawerRight .fides-drawer-close {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 84px;
    padding: 0;
    background: #0059B2;
    color: #fff;
    border: 0;
    border-radius: 6px 0 0 6px;
    box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
  }
  .fides-drawer-handle:hover,
  #drawerRight .fides-drawer-close:hover {
    background: #004080;
    color: #fff;
  }
  .fides-drawer-handle {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 10;
  }
  .fides-drawer-close-form {
    display: block;
    position: absolute;
    top: 50%;
    left: -32px;
    transform: translateY(-50%);
    margin: 0;
  }
  #drawerRight .fides-drawer-close { position: relative; }

  .fides-drawer-handle-lbl {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    margin-top: 6px;
    font-weight: 500;
    text-transform: uppercase;
    opacity: 0.9;
  }
}

/* Form a colonne strette: col-md-2 / col-md-3 con input dentro diventano
   inutilizzabili sotto 768px (input ~80px effettivi). Stack a 2 colonne. */
@media (max-width: 768px) {
  .form-row > .col-md-2,
  .form-row > .col-md-3 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* dettaglio_pratica — densità più alta su tablet portrait */
  #content .fides-mandato-body {
    height: calc(100vh - 220px);
    height: calc(100dvh - 220px);
    min-height: 400px;
  }
}

/* Mobile (≤576px) — Android/iPhone in portrait */
@media (max-width: 576px) {
  #content { padding: 8px; }
  #content .card { margin-bottom: 0.5rem !important; }
  #content .fides-pratica-header .badge {
    font-size: 0.78em;
    padding: 0.35em 0.55em;
  }
  #content .fides-pratica-header h5 { font-size: 1rem; }
  #content .fides-mandato-body {
    height: calc(100vh - 280px);
    height: calc(100dvh - 280px);
    min-height: 360px;
  }
}

/* iOS Safari — safe area per notch/home indicator (iPhone X+) */
@supports (padding: env(safe-area-inset-top)) {
  #sidebar {
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* =============================================================================
 * TOUCH INPUT (dito come puntatore primario)
 * Indipendente dalla viewport: copre iPad, tablet Android, Surface in modalità
 * touch, telefoni. Desktop con mouse/trackpad non vede queste regole.
 * ============================================================================= */
@media (pointer: coarse) {
  /* Hit target 44×44 — soglia Apple HIG (44pt) e Material Design (48dp ≈ 44px).
     I .btn-sm in tabella sono ~24px di default. */
  .btn-sm,
  .table .btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Padding più ampio in celle di .table-sm per facilitare il tap su righe
     onclick (elenco_pagamenti.php, pagamenti.php, elenco_pratiche.php). */
  .table-sm td,
  .table-sm th {
    padding: 0.6rem 0.4rem;
  }

  /* Disabilita il delay di 300ms del double-tap-zoom su Android Chrome
     (su iOS Safari è già rimosso dal meta viewport user-scalable=0). */
  .btn,
  a,
  [role="button"],
  .fides-row-clickable,
  tr[onclick] {
    touch-action: manipulation;
  }

}

/* =============================================================================
 * AUTH PAGES — MOBILE / TABLET OPTIMIZATIONS
 * Login (login.php), 2FA (appauth.php), cambio password (change_password.php).
 * Indirizza tap targets touch, viewport corti (landscape phone), autozoom
 * iOS Safari, overflow Turnstile. (Safe-area è inline su `.auth-container`.)
 * ============================================================================= */

/* Viewport corti in orientation landscape su schermi stretti: il form 2FA
 * con QR + secret + input + countdown + bottone non entra in 375px di
 * altezza. Permettiamo scroll naturale e riduciamo il padding verticale.
 * 100dvh (dynamic viewport) si aggiorna con la tastiera virtuale aperta.
 *
 * Restrizione voluta: `landscape` + `max-width: 900px` esclude i laptop
 * desktop (es. 1366×768 o MacBook Air 1440×900 con DevTools) che pure
 * matcherebbero `max-height: 720px`. Sui veri tablet/phone landscape la
 * larghezza è ≤ ~900px, quindi il guard non perde target legittimi. */
@media (max-height: 720px) and (orientation: landscape) and (max-width: 900px) {
  .auth-container {
    min-height: 100dvh;
    justify-content: flex-start;
    padding-top: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }
  .auth-card-modern { padding: 1.5rem 1.5rem; }
  .auth-logo        { margin-bottom: 0.25rem; }
  .auth-logo img    { max-width: 120px; }
  .auth-title       { font-size: 1.25rem; margin: 0.1rem 0 0.25rem; }
  .auth-subtitle    { margin-bottom: 1rem; font-size: 0.88rem; }
}

/* Viewport molto stretti (es. Galaxy Fold chiuso 280px, iPhone SE 320px):
 * il widget Turnstile è fisso a 300px (`data-size="normal"`, vedi
 * login.php) e sfora la card. Riduciamo il padding orizzontale della
 * card e estendiamo il container del widget oltre il padding con un
 * margin negativo.
 *
 * Trade-off: il margin negativo è preferito a `transform: scale()` perché
 * la trasformazione CSS sull'iframe Cloudflare può rompere il calcolo
 * dei click coordinates del challenge in alcune versioni del widget.
 * Lo sforamento di -0.35rem rientra dentro l'area `border-radius: 12px`
 * della card e non taglia il widget (visivamente impercettibile). */
@media (max-width: 359px) {
  .auth-container       { padding-left: 0.5rem; padding-right: 0.5rem; }
  .auth-card-modern     { padding: 1.5rem 0.85rem; }
  .auth-turnstile       { margin-left: -0.35rem; margin-right: -0.35rem; }
  .otp-card .otp-input  { font-size: 1.15rem; letter-spacing: 0.25rem; }
}

/* Touch input — Hit target 44×44 sui controlli ausiliari dell'auth.
 * Compatibile con @media (pointer: coarse) già sopra. */
@media (pointer: coarse) {
  /* Toggle "mostra password": l'icona resta 1rem ma l'area tappabile
     si espande a 44×44. Non aumentiamo `width` per non disallineare
     visivamente l'icona — usiamo solo padding e `min-*`. */
  .float-field .password-toggle {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    right: 0.2rem;
  }
  /* Compensiamo il padding-right dell'input per non sovrapporre il
     toggle al testo digitato. */
  .float-field.has-toggle input { padding-right: 3.25rem; }

  /* Bottone copia chiave OTP — tap target 44×44 senza ingrandire icona. */
  .otp-card .btn-copy {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
  }

  /* Link "Hai dimenticato la password?" / "Annulla e torna al login":
     padding verticale per raggiungere ~44px tappabili. */
  .auth-link-secondary {
    display: inline-block;
    padding: 0.6rem 0.25rem;
    min-height: 44px;
  }

  /* Checkbox "Ricorda questo dispositivo per oggi": label più alta e
     checkbox ingrandito per facilitare il tap. */
  .otp-card .remember-group label {
    padding: 0.4rem 0;
    min-height: 44px;
    gap: 0.6rem;
  }
  .otp-card .remember-group input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
  }

  /* CTA principale: già 44px+ via padding 0.85rem, ma esplicitiamo
     per coerenza e per battere eventuali override. */
  .btn-auth-primary { min-height: 48px; }
}

/* iOS Safari autozoom prevention: se un input ha font-size < 16px,
 * Safari fa autozoom al focus rompendo il layout. Tutti gli input
 * auth devono essere ≥ 16px su mobile. `1rem` lo è già (root = 16px)
 * ma esplicitiamo `16px` per difesa contro eventuali override di
 * `html { font-size }` futuri. Applicato solo su mobile per non
 * alterare la tipografia desktop. */
@media (max-width: 767px) {
  /* `.otp-input` è già 1.5rem (= 24px su root 16px) e a ≤576px diventa
     1.3rem (= 20.8px) via inline <style> in appauth.php — entrambi sopra
     la soglia 16px, nessun autozoom. Qui copriamo solo gli input di
     login/cambio password. */
  .float-field input { font-size: 16px; }
}

/* === Upload form (allega_file.php) — segmented pill-group + CTA elevato.
 * Coerente con stack BS4 + Font Awesome (no nuove dipendenze).
 */
.fides-pill-group {
  background: #f1f3f6;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  box-shadow: none;
}
.fides-pill-group .fides-pill {
  background: transparent;
  border: 0;
  color: #5a6573;
  border-radius: 999px !important;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.fides-pill-group .fides-pill:hover {
  background: #e6ebf1;
  color: #0059B2;
}
.fides-pill-group .fides-pill.active,
.fides-pill-group .fides-pill.focus,
.fides-pill-group .fides-pill:active {
  background: #ffffff;
  color: #0059B2;
  box-shadow: 0 1px 3px rgba(0, 89, 178, 0.15), 0 0 0 1px rgba(0, 89, 178, 0.12);
}
.fides-pill-group .fides-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fides-upload-btn {
  border-radius: 999px;
  padding: 0.6rem 1.75rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 6px rgba(40, 167, 69, 0.25);
  transition: transform .12s ease, box-shadow .15s ease;
}
.fides-upload-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.35);
}
.fides-upload-btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.75;
  transform: none;
  box-shadow: none;
}
