/* ============================================================
    form.css
    Hyomin Design System v1.0 — Form Components

    컴포넌트:
    - .label          — 폼 라벨 + 필수 별표
    - .input          — 텍스트 입력 필드
    - .helper-text    — 안내 메시지
    - .form-group     — 세 컴포넌트 묶는 래퍼

    사용법:
    <div class="form-group">
        <label class="label" for="id">Label <span class="label__required">*</span></label>
        <input class="input" type="text" id="id" placeholder="Placeholder" />
        <span class="helper-text">HelperText</span>
    </div>
    ============================================================ */


/* ─────────────────────────────────────────
    Form Group — 래퍼
    ───────────────────────────────────────── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
    width: 100%;
}


/* ─────────────────────────────────────────
    Label
    ───────────────────────────────────────── */

.label {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-1);
    font-family: var(--font-secondary);
    font-size: var(--font-size-body-base); /* 18px — Figma: Body base */
    font-weight: var(--font-weight-regular);
    color: var(--gray-900);
    line-height: 27px;
    white-space: nowrap;
}

.label__required {
    color: var(--color-accent-main); /* accent/main = #dc2626 */
    line-height: 27px;
}


/* ─────────────────────────────────────────
    Input
    ───────────────────────────────────────── */

.input {
    width: 100%;
    min-width: 280px;
    height: 40px;
    padding: var(--spacing-2) var(--spacing-4);
    font-family: var(--font-secondary);
    font-size: var(--font-size-body-sm); /* 16px */
    font-weight: var(--font-weight-regular);
    color: var(--gray-900);
    background-color: #ffffff;
    border: var(--border-width) solid var(--gray-200);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--duration-fast) var(--easing-default), background-color var(--duration-fast) var(--easing-default), box-shadow var(--duration-fast) var(--easing-default);
}

.input::placeholder {
    color: var(--gray-400);
}

/* Hover */
.input:hover {
    background-color: var(--gray-50);
    border-color: var(--gray-300);
}

/* Focus — Figma 원본값 그대로 */
.input:focus {
    background-color: #ffffff;
    border-color: var(--green-500);
    box-shadow: 0 0 0 2px var(--green-50);
}

/* Disabled */
.input:disabled {
    background-color: var(--gray-100);
    border-color: var(--gray-300);
    cursor: not-allowed;
}

.input:disabled::placeholder {
    opacity: 0.6;
}

/* Error */
.input--error {
    border-color: var(--color-error-main); /* error/main = #b91c1c */
}

.input--error:hover {
    border-color: var(--color-error-main);
}

.input--error:focus {
    border-color: var(--color-error-main);
    box-shadow: 0 0 0 2px var(--red-50);
}

/* Success */
.input--success {
    border-color: var(--color-success-main); /* success/main = #22c55e */
}

.input--success:hover {
    border-color: var(--color-success-main);
}

.input--success:focus {
    border-color: var(--color-success-main);
    box-shadow: 0 0 0 2px var(--green-50);
}


/* ─────────────────────────────────────────
    Helper Text
    ───────────────────────────────────────── */

.helper-text {
    font-family: var(--font-secondary);
    font-size: var(--font-size-body-sm); /* 16px */
    font-weight: var(--font-weight-regular);
    color: var(--gray-500);
    line-height: 24px;
}

.helper-text--error {
    color: var(--color-error-main); /* error/main = #b91c1c */
}

.helper-text--success {
    color: var(--color-success-main); /* success/main = #22c55e */
}


/* ─────────────────────────────────────────
    Checkbox
    ───────────────────────────────────────── */

.checkbox {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-sm);
}

/* 포커스 시 전체 div에 빨간 테두리 */
.checkbox:focus-within {
    outline: 3px solid var(--color-accent-main);
    outline-offset: -3px;
}

/* 네이티브 input 숨김 */
.checkbox__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* label이 control + 텍스트를 함께 감쌈 */
.checkbox__label {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2);
    font-family: var(--font-secondary);
    font-size: var(--font-size-body-sm);
    font-weight: var(--font-weight-regular);
    color: var(--gray-900);
    line-height: 24px;
    user-select: none;
    cursor: pointer;
}

/* 커스텀 박스 */
.checkbox__control {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    border: var(--border-width) solid var(--gray-300);
    background-color: #ffffff;
    transition: border-color var(--duration-fast), background-color var(--duration-fast);
}

.checkbox__control::after {
    content: "✓";
    font-family: var(--font-secondary);
    font-size: var(--font-size-body-sm);
    font-weight: var(--font-weight-regular);
    line-height: 1;
    color: transparent;
}

/* Hover */
.checkbox__label:hover .checkbox__control {
    border-color: var(--gray-400);
}

/* Checked */
.checkbox__input:checked + .checkbox__label .checkbox__control {
    background-color: var(--green-500);
    border-color: var(--green-500);
}

.checkbox__input:checked + .checkbox__label .checkbox__control::after {
    color: #ffffff;
}

