/* ═══════════════════════════════════════
   ARKDIO Form Builder - Public CSS
   Design System: Airbnb (DESIGN.md)
   ═══════════════════════════════════════ */

.afb-form-wrapper {
    margin: 0 auto;
    font-family: 'Inter', -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: #222222;
}

/* ─── 인풋 스타일 (레이아웃별) ─── */

/* 박스형 (default): 일반 사각 테두리 인풋 */
.afb-layout-default .afb-form input[type="text"],
.afb-layout-default .afb-form input[type="email"],
.afb-layout-default .afb-form input[type="url"],
.afb-layout-default .afb-form input[type="tel"],
.afb-layout-default .afb-form input[type="number"],
.afb-layout-default .afb-form input[type="date"],
.afb-layout-default .afb-form input[type="time"],
.afb-layout-default .afb-form input[type="datetime-local"],
.afb-layout-default .afb-form textarea,
.afb-layout-default .afb-form select {
    border: 1px solid #c1c1c1; border-radius: 4px; background: #ffffff;
}
.afb-layout-default .afb-form .afb-submit-btn { border-radius: 8px !important; }

/* 하단 라인형 (boxed): 테두리 없이 밑줄만 */
.afb-layout-boxed .afb-form input[type="text"],
.afb-layout-boxed .afb-form input[type="email"],
.afb-layout-boxed .afb-form input[type="url"],
.afb-layout-boxed .afb-form input[type="tel"],
.afb-layout-boxed .afb-form input[type="number"],
.afb-layout-boxed .afb-form input[type="date"],
.afb-layout-boxed .afb-form input[type="time"],
.afb-layout-boxed .afb-form input[type="datetime-local"],
.afb-layout-boxed .afb-form textarea,
.afb-layout-boxed .afb-form select {
    border: none; border-bottom: 1.5px solid #c1c1c1; border-radius: 0;
    background: transparent; padding-left: 0; padding-right: 0;
}
.afb-layout-boxed .afb-form input:focus,
.afb-layout-boxed .afb-form textarea:focus,
.afb-layout-boxed .afb-form select:focus {
    border-color: #222222; box-shadow: none;
    border-bottom-width: 2px;
}
.afb-layout-boxed .afb-form .afb-submit-btn { border-radius: 8px !important; }

/* 라운드형 (floating): 완전 둥근 인풋 */
.afb-layout-floating .afb-form input[type="text"],
.afb-layout-floating .afb-form input[type="email"],
.afb-layout-floating .afb-form input[type="url"],
.afb-layout-floating .afb-form input[type="tel"],
.afb-layout-floating .afb-form input[type="number"],
.afb-layout-floating .afb-form input[type="date"],
.afb-layout-floating .afb-form input[type="time"],
.afb-layout-floating .afb-form input[type="datetime-local"],
.afb-layout-floating .afb-form select {
    border: 1px solid #c1c1c1; border-radius: 99px; background: #ffffff;
    padding-left: 18px; padding-right: 18px;
}
.afb-layout-floating .afb-form textarea {
    border: 1px solid #c1c1c1; border-radius: 16px; background: #ffffff;
    padding: 14px 18px;
}
.afb-layout-floating .afb-form .afb-submit-btn { border-radius: 99px !important; }

