/**
 * AIESEC Hub — ottimizzazioni mobile globali
 * (layout.html, login standalone, landing)
 */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  min-width: 0;
}

/* Riduce ritardo tap su link/bottoni (Safari) */
a,
button,
[role="button"],
.theme-badge,
input[type="submit"] {
  touch-action: manipulation;
}

/* iOS Safari: font < 16px sugli input causa zoom indesiderato al focus */
@media (max-width: 640px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="range"]):not([type="file"]),
  select,
  textarea {
    font-size: max(1rem, 16px) !important;
  }
}

/* Header: rispetta notch / Dynamic Island */
.aiesec-app-header {
  padding-top: max(0px, var(--safe-top));
  padding-left: max(0px, var(--safe-left));
  padding-right: max(0px, var(--safe-right));
}

/* Footer sopra home indicator */
.aiesec-app-footer {
  padding-bottom: max(1.5rem, calc(0.5rem + var(--safe-bottom)));
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
}

/* Wrapper tabelle (anche iniettato via JS) */
.aiesec-table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin-bottom: 1rem;
}

.aiesec-table-scroll table {
  width: max-content;
  min-width: 100%;
}

/* Touch target minimo ~44px per badge header (mobile) */
@media (max-width: 768px) {
  header.theme-header .theme-badge {
    min-height: 44px;
    min-width: 44px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Dropdown area: non uscire dallo schermo */
  #area-select-dropdown {
    max-height: min(70vh, 28rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Flash / alert: testi lunghi */
[role="alert"] .aiesec-alert-text {
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
}

/* Modali full-screen friendly */
@media (max-width: 640px) {
  #pin-modal .aiesec-modal-panel,
  #member-settings-modal .aiesec-modal-panel {
    max-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
