/* ✅ Fix universale: evita tagli/overflow su mobile */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  overflow-x: hidden;
}

/* Base */
body {
  background-color: #c8d6f1;
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* Header */
#header-container {
  width: 100%;
  background-color: #ecf4e2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  position: fixed;
  top: 0;
  z-index: 1000;
}

#logo-container { flex: 0 0 auto; }

#logo {
  max-width: 90px;
  height: auto;
  margin-left: 10px;
  mix-blend-mode: multiply;
}

#title-container {
  flex: 1;
  text-align: left;
  padding-right: 12px;
}

#title-container h1 {
  margin: 0;
  font-size: 1.35em;
}

/* Card form */
#form-container {
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  padding: 20px;
  max-width: 680px;

  /* ✅ evita overflow: il container non supera mai lo schermo */
  width: calc(100% - 20px);

  margin: 140px auto 18px;
  text-align: center;
}

/* Form */
form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

label { font-weight: bold; }

select, input[type="date"] {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 1em;
  width: 100%;
  max-width: 320px;
}

.section-title {
  margin: 6px 0 2px;
  font-size: 1.2em;
}

.center-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Box already */
.already-box {
  width: 100%;
  max-width: 640px;
  margin-top: 8px;
  text-align: left;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 12px 12px 10px;
  background: #f8fbf8;
}

.already-title { margin: 0 0 8px; }

.already-list div {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(0,0,0,0.08);
}
.already-list div:last-child { border-bottom: none; }

/* Lista coristi */
.singers-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  max-width: 640px;
  margin-top: 10px;
  text-align: left;
}

.singer-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.06);
  background: #ffffff;
}

input[type="checkbox"] { transform: scale(1.1); }

/* Submit */
.submit-area {
  width: 100%;
  max-width: 640px;
  margin-top: 14px;
}

button {
  width: 100%;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  border: none;
  font-size: 1em;
  background-color: #4CAF50;
  color: white;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.3s;
}

button:hover { background-color: #45a049; }
button:active { transform: scale(0.99); }
button:disabled { opacity: 0.7; cursor: not-allowed; }

/* Desktop: 2 colonne */
@media (min-width: 700px) {
  .singers-list { grid-template-columns: 1fr 1fr; }
}

/* Mobile: più spazio e bottone sticky */
@media (max-width: 600px) {
  #form-container {
    margin: 130px auto 10px;
    width: calc(100% - 16px);  /* ✅ un filo più stretto */
    padding: 12px;
  }

  /* ✅ nessun figlio deve “sbordare” */
  .already-box,
  .singers-list,
  .submit-area,
  select,
  input[type="date"],
  button {
    max-width: 100%;
  }

  #title-container h1 { font-size: 1.15em; }

  .singer-container { padding: 14px 12px; }

  .submit-area {
    position: sticky;
    bottom: 10px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(2px);
    padding: 10px 0 6px;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-top: 16px;
  }

  button { max-width: 100%; }
}

/* =========================================
   OVERLAY GLOBALE (coerente per tutte le attese)
========================================= */
.global-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.global-overlay-card {
  background: white;
  border-radius: 16px;
  padding: 26px 28px 18px;
  width: min(340px, 88vw);
  text-align: center;
  box-shadow: 0 18px 45px rgba(0,0,0,0.35);
  animation: overlayPop 0.22s ease;
}

.global-spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 6px solid rgba(76,175,80,0.25);
  border-top-color: rgba(76,175,80,1);
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}

.global-overlay-text {
  font-weight: 700;
  font-size: 1.1em;
}

.global-overlay-subtext {
  margin-top: 6px;
  font-size: 0.95em;
  opacity: 0.75;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes overlayPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}