/* =============================================================================
   Rotaract Milano Duomo – Gestionale mobile (check-in in loco)
   Mobile-first, pensato per l'uso con una mano sola. Richiede base.css.
   ============================================================================= */

body.mobile-admin-page {
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  background-color: var(--bg);
  background-image:
    radial-gradient(700px 320px at 0% -5%, rgba(216, 27, 96, 0.1), transparent 65%),
    radial-gradient(500px 260px at 100% 0%, rgba(13, 148, 136, 0.08), transparent 60%);
  -webkit-tap-highlight-color: transparent;
}

.mobile-admin-shell {
  width: min(860px, 100%);
  max-width: 860px;
  gap: 1rem;
}

.mobile-admin-page .toast {
  bottom: calc(1rem + env(safe-area-inset-bottom));
  max-width: min(94vw, 520px);
}

/* -----------------------------------------------------------------------------
   Guard (accesso negato)
   ----------------------------------------------------------------------------- */

.mobile-guard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  padding: 2rem 1.25rem;
}

.mobile-guard h1 {
  font-size: 1.4rem;
}

.mobile-guard p {
  max-width: 32ch;
}

.mobile-guard .btn {
  margin-top: 0.5rem;
  max-width: 320px;
}

.mobile-guard-icon {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-50);
  color: var(--brand-600);
}

.mobile-guard-icon svg {
  width: 1.6rem;
  height: 1.6rem;
}

/* -----------------------------------------------------------------------------
   Shell dell'app
   ----------------------------------------------------------------------------- */

.mobile-admin {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  /* clip (e non hidden) per non rompere la barra sticky "Torna agli eventi" */
  overflow: hidden;
  overflow: clip;
  border-radius: var(--radius-xl);
}

@media (max-width: 640px) {
  .mobile-admin {
    padding: 0;
    border-radius: var(--radius-lg);
  }
}

/* Header compatto */
.mobile-admin-header {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.95rem 1rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--brand-50) 0%, var(--surface) 55%, var(--teal-50) 100%);
}

.mobile-admin-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.mobile-admin-heading > div {
  min-width: 0;
}

.mobile-admin-logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  background: var(--surface);
}

.mobile-admin-header h1 {
  margin: 0;
  font-size: 1.3rem;
}

