<h2 mat-dialog-title>{{ isEditMode ? 'Modifica Struttura' : 'Aggiungi Nuova Struttura' }}</h2>

<mat-dialog-content [formGroup]="structureForm">
  <div class="form-grid"> <!-- Contenitore per la griglia -->
    <mat-form-field appearance="fill">
      <mat-label>Nome Struttura</mat-label>
      <input matInput formControlName="name" required>
      <mat-error *ngIf="structureForm.get('name')?.hasError('required')">
        Il nome è obbligatorio.
      </mat-error>
    </mat-form-field>

    <mat-form-field appearance="fill">
      <mat-label>Indirizzo</mat-label>
      <input matInput formControlName="address">
    </mat-form-field>

    <mat-form-field appearance="fill">
      <mat-label>Città</mat-label>
      <input matInput formControlName="city">
    </mat-form-field>

    <mat-form-field appearance="fill">
      <mat-label>Provincia</mat-label>
      <input matInput formControlName="province">
    </mat-form-field>

    <mat-form-field appearance="fill">
      <mat-label>CAP</mat-label>
      <input matInput formControlName="zip_code">
    </mat-form-field>

    <mat-form-field appearance="fill">
      <mat-label>Telefono</mat-label>
      <input matInput formControlName="phone">
    </mat-form-field>

    <mat-form-field appearance="fill">
      <mat-label>Email</mat-label>
      <input matInput formControlName="email" type="email">
       <mat-error *ngIf="structureForm.get('email')?.hasError('email')">
        Inserisci un indirizzo email valido.
      </mat-error>
    </mat-form-field>

    <mat-form-field appearance="fill" class="full-width-field"> <!-- Campo note a larghezza piena -->
      <mat-label>Note</mat-label>
      <textarea matInput formControlName="notes"></textarea>
    </mat-form-field>
  </div>
</mat-dialog-content>

<mat-dialog-actions align="end">
  <button mat-button (click)="onCancel()">Annulla</button>
  <button mat-raised-button color="primary" (click)="onSave()" [disabled]="!structureForm.valid">
    {{ isEditMode ? 'Salva Modifiche' : 'Aggiungi' }}
  </button>
</mat-dialog-actions>
