/**
 * 공통 폼 디자인: 정적 JSP와 동적으로 생성한 HTML에 같은 상태 규칙을 적용합니다.
 * 텍스트 입력, 선택 컨트롤, 토글은 각자의 의미와 브라우저 키보드 동작을 유지합니다.
 * Made by Duhyun, Kim / Datetime 19 Oct 2026
 */
:root {
    --sq-control-radius: 10px;
    --sq-control-height: 44px;
    --sq-choice-size: 20px;
    --sq-control-border: #94a3b8;
    --sq-control-bg: #fff;
    --sq-control-text: #172033;
    --sq-control-muted: #475569;
    --sq-control-accent: #2563eb;
    --sq-control-error: #b42318;
}

/* 파일/범위/색상/숨김 입력은 전용 UI가 있어 텍스트 입력 규칙에서 제외합니다. */
body main :is(input:not([type=range]):not([type=radio]):not([type=checkbox]):not([type=file]):not([type=hidden]):not([type=color]), select, textarea) {
    box-sizing: border-box;
    border: 1px solid var(--sq-control-border);
    border-radius: var(--sq-control-radius);
    background-color: var(--sq-control-bg);
    color: var(--sq-control-text);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    padding: 9px var(--sq-control-padding-end, 11px) 9px var(--sq-control-padding-start, 11px);
    min-width: 0;
    min-height: var(--sq-control-height);
}

body main .member-password-field input {
    --sq-control-padding-end: 62px;
}

body main .button {
    font-size: 14px;
}

body main .button.compact,
body main .text-button {
    font-size: 13px;
}

body main textarea {
    line-height: 1.65;
    resize: vertical;
}

body main :is(input, textarea)::placeholder {
    color: #64748b;
    opacity: 1;
}

/* 작은 native glyph와 44px label 터치 영역을 분리해 화면 부피를 줄입니다. */
body main input:is([type=radio], [type=checkbox]):not([role=switch]) {
    appearance: auto;
    display: inline-block;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    max-width: 20px;
    max-height: 20px;
    margin: 0;
    padding: 0;
    vertical-align: middle;
    accent-color: var(--sq-control-accent);
    box-shadow: none;
}

body main label.check,
body main label:has(> input:is([type=radio], [type=checkbox])) {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--sq-control-height);
    line-height: 1.5;
    cursor: pointer;
}

body main label:has(> input:is([type=radio], [type=checkbox]):disabled) {
    color: var(--sq-control-muted);
    cursor: not-allowed;
}

/* role=switch인 실제 checkbox만 토글로 표시합니다. 상태는 input.checked가 원본입니다. */
body main input[type=checkbox][role=switch] {
    appearance: none;
    display: inline-block;
    position: relative;
    flex: 0 0 40px;
    width: 40px;
    height: 24px;
    min-width: 40px;
    min-height: 24px;
    max-height: 24px;
    margin: 0;
    padding: 2px;
    border: 1px solid #64748b;
    border-radius: 999px;
    background: #cbd5e1;
    cursor: pointer;
}

body main input[type=checkbox][role=switch]::before {
    content: "";
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px #0f172a30;
    transition: transform 120ms ease;
}

body main input[type=checkbox][role=switch]:checked {
    border-color: #1d4ed8;
    background: #2563eb;
}

body main input[type=checkbox][role=switch]:checked::before {
    transform: translateX(16px);
}

body main :is(.button, button:not(.ql-toolbar button):not(.trim-handle):not(.trim-focus)) {
    border-radius: var(--sq-control-radius);
    font-family: inherit;
}

body main :is(.button, form > .text-button, .recovery-actions button) {
    min-height: var(--sq-control-height);
    line-height: 1.5;
}

body main :is(input, textarea)[aria-invalid=true] {
    --sq-control-border: var(--sq-control-error);
}

body main :is(input, textarea)[readonly] {
    --sq-control-bg: #f1f5f9;
}

body main :is(input, textarea, select):disabled,
body main :is(button, .button):is(:disabled, [aria-disabled=true]) {
    --sq-control-bg: #f1f5f9;
    opacity: 1;
    color: #475569;
    border-color: #94a3b8;
    cursor: not-allowed;
}

body main :is(button, .button):is(:disabled, [aria-disabled=true]) {
    background-color: #f1f5f9;
}

body main input[type=checkbox][role=switch]:disabled {
    border-color: #94a3b8;
    background-color: #94a3b8;
    cursor: not-allowed;
}

body main :is(button, .button)[aria-busy=true] {
    cursor: progress;
}

body main :is(input, textarea, select, button, a):focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    body main input[type=checkbox][role=switch]::before {
        transition: none;
    }
}

@media (forced-colors: active) {
    body main input[type=checkbox][role=switch] {
        appearance: auto;
        background: Canvas;
        border-color: ButtonText;
    }
    body main input[type=checkbox][role=switch]::before {
        display: none;
    }
    body main :is(input, textarea, select, button, a):focus-visible {
        outline-color: Highlight;
    }
}
