/* =========================================================
   FINPLUS OSTIA - Mobile Races layout fix v3
   Fix:
   - riduce lo spazio tra PDF elenco gare e box ricerca
   - su mobile mostra Gestione Gara agli istruttori/coach
   - mantiene nascosta Gestione Gara ai nuotatori, apribile via pulsante
   ========================================================= */

@media (max-width: 820px) {
  /* Riduce il vuoto verticale sotto il pulsante PDF elenco gare */
  #racesView > .card > .card-head {
    padding-bottom: 6px !important;
    margin-bottom: 0 !important;
  }

  #racesView > .card > .card-body {
    padding-top: 4px !important;
  }

  #exportRaceListBtn {
    margin-bottom: 0 !important;
  }

  #racesView .race-toolbar {
    top: 108px !important;
    margin-top: 0 !important;
    margin-bottom: 10px !important;
  }

  #racesView .mobile-race-helper {
    margin-top: 0 !important;
    margin-bottom: 8px !important;
  }

  /* Default mobile: il form gestione gare resta nascosto per profili non coach */
  body:not(.mobile-race-coach):not(.mobile-race-editor-open) #raceEditorCard {
    display: none !important;
  }

  /* Coach/istruttore: il form gestione gare resta visibile su mobile */
  body.mobile-race-coach #raceEditorCard {
    display: block !important;
    order: 2 !important;
  }

  /* Coach/istruttore: il pulsante toggle non serve */
  body.mobile-race-coach #mobileRaceEditorToggle {
    display: none !important;
  }

  /* Se non coach, il toggle resta visibile */
  body:not(.mobile-race-coach) #mobileRaceEditorToggle {
    display: inline-flex !important;
  }

  /* Compatta un po' il form su mobile coach */
  body.mobile-race-coach #raceEditorCard .card-head,
  body.mobile-race-coach #raceEditorCard .card-body {
    padding: 12px !important;
  }
}
