import React from "react"; /** Product text input — 6px radius, brand focus ring, C1 14px text. * R01: 오류 테두리와 포커스 링을 독립 계산. R04: 소비자 핸들러 합성. R10: C1 역할 토큰 연결. */ export function Input({ size = "md", invalid = false, disabled = false, style, onFocus, onBlur, onMouseEnter, onMouseLeave, ...rest }) { const [focus, setFocus] = React.useState(false); const [hover, setHover] = React.useState(false); const heights = { sm: 32, md: 40, lg: 48 }; const borderColor = invalid ? "hsl(var(--destructive))" : focus ? "hsl(var(--input-active))" : hover ? "hsl(var(--input-hover))" : "hsl(var(--input))"; // 포커스 링: 정상은 --ring(기존 glow 3px 유지), 오류는 --destructive 기반 3px glow → 오류 테두리와 별개로 항상 식별 가능 const ring = focus ? (invalid ? "0 0 0 var(--input-focus-ring-width, var(--focus-ring-width, 3px)) hsl(var(--destructive) / 0.3)" : "0 0 0 var(--input-focus-ring-width, var(--focus-ring-width, 3px)) hsl(var(--ring))") : "none"; return ( { setFocus(true); onFocus?.(e); }} onBlur={(e) => { setFocus(false); onBlur?.(e); }} onMouseEnter={(e) => { setHover(true); onMouseEnter?.(e); }} onMouseLeave={(e) => { setHover(false); onMouseLeave?.(e); }} {...rest} style={{ height: heights[size], padding: "0 12px", fontFamily: "var(--font-sans)", fontSize: "var(--text-c1, 14px)", fontWeight: 500, color: disabled ? "hsl(var(--disabled-foreground))" : "hsl(var(--foreground))", background: disabled ? "hsl(var(--disabled))" : "hsl(var(--background))", border: `1px solid ${disabled ? "hsl(var(--disabled-border))" : borderColor}`, borderRadius: 6, outline: "none", boxShadow: ring, transition: "border-color var(--duration-fast), box-shadow var(--duration-fast)", boxSizing: "border-box", width: "100%", ...style, }} /> ); }