.mobile-admin-header .badge-subtitle {
  font-size: 0.68rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-admin-header .badge-subtitle:empty {
  display: none;
}

.mobile-admin-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.mobile-top-btn {
  --btn-icon-bg: var(--slate-100);
  --btn-icon-fg: var(--slate-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 48px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.mobile-top-btn:hover {
  background: var(--surface-2);
  text-decoration: none;
  transform: none;
  box-shadow: var(--shadow-xs);
}

.mobile-top-btn:active {
  transform: scale(0.98);
}

.mobile-top-btn > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-top-icon {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-icon-bg);
  color: var(--btn-icon-fg);
  flex-shrink: 0;
}

.mobile-top-icon svg {
  width: 0.95rem;
  height: 0.95rem;
}

.mobile-top-btn[data-kind='public'] {
  --btn-icon-bg: var(--teal-100);
  --btn-icon-fg: var(--teal-700);
}

.mobile-top-btn[data-kind='desktop'] {
  --btn-icon-bg: var(--indigo-100);
  --btn-icon-fg: var(--indigo-700);
}

.mobile-top-btn[data-kind='logout'] {
  --btn-icon-bg: var(--red-50);
  --btn-icon-fg: var(--red-700);
  color: var(--red-700);
}

.mobile-top-btn[data-kind='logout']:hover {
  background: var(--red-50);
  border-color: var(--red-100);
}

/* Pannelli */
.mobile-panel {
  padding: 1rem;
}

.mobile-events-list,
.mobile-attendees-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.mobile-empty-state {
  padding: 1.75rem 1rem;
}

/* -----------------------------------------------------------------------------
   Lista eventi
   ----------------------------------------------------------------------------- */

.mobile-events-section-header {
  flex-wrap: nowrap;
  align-items: flex-start;
}

.mobile-events-section-header > div {
  min-width: 0;
}

.mobile-events-section-header .count-pill {
  flex-shrink: 0;
}

.mobile-events-section-header h3 {
  font-size: 1.05rem;
}

.mobile-event-list-stack {
  display: flex;
  flex-direction: column;
}

.mobile-event-card {
  position: relative;
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-content: start;
  gap: 0.85rem;
  padding: 0.95rem 0.9rem 0.95rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  text-align: left;
  white-space: normal;
  box-shadow: none;
  transition: background var(--transition);
}

.mobile-event-card:hover {
  background: var(--brand-50);
  transform: none;
  box-shadow: none;
}

.mobile-event-card:active {
  background: var(--brand-100);
}

.mobile-event-card:focus-visible {
  box-shadow: inset var(--ring);
  z-index: 1;
}

.mobile-event-card:last-child {
  border-bottom: 0;
}

.mobile-event-date-badge {
  width: 3.3rem;
  min-height: 3.5rem;
  border-radius: var(--radius);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  background: var(--brand-50);
  color: var(--brand-700);
  flex: 0 0 auto;
  align-self: flex-start;
}

.mobile-event-date-badge strong {
  font-size: 1.35rem;
  font-weight: 800;
}

.mobile-event-date-badge small {
  margin-top: 0.2rem;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mobile-event-content {
  min-width: 0;
  display: grid;
  gap: 0.3rem;
}

.mobile-event-topline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.mobile-event-title {
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.mobile-event-meta {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--brand-700);
}

.mobile-event-location {
  font-size: 0.86rem;
  color: var(--text-3);
  overflow-wrap: anywhere;
}

.mobile-event-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.mobile-event-metrics span {
  --metric-fg: var(--text-3);
  --metric-bg: var(--surface-2);
  min-width: 0;
  padding: 0.35rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--metric-bg);
  color: var(--metric-fg);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-event-metrics span[data-metric='paid'] {
  --metric-fg: var(--sky-700);
  --metric-bg: var(--sky-50);
}

.mobile-event-metrics span[data-metric='attended'] {
  --metric-fg: var(--green-700);
  --metric-bg: var(--green-50);
}

.mobile-event-metrics strong {
  display: block;
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.mobile-event-chevron {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-3);
  flex-shrink: 0;
}

.mobile-event-chevron svg {
  width: 0.95rem;
  height: 0.95rem;
}

/* -----------------------------------------------------------------------------
   Dettaglio evento (check-in)
   ----------------------------------------------------------------------------- */

.mobile-panel-top {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -1rem -1rem 0.9rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.mobile-back-button {
  width: 100%;
  min-height: 48px;
  justify-content: center;
}

.mobile-event-summary {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.mobile-summary-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-50) 0%, var(--surface) 70%);
}

.mobile-summary-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.mobile-summary-card h2 {
  margin: 0;
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.mobile-summary-meta {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0;
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 600;
}

.mobile-summary-meta svg {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  color: var(--brand-600);
  flex-shrink: 0;
}

.mobile-stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.mobile-stat-card {
  padding: 0.8rem 0.7rem 0.75rem 0.95rem;
  gap: 0.1rem;
}

.mobile-stat-card .mobile-stat-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.mobile-stat-card > strong {
  font-size: 1.6rem;
}

.mobile-stat-card > small {
  font-size: 0.74rem;
}

/* -----------------------------------------------------------------------------
   Card partecipante
   ----------------------------------------------------------------------------- */

.mobile-attendees-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.25rem 0.15rem;
}

.mobile-attendees-head h3 {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.05rem;
}

.mobile-attendees-head p {
  margin: 0;
  font-size: 0.86rem;
}

.mobile-attendee-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), background var(--transition);
}

.mobile-attendee-card[data-attended='true'] {
  border-color: var(--green-100);
  background: linear-gradient(180deg, var(--green-50) 0%, var(--surface) 45%);
}

.mobile-attendee-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-attendee-identity {
  min-width: 0;
}

.mobile-attendee-head h3 {
  margin: 0 0 0.1rem;
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.mobile-attendee-role {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-3);
}

.mobile-attendee-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--amber-100);
  border-radius: var(--radius);
  background: var(--amber-50);
  color: var(--amber-700);
  font-weight: 700;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.mobile-attendee-alert svg {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.05rem;
  flex-shrink: 0;
}

.mobile-attendee-alert > span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.mobile-attendee-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.mobile-attendee-alert.muted-alert {
  padding: 0.55rem 0.8rem;
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-weight: 500;
  font-size: 0.84rem;
}

/* Toggle grandi "Ha pagato" / "Presente" */
.mobile-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.mobile-check-card {
  --check-fg: var(--text-2);
  --check-bg: var(--surface-2);
  --check-border: var(--border-strong);
  --check-on-fg: var(--green-700);
  --check-on-bg: var(--green-50);
  --check-on-border: var(--green-600);
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.7rem;
  min-height: 56px;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--check-border);
  border-radius: var(--radius);
  background: var(--check-bg);
  color: var(--check-fg);
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition),
    transform var(--transition);
}

.mobile-check-card:active {
  transform: scale(0.98);
}

