'use client';

import { TabProps } from '../types';

export function DeliveryTab({ data, onChange, canUpdate }: TabProps) {
  return (
    <div className="space-y-6">
      <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
        <div>
          <label className="block text-sm font-medium mb-1.5" style={{ color: 'var(--color-text-secondary)' }}>
            Delivery Charges
          </label>
          <input
            type="number"
            step="0.01"
            min="0"
            value={data.delivery_charges || 0}
            onChange={(e) => onChange('delivery_charges', parseFloat(e.target.value) || 0)}
            disabled={!canUpdate}
            placeholder="0.00"
            className="w-full px-4 py-2.5 rounded-lg text-sm outline-none transition-all focus:ring-2 focus:ring-cta/20 disabled:opacity-50"
            style={{
              background: 'var(--color-surface-alt)',
              border: '1px solid var(--color-border)',
              color: 'var(--color-text)',
            }}
          />
          <p className="text-xs mt-1" style={{ color: 'var(--color-text-tertiary)' }}>
            Fixed delivery charge per order. Set 0 for free delivery.
          </p>
        </div>

        <div>
          <label className="block text-sm font-medium mb-1.5" style={{ color: 'var(--color-text-secondary)' }}>
            Free Delivery Threshold
          </label>
          <input
            type="number"
            step="0.01"
            min="0"
            value={data.free_delivery_threshold || 0}
            onChange={(e) => onChange('free_delivery_threshold', parseFloat(e.target.value) || 0)}
            disabled={!canUpdate}
            placeholder="1000.00"
            className="w-full px-4 py-2.5 rounded-lg text-sm outline-none transition-all focus:ring-2 focus:ring-cta/20 disabled:opacity-50"
            style={{
              background: 'var(--color-surface-alt)',
              border: '1px solid var(--color-border)',
              color: 'var(--color-text)',
            }}
          />
          <p className="text-xs mt-1" style={{ color: 'var(--color-text-tertiary)' }}>
            Orders above this amount get free delivery. Set 0 to disable free delivery.
          </p>
        </div>
      </div>

      <div className="p-4 rounded-lg" style={{ 
        background: 'var(--color-surface-alt)',
        border: '1px solid var(--color-border)'
      }}>
        <h4 className="text-sm font-medium mb-2" style={{ color: 'var(--color-text-secondary)' }}>
          Delivery Rules:
        </h4>
        <ul className="text-xs space-y-1" style={{ color: 'var(--color-text-tertiary)' }}>
          <li>• Delivery charges apply to all orders below the free delivery threshold</li>
          <li>• Free delivery applies when order total equals or exceeds the threshold</li>
          <li>• Delivery charges are added during checkout before payment</li>
        </ul>
      </div>
    </div>
  );
}