<ng-container *transloco="let t; prefix: 'settingsReader.fonts.upload'">
<div class="font-upload-dialog">
  <div class="panel-header">
    <div class="header-icon-wrapper">
      <i class="pi pi-upload header-icon"></i>
    </div>
    <div class="header-text">
      <h2 class="panel-title">{{ t('title') }}</h2>
      <p class="panel-description">
        {{ t('description') }}
      </p>
    </div>
    <p-button
      icon="pi pi-times"
      (click)="cancel()"
      severity="secondary"
      [text]="true"
      [rounded]="true"
      [disabled]="isUploading"
      class="close-button"/>
  </div>

  <div class="upload-container">
    <div class="file-upload-section">
      <div class="section-header">
        <span class="section-title">
          <i class="pi pi-file"></i>
          {{ t('selectFile') }}
        </span>
      </div>

      @if (!selectedFile) {
        <div class="upload-zone"
             [class.drag-over]="isDragOver"
             (click)="onUploadZoneClick()"
             (drop)="onDrop($event)"
             (dragover)="onDragOver($event)"
             (dragleave)="onDragLeave($event)">
          <input
            #fileInput
            type="file"
            accept=".ttf,.otf,.woff,.woff2"
            [disabled]="isUploading"
            (change)="onFileInputChange($event)"
            style="display: none;"
          />
          <div class="empty-state">
            <div class="empty-icon-wrapper">
              <i class="pi pi-cloud-upload empty-icon"></i>
            </div>
            <h3 class="empty-title">{{ t('dragDrop') }}</h3>
            <p class="empty-description" [innerHTML]="t('supportedFormats')"></p>
            <p class="empty-description">{{ t('maxSize') }}</p>
          </div>
        </div>
      } @else {
      <div class="file-selected">
        <div class="file-info-card">
          <i class="pi pi-file"></i>
          <div class="file-details">
            <span class="file-name">{{ selectedFile.name }}</span>
            <span class="file-meta">{{ formatFileSize(selectedFile.size) }} • {{ selectedFile.name.split('.').pop()?.toUpperCase() }}</span>
          </div>
        </div>

        @if (previewFontFamily) {
          <div class="preview-section">
            <label class="preview-label">
              <i class="pi pi-eye"></i>
              {{ t('fontPreview') }}
            </label>
            <div class="font-preview" [style.font-family]="previewFontFamily">
              <p class="preview-paragraph">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
              </p>
              <p class="preview-paragraph-small">
                Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
                Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
              </p>
              <div class="preview-characters">
                <span>ABCDEFGHIJKLMNOPQRSTUVWXYZ</span>
                <span>abcdefghijklmnopqrstuvwxyz</span>
                <span>0123456789 !@#$%^&*()</span>
              </div>
            </div>
          </div>
        }

        <div class="setting-item">
          <div class="setting-info">
            <label for="fontName" class="setting-label">{{ t('displayName') }}</label>
            <p class="setting-description">
              {{ t('displayNameDesc') }}
            </p>
          </div>
          <div class="setting-control">
            <input
              pInputText
              id="fontName"
              [(ngModel)]="uploadedFontName"
              [placeholder]="t('displayNamePlaceholder')"
              [disabled]="isUploading"
              class="font-name-input"
            />
          </div>
        </div>
      </div>
    }
  </div>
  </div>

  <div class="dialog-footer">
    <p-button
      [label]="'common.cancel' | transloco"
      icon="pi pi-times"
      severity="secondary"
      [outlined]="true"
      (click)="cancel()"
      [disabled]="isUploading"
    ></p-button>
    <p-button
      [label]="t('uploadBtn')"
      icon="pi pi-upload"
      (click)="uploadFont()"
      [disabled]="isUploading || !selectedFile || !uploadedFontName.trim()"
      [loading]="isUploading"
    ></p-button>
  </div>
</div>
</ng-container>