.mobile-check-card[data-kind='paid'] {
  --check-on-fg: var(--sky-700);
  --check-on-bg: var(--sky-50);
  --check-on-border: var(--sky-700);
}

.mobile-check-card input[type='checkbox'] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.mobile-check-box {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  color: transparent;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.mobile-check-box svg {
  width: 1rem;
  height: 1rem;
}

.mobile-check-text {
  flex: 1;
  min-width: 0;
}

.mobile-check-card:has(input:checked) {
  border-color: var(--check-on-border);
  background: var(--check-on-bg);
  color: var(--check-on-fg);
}

.mobile-check-card:has(input:checked) .mobile-check-box {
  border-color: var(--check-on-border);
  background: var(--check-on-border);
  color: #fff;
}

.mobile-check-card:has(input:focus-visible) {
  box-shadow: var(--ring);
}

/* Fallback per browser senza :has() */
.mobile-check-card input:checked + .mobile-check-box {
  border-color: var(--check-on-border);
  background: var(--check-on-border);
  color: #fff;
}

.mobile-check-card input:focus-visible + .mobile-check-box {
  box-shadow: var(--ring);
}

/* -----------------------------------------------------------------------------
   Schermi più larghi (tablet / desktop)
   ----------------------------------------------------------------------------- */

@media (min-width: 640px) {
  .mobile-admin-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.25rem;
  }

  .mobile-admin-header h1 {
    font-size: 1.5rem;
  }

  .mobile-admin-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .mobile-top-btn {
    width: auto;
    min-height: var(--control-h);
    padding: 0.45rem 0.9rem 0.45rem 0.55rem;
  }

  .mobile-panel {
    padding: 1.25rem;
  }

  .mobile-panel-top {
    position: static;
    margin: 0 0 0.9rem;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
  }

  .mobile-back-button {
    width: auto;
  }

  .mobile-event-card {
    padding: 1rem 1.1rem;
  }

  .mobile-event-metrics span {
    font-size: 0.76rem;
  }

  .mobile-attendees-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }
}

/* Schermi molto stretti */
@media (max-width: 380px) {
  .mobile-admin-actions {
    gap: 0.4rem;
  }

  .mobile-top-btn {
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.45rem 0.35rem;
    font-size: 0.72rem;
  }

  .mobile-event-card {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 0.85rem 0.75rem;
  }

  .mobile-event-chevron {
    display: none;
  }

  .mobile-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .mobile-stat-card {
    padding: 0.65rem 0.5rem 0.6rem 0.75rem;
  }

  .mobile-stat-card > strong {
    font-size: 1.35rem;
  }

  .mobile-check-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-check-card,
  .mobile-event-card,
  .mobile-top-btn {
    transition: none;
  }
}

/* -----------------------------------------------------------------------------
   Aggiunta partecipante (socio dall'elenco / ospite)
   ----------------------------------------------------------------------------- */

.mobile-panel-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
}

.mobile-add-button {
  flex: 1 1 auto;
  min-height: 3rem;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  font-weight: 800;
}

.mobile-add-button svg {
  width: 1.1rem;
  height: 1.1rem;
}

body.modal-open {
  overflow: hidden;
}

.mobile-add-card {
  max-width: 560px;
  padding: 1.25rem;
}

.mobile-add-form {
  display: grid;
  gap: 1rem;
}

.mobile-add-panel {
  display: grid;
  gap: 0.75rem;
}

.mobile-member-list {
  display: grid;
  gap: 0.4rem;
  max-height: min(44vh, 380px);
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.mobile-member-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: none;
  white-space: normal;
}

.mobile-member-item:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border-strong);
  background: var(--surface);
}

.mobile-member-item.is-selected {
  border-color: var(--green-600);
  background: var(--green-50);
}

.mobile-member-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mobile-member-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-member-text small {
  color: var(--text-3);
  font-weight: 600;
}

.mobile-member-check {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green-600);
  color: #fff;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 140ms ease, transform 140ms ease;
}

.mobile-member-check svg {
  width: 0.95rem;
  height: 0.95rem;
}

.mobile-member-item.is-selected .mobile-member-check {
  opacity: 1;
  transform: scale(1);
}

.mobile-add-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0.35rem 0.85rem;
}

.mobile-add-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-2);
  padding: 0.45rem 0;
}

.mobile-add-optional {
  display: grid;
  gap: 0.75rem;
  padding: 0.35rem 0 0.75rem;
}

.mobile-add-form .mobile-check-grid {
  margin: 0;
}

.mobile-add-form .modal-footer button {
  flex: 1;
}

.mobile-price-field input {
  max-width: 200px;
  font-variant-numeric: tabular-nums;
}
