:root {
  --brand-primary: #0f766e;
  --brand-secondary: #f59e0b;
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #cbd5e1;
  --danger: #dc2626;
  --success: #15803d;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
}

.container-wide {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px;
}

/* === BANNER AVVISO IN ALTO === */
.top-banner {
  padding: 12px 16px;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
}
.top-banner.info { background: #dbeafe; color: #1e40af; border-bottom: 2px solid #93c5fd; }
.top-banner.warning { background: #fef3c7; color: #92400e; border-bottom: 2px solid #fcd34d; }
.top-banner.danger { background: #fee2e2; color: #991b1b; border-bottom: 2px solid #fca5a5; }
.top-banner.success { background: #dcfce7; color: #166534; border-bottom: 2px solid #86efac; }

/* === INTESTAZIONE EVENTO === */
.event-topbar {
  background: var(--brand-primary);
  color: #ffffff;
  padding: 18px 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
}

.event-topbar-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.societa-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.event-topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.25;
}

.event-meta-line {
  font-size: 0.9rem;
  opacity: 0.92;
  margin-top: 2px;
}

.spots-pill {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: right;
}

/* === CARD E STATI === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  border: 1px solid #e2e8f0;
  margin-bottom: 20px;
}

.center-card {
  max-width: 520px;
  margin: 60px auto;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === CONTENITORE ISOLATO GEMINI === */
#gemini-shadow-host {
  margin-bottom: 24px;
  background: #ffffff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  border: 1px solid #e2e8f0;
}

/* === MODULO DI ISCRIZIONE === */
.form-section-title {
  margin: 0 0 6px;
  font-size: 1.4rem;
  color: var(--brand-primary);
}

.form-subtitle {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.94rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text-main);
}

.req-star {
  color: var(--danger);
  margin-left: 3px;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.field-textarea {
  min-height: 92px;
  resize: vertical;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.choice-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.95rem;
}

.choice-item input {
  margin-top: 4px;
  width: 17px;
  height: 17px;
  accent-color: var(--brand-primary);
  flex-shrink: 0;
}

.file-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === SCHEDE ATLETA / FRATELLO === */
.athlete-block {
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 16px;
  margin-top: 18px;
  background: #fcfcfd;
}

.athlete-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.athlete-tag {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--brand-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.96rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.05s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}

.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--brand-primary);
  color: var(--brand-primary);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid #fca5a5;
  color: var(--danger);
  padding: 5px 10px;
  font-size: 0.82rem;
}

.btn-warning {
  background: #d97706;
  color: #ffffff;
}

.brother-bar {
  margin-top: 16px;
  display: flex;
  justify-content: flex-start;
}

/* === BOX GDPR UNIFICATO === */
.gdpr-box {
  margin-top: 22px;
  padding: 16px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
}

.gdpr-scroll {
  max-height: 185px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 12px;
  border-radius: 6px;
  font-size: 0.84rem;
  color: #334155;
  margin-bottom: 14px;
}

.gdpr-scroll h4 {
  margin: 0 0 6px;
  color: #0f172a;
  font-size: 0.92rem;
}

.gdpr-photo-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
}

.error-alert {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 0.92rem;
  margin-top: 14px;
}

.progress-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #e0f2fe;
  color: #075985;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
}

.submit-bar {
  margin-top: 20px;
}

.submit-bar .btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
}

/* === MODALI === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  background: #ffffff;
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}

.modal-card-wide {
  max-width: 820px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* === RICEVUTA DI CONFERMA === */
.receipt-success-head {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 18px;
}

.receipt-custom-note {
  background: #fffbeb;
  border-left: 4px solid var(--brand-secondary);
  padding: 14px 16px;
  border-radius: 6px;
  margin-bottom: 18px;
  font-size: 0.96rem;
  white-space: pre-wrap;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-bottom: 16px;
}

.summary-table th,
.summary-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}

.summary-table th {
  width: 38%;
  color: var(--text-muted);
  font-weight: 600;
}

/* === VISTA SEGRETA TABELLA === */
.secret-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.data-table tr:nth-child(even) td {
  background: #f8fafc;
}

/* === ADATTAMENTO SMARTPHONE === */
@media (max-width: 600px) {
  .card {
    padding: 16px;
  }
  .event-topbar h1 {
    font-size: 1.25rem;
  }
  .spots-pill {
    text-align: left;
    width: 100%;
  }
}

/* === STAMPA A4 (RICEVUTA E VISTA SEGRETA) === */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .no-print {
    display: none !important;
  }

  /* Se la modale ricevuta è aperta, stampa solo quella */
  body.printing-receipt #app-root > *:not(#receipt-print-modal) {
    display: none !important;
  }

  body.printing-receipt #receipt-print-modal {
    position: static !important;
    background: #ffffff !important;
    padding: 0 !important;
    display: block !important;
  }

  body.printing-receipt #receipt-print-modal .modal-card {
    box-shadow: none !important;
    max-width: 100% !important;
    max-height: none !important;
    padding: 0 !important;
  }

  /* Vista segreta A4 */
  body.printing-secret .container-wide {
    max-width: 100% !important;
    padding: 0 !important;
  }

  body.printing-secret .card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }

  body.printing-secret .table-scroll {
    overflow: visible !important;
    border: none !important;
  }

  body.printing-secret .data-table {
    width: 100% !important;
    table-layout: fixed !important;
    font-size: 9pt !important;
  }

  body.printing-secret.compact-a4 .data-table {
    font-size: 7.2pt !important;
  }

  body.printing-secret .data-table th,
  body.printing-secret .data-table td {
    padding: 4px 5px !important;
    white-space: normal !important;
    word-break: break-word !important;
    border: 1px solid #94a3b8 !important;
  }

  body.printing-secret .data-table th {
    background: #e2e8f0 !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}