/**
 * CommonSettingsSectionCompact
 *
 * Compact version of common settings fields for constructor sidebar.
 * Label and appear timing in a space-efficient layout.
 */

import React from 'react';
import type { CommonSettingsSectionProps } from './types';

const CommonSettingsSectionCompact: React.FC<CommonSettingsSectionProps> = ({
  label,
  appearDelaySec,
  appearDurationSec,
  onChange,
  showLabel = true,
}) => {
  return (
    <div className='mb-2 space-y-2'>
      {showLabel && (
        <div>
          <label className='mb-1 block text-[11px] font-semibold text-gray-600'>
            Label
          </label>
          <input
            className='w-full rounded border border-gray-300 px-2 py-1 text-xs'
            value={label}
            onChange={(event) => onChange('label', event.target.value)}
          />
        </div>
      )}
      <div>
        <label className='mb-1 block text-[11px] font-semibold text-gray-600'>
          Appear delay (sec)
        </label>
        <input
          className='w-full rounded border border-gray-300 px-2 py-1 text-xs'
          type='number'
          min='0'
          step='0.1'
          value={appearDelaySec ?? 0}
          onChange={(event) => onChange('appearDelaySec', event.target.value)}
        />
      </div>
      <div>
        <label className='mb-1 block text-[11px] font-semibold text-gray-600'>
          Appear duration (sec)
        </label>
        <input
          className='w-full rounded border border-gray-300 px-2 py-1 text-xs'
          type='number'
          min='0.1'
          step='0.1'
          placeholder='Unlimited'
          value={appearDurationSec ?? ''}
          onChange={(event) =>
            onChange('appearDurationSec', event.target.value)
          }
        />
        <p className='mt-1 text-[11px] text-gray-500'>
          Leave empty for unlimited.
        </p>
      </div>
    </div>
  );
};

export default CommonSettingsSectionCompact;