/* ─── 헤더 / 푸터 ─── */
.afb-form-header { margin-bottom: 24px; }
.afb-form-header-title { font-size: 28px; font-weight: 700; margin: 0 0 8px; color: #222222; line-height: 1.43; }
.afb-form-header-text { font-size: 14px; color: #6a6a6a; margin: 0; line-height: 1.43; }
.afb-form-footer { margin-top: 20px; font-size: 13px; color: #929292; text-align: center; }

/* ─── 필드 그리드 ─── */
.afb-form-fields { display: flex; flex-wrap: wrap; gap: 16px; }
.afb-form-field { margin-bottom: 2px; box-sizing: border-box; }
.afb-col-1 { width: 100%; }
.afb-col-2 { width: calc(50% - 8px); }
.afb-col-3 { width: calc(33.333% - 11px); }

@media (max-width: 600px) {
    .afb-col-2, .afb-col-3 { width: 100%; }
}

/* ─── 라벨 ─── */
.afb-form-field > label { display: block; font-size: 14px; font-weight: 600; color: #222222; margin-bottom: 6px; line-height: 1.43; }
.afb-req { color: #c13515; font-weight: 700; }

/* ─── 인풋 (Airbnb: 8px radius, #222222 text, 2px focus ring) ─── */
.afb-form-field input[type="text"],
.afb-form-field input[type="email"],
.afb-form-field input[type="url"],
.afb-form-field input[type="tel"],
.afb-form-field input[type="number"],
.afb-form-field input[type="date"],
.afb-form-field input[type="time"],
.afb-form-field input[type="datetime-local"],
.afb-form-field textarea,
.afb-form-field select {
    width: 100%; padding: 12px 14px;
    border: 1px solid #c1c1c1; border-radius: 8px;
    font-size: 15px; font-weight: 600; color: #222222; background: #ffffff;
    box-sizing: border-box; line-height: 1.43;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.afb-form-field input:focus,
.afb-form-field textarea:focus,
.afb-form-field select:focus {
    border-color: #222222; outline: none;
    box-shadow: 0 0 0 2px #222222;
}
.afb-form-field input::placeholder,
.afb-form-field textarea::placeholder { color: #8a8a8a; font-weight: 500; }
.afb-form-field textarea { resize: vertical; min-height: 100px; }

/* ─── Select 커스텀 화살표 (테마의 chevron 타일링 버그 방지)
   - appearance: none 으로 OS/테마 화살표 제거
   - 자체 SVG chevron 1개 + no-repeat
   - 모든 background-* 단축 속성을 명시적으로 덮어써 테마 오버라이드 차단 */
.afb-form-wrapper .afb-form-field select,
body .afb-form-wrapper .afb-form-field select,
html body .afb-form-wrapper .afb-form-field select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-color: #ffffff !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M2 2L6 6L10 2' stroke='%23929292' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 18px center !important;
    background-size: 12px 8px !important;
    background-attachment: scroll !important;
    background-origin: padding-box !important;
    background-clip: border-box !important;
    padding-right: 42px !important;
    cursor: pointer;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    filter: none !important;
}
.afb-form-wrapper .afb-form-field select:hover,
body .afb-form-wrapper .afb-form-field select:hover {
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
}
.afb-form-wrapper .afb-form-field select::-ms-expand { display: none !important; }

/* 에러 */
.afb-form-field.has-error input,
.afb-form-field.has-error textarea,
.afb-form-field.has-error select { border-color: #c13515; }
/* 필드 개별 에러 — 전역 form-message 와 동일 포맷(배너) + font-weight 400 */
.afb-field-error {
    display: none;
    padding: 16px 20px;
    border-radius: 8px;
    margin-top: 8px;
    background: #fff0f0;
    color: #c13515;
    font: 400 14px/1.43 var(--font, 'Pretendard', -apple-system, system-ui, sans-serif);
    text-align: center;
}

/* ─── 코멘트 ─── */
.afb-field-comment { font-size: 13px; color: #6a6a6a; margin-top: 6px; line-height: 1.23; }

/* ─── 체크박스 / 라디오 ─── */
.afb-check-label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #222222; margin: 8px 0; cursor: pointer; font-weight: 400; line-height: 1.43; }
.afb-check-label input { margin: 0; width: 18px; height: 18px; }

/* ─── 약관 ─── */
.afb-terms-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; line-height: 1; }
.afb-terms-label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: #222222; cursor: pointer; font-weight: 400 !important; line-height: 1; margin: 0; }
.afb-terms-label input { margin: 0; width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }
.afb-terms-text { display: inline-flex; align-items: center; gap: 4px; line-height: 1; }
.afb-terms-text .afb-req { margin-left: 2px; line-height: 1; }
.afb-terms-links { display: inline-flex; align-items: center; gap: 8px; line-height: 1; }
.afb-terms-link { color: #222222; text-decoration: underline; font-size: 13px; font-weight: 500; line-height: 1; }
.afb-terms-link:hover { color: #3f3f3f; }

/* ─── 구분선 ─── */
.afb-divider { border: none; border-top: 1px solid #dddddd; margin: 12px 0; width: 100%; }

/* ─── 패러그래프 ─── */
.afb-paragraph { font-size: 14px; color: #6a6a6a; line-height: 1.6; margin: 0; }

/* ─── 별점 ─── */
.afb-star-rating { display: flex; gap: 6px; }
.afb-star-item { font-size: 32px; cursor: pointer; color: #dddddd; transition: color 0.15s; user-select: none; }
.afb-star-item:hover, .afb-star-item.active { color: #222222; }

/* ─── 숫자 척도 ─── */
.afb-number-scale { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.afb-scale-num {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: 1px solid #c1c1c1; border-radius: 8px;
    font-size: 14px; font-weight: 500; color: #6a6a6a;
    cursor: pointer; transition: all 0.15s; user-select: none;
}
.afb-scale-num:hover, .afb-scale-num.active { background: #222222; color: #ffffff; border-color: #222222; }
.afb-scale-caption { font-size: 12px; color: #929292; margin: 0 6px; }

/* ─── 스마일 ─── */
.afb-smiley-scale { display: flex; gap: 12px; }
.afb-smiley-item { font-size: 36px; cursor: pointer; opacity: 0.3; transition: all 0.2s; user-select: none; }
.afb-smiley-item:hover, .afb-smiley-item.active { opacity: 1; transform: scale(1.15); }

/* ─── 좋아요 ─── */
.afb-thumb-scale { display: flex; gap: 20px; }
.afb-thumb-item { font-size: 40px; cursor: pointer; opacity: 0.3; transition: all 0.2s; user-select: none; }
.afb-thumb-item:hover, .afb-thumb-item.active { opacity: 1; transform: scale(1.15); }

/* ─── 제출 버튼 (Airbnb Primary Dark — 백엔드 미리보기와 동일 규격)
   #222222 / 8px radius / 32px padding / 48px height / 500 16px
   테마 CSS 오버라이드 방지를 위한 !important + 개별 속성 지정 ─── */
.afb-form-wrapper .afb-form-submit { margin-top: 24px !important; }
.afb-form-wrapper .afb-form .afb-submit-btn,
.afb-form-wrapper button.afb-submit-btn,
body .afb-form-wrapper .afb-submit-btn,
body .afb-form-wrapper button[type="submit"].afb-submit-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding-top: 0 !important;
    padding-right: 32px !important;
    padding-bottom: 0 !important;
    padding-left: 32px !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    width: auto !important;
    min-width: 0 !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-radius: 8px !important;
    background-color: #222222 !important;
    background-image: none !important;
    color: #ffffff !important;
    font-family: 'Inter', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    line-height: 1.25 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    text-decoration: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    cursor: pointer !important;
    transition: box-shadow 0.15s, filter 0.15s !important;
    vertical-align: middle !important;
    margin: 0 !important;
}
.afb-form-wrapper .afb-submit-btn:hover { transform: none !important; opacity: 1 !important; filter: brightness(0.95); }
.afb-form-wrapper .afb-submit-btn:focus { box-shadow: 0 0 0 2px #222222 !important; transform: none !important; outline: none; }
.afb-form-wrapper .afb-submit-btn:disabled { opacity: 0.5 !important; cursor: not-allowed !important; transform: none !important; filter: none !important; }

/* ─── 메시지 ─── */
.afb-form-message {
    padding: 16px 20px;
    border-radius: 8px;
    margin-top: 20px;
    font: 400 14px/1.43 var(--font, 'Pretendard', -apple-system, system-ui, sans-serif);
    text-align: center;
}
.afb-form-message.success { background: #edfaef; color: #155724; }
.afb-form-message.error { background: #fff0f0; color: #c13515; }

/* ─── 제출 버튼 풀와이드 (PC / PC+Mobile / Mobile)
   base 룰(.afb-form-wrapper .afb-form .afb-submit-btn)이 width:auto, display:inline-flex 를
   !important로 강제하므로 같은 또는 더 높은 specificity로 덮어쓴다. */
.afb-form-wrapper .afb-form-submit { display: block; }
.afb-form-wrapper .afb-form .afb-submit-btn,
body .afb-form-wrapper .afb-form .afb-submit-btn {
    width: auto !important;
    display: inline-flex !important;
}
/* 풀와이드 ALL: 모든 화면에서 100% */
.afb-form-wrapper .afb-form-submit.afb-fw-all-wrap,
body .afb-form-wrapper .afb-form-submit.afb-fw-all-wrap { display: block !important; }
.afb-form-wrapper .afb-form .afb-submit-btn.afb-fw-all,
body .afb-form-wrapper .afb-form .afb-submit-btn.afb-fw-all {
    width: 100% !important;
    display: flex !important;
    max-width: 100% !important;
}
/* 풀와이드 PC: 769px 이상에서만 100% */
@media (min-width: 769px) {
    .afb-form-wrapper .afb-form-submit.afb-fw-pc-wrap,
    body .afb-form-wrapper .afb-form-submit.afb-fw-pc-wrap { display: block !important; }
    .afb-form-wrapper .afb-form .afb-submit-btn.afb-fw-pc,
    body .afb-form-wrapper .afb-form .afb-submit-btn.afb-fw-pc {
        width: 100% !important;
        display: flex !important;
        max-width: 100% !important;
    }
}
/* 풀와이드 MOBILE: 768px 이하에서만 100% */
@media (max-width: 768px) {
    .afb-form-wrapper .afb-form-submit.afb-fw-mobile-wrap,
    body .afb-form-wrapper .afb-form-submit.afb-fw-mobile-wrap { display: block !important; }
    .afb-form-wrapper .afb-form .afb-submit-btn.afb-fw-mobile,
    body .afb-form-wrapper .afb-form .afb-submit-btn.afb-fw-mobile {
        width: 100% !important;
        display: flex !important;
        max-width: 100% !important;
    }
}

/* ─── 약관 모달 (Airbnb: 20px radius, 3-layer shadow) ─── */
.afb-terms-modal {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.55);
    z-index: 2147483647;
    align-items: center; justify-content: center;
    padding: 20px; box-sizing: border-box;
}
.afb-terms-modal.afb-modal-open {
    display: flex !important;
    position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100vw !important; height: 100vh !important;
    background: rgba(0,0,0,0.55) !important;
    z-index: 2147483647 !important;
    align-items: center !important; justify-content: center !important;
    padding: 20px !important; box-sizing: border-box !important;
}
.afb-terms-modal-content {
    background: #ffffff !important; border-radius: 20px !important;
    padding: 0 !important;
    width: var(--afb-popup-w, 640px) !important;
    max-width: calc(100vw - 40px) !important;
    height: var(--afb-popup-h, 560px) !important;
    max-height: calc(100vh - 40px) !important;
    overflow: hidden !important;
    position: relative !important;
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    box-shadow: rgba(0,0,0,0.02) 0px 0px 0px 1px, rgba(0,0,0,0.04) 0px 2px 6px, rgba(0,0,0,0.1) 0px 4px 8px !important;
    color: #222222 !important;
}
.afb-terms-modal-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    padding: 28px 32px 16px !important;
    margin: 0 !important;
    border-bottom: 1px solid #dddddd !important;
    min-width: 0 !important;
}
.afb-terms-modal-header h3 { margin: 0 !important; font-size: 20px !important; font-weight: 600 !important; color: #222222 !important; letter-spacing: -0.4px; }
.afb-terms-modal-close {
    font-size: 28px !important; color: #929292 !important; cursor: pointer !important; line-height: 1 !important;
    width: 36px !important; height: 36px !important; display: flex !important; align-items: center !important; justify-content: center !important;
    border-radius: 50% !important; transition: background 0.15s; flex-shrink: 0;
}
.afb-terms-modal-close:hover { background: #f2f2f2 !important; color: #222222 !important; }
.afb-terms-body {
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    font-size: 14px !important;
    color: #3f3f3f !important;
    line-height: 1.8 !important;
    word-break: break-word;
    padding: 20px 32px 28px !important;
    box-sizing: border-box !important;
}
body.afb-modal-locked { overflow: hidden !important; }
.afb-terms-body::-webkit-scrollbar { width: 8px; }
.afb-terms-body::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }
.afb-terms-body::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }
.afb-terms-body::-webkit-scrollbar-track { background: transparent; }
.afb-terms-body p, .afb-terms-body li, .afb-terms-body div { color: #3f3f3f !important; font-size: 14px !important; line-height: 1.8 !important; }

/* 모바일 풀스크린 — 768px 이하 */
@media (max-width: 768px) {
    .afb-popup-mobile-full .afb-terms-modal,
    .afb-terms-modal.afb-popup-mobile-full {
        padding: 0 !important;
    }
    .afb-popup-mobile-full .afb-terms-modal.afb-modal-open,
    .afb-terms-modal.afb-popup-mobile-full.afb-modal-open {
        padding: 0 !important;
    }
    .afb-popup-mobile-full .afb-terms-modal-content,
    .afb-terms-modal.afb-popup-mobile-full .afb-terms-modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        padding: 0 !important;
    }
    .afb-popup-mobile-full .afb-terms-modal-header,
    .afb-terms-modal.afb-popup-mobile-full .afb-terms-modal-header {
        padding: 24px 20px 14px !important;
    }
    .afb-popup-mobile-full .afb-terms-body,
    .afb-terms-modal.afb-popup-mobile-full .afb-terms-body {
        padding: 16px 20px 24px !important;
    }
    .afb-popup-mobile-full .afb-terms-modal-close,
    .afb-terms-modal.afb-popup-mobile-full .afb-terms-modal-close {
        position: absolute !important;
        top: 12px !important; right: 12px !important;
        z-index: 2 !important;
    }
}

/* ─── 폼 래퍼 PC/모바일 너비 (CSS 변수 기반) ─── */
.afb-form-wrapper {
    max-width: var(--afb-w-pc, 100%);
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}
@media (max-width: 768px) {
    .afb-form-wrapper {
        max-width: var(--afb-w-mobile, 100%);
    }
}

/* ─── 버튼 텍스트 컬러 동기화: 약관 동의 영역 ───
   공통 설정에서 선택한 버튼 텍스트 컬러(--afb-btn-text)를
   약관 체크박스 라벨과 약관 링크에 동일하게 적용.
   폼 배경/필드/타이틀 등 나머지 요소는 건드리지 않음. */
.afb-form-wrapper .afb-terms-wrap,
.afb-form-wrapper .afb-terms-label,
.afb-form-wrapper .afb-terms-label *,
.afb-form-wrapper .afb-terms-text,
.afb-form-wrapper .afb-terms-text *,
.afb-form-wrapper .afb-terms-links,
.afb-form-wrapper .afb-terms-link {
    color: var(--afb-btn-text, #ffffff) !important;
}
.afb-form-wrapper .afb-terms-link { text-decoration: underline !important; }
.afb-form-wrapper .afb-terms-link:hover { opacity: .85; }
