// Variables CSS pour le thème personnalisable
:host {
  --field-renderer-primary: #3f51b5;
  --field-renderer-accent: #206bc4;
  --field-renderer-error: #d63384;
  --field-renderer-bg: #f8fafc;
  --field-renderer-border: #e6e7e9;
  --field-renderer-radius: 0.375rem;
  --field-renderer-font-size: 0.875rem;
  --field-renderer-font-family: inherit;
}

.form-group {
  margin-bottom: 1.5rem;
  font-family: var(--field-renderer-font-family);
  font-size: var(--field-renderer-font-size);
}

.error {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  color: var(--field-renderer-error);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Autocomplétion styles */
.search-icon {
  color: rgba(0, 0, 0, 0.54);
}

.loading-spinner {
  margin-left: 8px;
}

::ng-deep .autocomplete-option {
  .option-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
  }

  .option-icon {
    color: var(--field-renderer-accent);
    font-size: 20px;
    width: 20px;
    height: 20px;
  }

  .option-details {
    flex: 1;
    min-width: 0;
  }

  .option-name {
    font-size: 14px;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

::ng-deep .no-results-option {
  .no-results {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 14px;
    padding: 8px 0;

    mat-icon {
      font-size: 20px;
      width: 20px;
      height: 20px;
    }
  }
}

/* Checkbox styles */
.checkbox-wrapper {
  margin: 1rem 0;

  ::ng-deep .mat-checkbox-label {
    font-size: 0.875rem;
    color: var(--tblr-body-color, #1e293b);
  }
}

/* File upload styles */
.file-upload-wrapper {
  .file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--tblr-bg, #f8fafc);
    border-radius: 0.375rem;
    border: 1px solid var(--tblr-border-color, #e6e7e9);

    .file-icon {
      color: var(--field-renderer-accent);
      font-size: 20px;
      width: 20px;
      height: 20px;
    }

    .file-name {
      font-size: 0.875rem;
      color: var(--tblr-body-color, #1e293b);
      flex: 1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

/* Color picker styles */
.color-picker-wrapper {
  display: flex;
  gap: 16px;
  align-items: center;

  mat-form-field {
    flex: 1;
  }

  .color-preview {
    display: flex;
    align-items: center;

    .color-swatch {
      width: 40px;
      height: 40px;
      border-radius: 4px;
      border: 2px solid rgba(0, 0, 0, 0.12);
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
  }
}

/* Range slider styles */
.range-wrapper {
  padding: 16px 0;

  input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--field-renderer-primary) 0%, var(--field-renderer-primary) var(--range-progress, 50%), #e0e0e0 var(--range-progress, 50%), #e0e0e0 100%);
    outline: none;
    -webkit-appearance: none;

    &::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: var(--field-renderer-primary);
      cursor: pointer;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
      transition: transform 0.2s ease;

      &:hover {
        transform: scale(1.2);
      }
    }

    &::-moz-range-thumb {
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: var(--field-renderer-primary);
      cursor: pointer;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
      border: none;
      transition: transform 0.2s ease;

      &:hover {
        transform: scale(1.2);
      }
    }
  }

  .range-value {
    display: block;
    text-align: center;
    margin-top: 8px;
    font-weight: 500;
    color: var(--field-renderer-primary);
  }

  .range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 12px;
    color: rgba(0, 0, 0, 0.54);
  }
}

/* Read-only mode styles */
.readonly-field {
  padding: 12px;
  background: var(--field-renderer-bg);
  border: 1px solid var(--field-renderer-border);
  border-radius: var(--field-renderer-radius);
  margin: 8px 0;

  .readonly-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.6);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .readonly-value {
    font-size: var(--field-renderer-font-size);
    font-family: var(--field-renderer-font-family);
    color: #1e293b;
    font-weight: 500;

    &.reference-link {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      color: var(--field-renderer-accent);
      cursor: pointer;
      transition: color 0.2s ease;

      &:hover {
        text-decoration: underline;
        opacity: 0.8;
      }

      .reference-icon {
        font-size: 16px;
        width: 16px;
        height: 16px;
      }
    }
  }
}

/* Fix Angular Material Select dropdown positioning */
::ng-deep .cdk-overlay-pane {
  margin-top: 0 !important;
}

::ng-deep .mat-select-panel {
  margin-top: -8px !important;
  max-height: 300px !important;
}