/* Disabled */
.checkbox__input:disabled + .checkbox__label {
    color: var(--gray-400);
    cursor: not-allowed;
}

.checkbox__input:disabled + .checkbox__label .checkbox__control {
    background-color: var(--gray-100);
    border-color: var(--gray-300);
}


/* ─────────────────────────────────────────
    Radio
    ───────────────────────────────────────── */

.radio {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-sm);
}

/* 포커스 시 전체 div에 빨간 테두리 */
.radio:focus-within {
    outline: 3px solid var(--color-accent-main);
    outline-offset: -3px;
}

/* 네이티브 input 숨김 */
.radio__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* label이 control + 텍스트를 함께 감쌈 */
.radio__label {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2);
    font-family: var(--font-secondary);
    font-size: var(--font-size-body-sm);
    font-weight: var(--font-weight-regular);
    color: var(--gray-900);
    line-height: 24px;
    user-select: none;
    cursor: pointer;
}

/* 커스텀 원형 */
.radio__control {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    border: var(--border-width) solid var(--gray-300);
    background-color: #ffffff;
    transition: border-color var(--duration-fast), background-color var(--duration-fast);
}

.radio__control::after {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: transparent;
    transition: background-color var(--duration-fast);
}

/* Hover */
.radio__label:hover .radio__control {
    border-color: var(--gray-400);
}

/* Checked */
.radio__input:checked + .radio__label .radio__control {
    border-color: var(--green-500);
}

.radio__input:checked + .radio__label .radio__control::after {
    background-color: var(--green-500);
}

/* Disabled */
.radio__input:disabled + .radio__label {
    color: var(--gray-400);
    cursor: not-allowed;
}

.radio__input:disabled + .radio__label .radio__control {
    background-color: var(--gray-100);
    border-color: var(--gray-300);
}


/* ─────────────────────────────────────────
    Select
    ───────────────────────────────────────── */

.select-wrap {
    position: relative;
    width: 100%;
}

.select {
    width: 100%;
    height: 40px;
    padding: var(--spacing-2) var(--spacing-4);
    padding-right: 36px; /* chevron 공간 */
    font-family: var(--font-secondary);
    font-size: var(--font-size-body-base); /* 18px — Figma: Body base */
    font-weight: var(--font-weight-regular);
    color: var(--gray-900);
    background-color: #ffffff;
    border: var(--border-width) solid var(--gray-200);
    border-radius: var(--radius-md);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    transition: border-color var(--duration-fast), background-color var(--duration-fast);
}

.select:hover {
    background-color: var(--green-50);
}

.select:focus-visible {
    outline: 1px solid var(--color-accent-main);
    outline-offset: -1px;
}

.select:disabled {
    background-color: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-400);
    cursor: not-allowed;
}

/* 값 선택된 상태 — JS에서 클래스 추가 */
.select--selected {
    background-color: var(--green-50);
    border-color: var(--green-500);
    color: var(--green-700);
}


/* ─────────────────────────────────────────
    Textarea
    ───────────────────────────────────────── */

.textarea {
    width: 100%;
    min-height: 100px;
    padding: var(--spacing-2);
    font-family: var(--font-secondary);
    font-size: var(--font-size-body-sm); /* 16px */
    font-weight: var(--font-weight-regular);
    color: var(--gray-900);
    background-color: #ffffff;
    border: var(--border-width) solid var(--gray-200);
    border-radius: var(--radius-md);
    outline: none;
    resize: vertical;
    line-height: 24px;
    transition: border-color var(--duration-fast), background-color var(--duration-fast), box-shadow var(--duration-fast);
}

.textarea::placeholder {
    color: var(--gray-400);
}

/* Hover — Figma: border gray-200 (input과 다름) */
.textarea:hover {
    background-color: var(--gray-50);
}

/* Focus — Figma 원본값 그대로 */
.textarea:focus {
    background-color: #ffffff;
    border-color: var(--green-500);
    box-shadow: 0 0 0 2px var(--green-50);
}

/* Disabled — Figma: border gray-200 (input과 다름) */
.textarea:disabled {
    background-color: var(--gray-100);
    border-color: var(--gray-200);
    cursor: not-allowed;
}

.textarea:disabled::placeholder {
    color: var(--gray-300);
}

/* Error */
.textarea--error {
    border-color: var(--color-error-main);
}

.textarea--error::placeholder {
    color: var(--gray-300);
}

.textarea--error:hover {
    border-color: var(--color-error-main);
}

.textarea--error:focus {
    border-color: var(--color-error-main);
    box-shadow: 0 0 0 2px var(--red-50);
}

/* Success */
.textarea--success {
    border-color: var(--color-success-main);
}

.textarea--success:hover {
    border-color: var(--color-success-main);
}

.textarea--success:focus {
    border-color: var(--color-success-main);
    box-shadow: 0 0 0 2px var(--green-50);
}
