/* =============================================
   FreeMode Design System - Modal Styles
   ============================================= */

/* ===== Modal Styles (Unified) ===== */
.modal-overlay {
    backdrop-filter: blur(1px);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 모달 호출 시 배경을 ref-ink 기준 60% 딤드로 처리한다. */
    background: color-mix(in srgb, var(--ref-ink) 60%, transparent);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--k-z-overlay);
}

/* 모달 위에 모달을 띄울 때 배경 없는 오버레이 */
.modal-overlay.no-backdrop {
    background: color-mix(in srgb, var(--ref-ink) 60%, transparent);
    backdrop-filter: blur(1px);
    z-index: var(--k-z-modal);
}

/* Base Modal Container - 통일된 기본 스타일 */
.modal-container {
    /* 기본 모달의 내부 가로 여백 값을 공통 변수로 관리한다. */
    --modal-inline-padding: 24px;
    background: var(--k-bg-white);
    border: none !important;
    border-radius: var(--fm-radius-medium);
    padding: 24px 0;
    max-width: 530px;
    width: 90%;
    position: relative;
    box-shadow: var(--k-shadow-modal);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* 개인정보 약관 모달 전용 클래스 - 중앙 정렬 보장 */
.privacy-modal-content {
    background: var(--k-bg-white);
    border-radius: var(--fm-radius-medium);
    padding: 16px 24px;
    max-width: 700px;
    width: 90%;
    position: relative;
    box-shadow: var(--k-shadow-box);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    margin: 0;
}

/* Modal Size Variants */
.modal-container.modal-small,
.modal-freemode.modal-small {
    max-width: 400px;
}

.modal-container.modal-medium,
.modal-freemode.modal-medium {
    max-width: 600px;
}

.modal-container.modal-large,
.modal-freemode.modal-large {
    max-width: 800px;
}

.modal-container.modal-xlarge,
.modal-freemode.modal-xlarge {
    max-width: 1000px;
}

/* 고객 등록 모달 전용 스타일 - 가운데 정렬 및 흰색 배경 */
#customerModal.modal-overlay {
    justify-content: center;
    align-items: center;
}

#customerModal .modal-freemode {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    max-width: 500px !important;
    height: auto !important;
    background: var(--k-bg-white) !important;
    background-color: var(--k-bg-white) !important;
}

/* Modal Fullscreen Mobile - 모바일에서 전체화면 모달 */
.modal-container.modal-fullscreen-mobile,
.modal-freemode.modal-fullscreen-mobile,
.modal-container-tab.modal-fullscreen-mobile {
    /* 데스크탑에서는 기본 스타일 유지 */
}

/* Modal Container Tab - 탭이 있는 모달용 (padding 있음) */
.modal-container-tab {
    /* 탭 모달의 내부 가로 여백 값을 공통 변수로 관리한다. */
    --modal-inline-padding: 24px;
    background: var(--k-bg-white);
    border: var(--k-border-thin);
    border-radius: var(--fm-radius-medium);
    box-shadow: var(--k-shadow-modal);
    padding: 24px 0;
    overflow: hidden;
    max-width: 550px;
    width: 90%;
    position: relative;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-container-tab.modal-small {
    max-width: 400px;
}

.modal-container-tab.modal-medium {
    max-width: 600px;
}

.modal-container-tab.modal-large {
    max-width: 800px;
}

/* 소셜 회원가입 약관 모달의 숨김 상태를 명시적으로 유지한다. */
.modal-overlay[hidden] {
    display: none;
}

/* 소셜 회원가입 약관 모달이 열렸을 때 배경 화면 스크롤을 막는다. */
body.social-signup-consent-open {
    overflow: hidden;
}

/* 소셜 회원가입 약관 모달의 본문 높이와 내부 간격을 구성한다. */
.modal-container.social-signup-consent-modal {
    max-height: 90vh;
}

.modal-header.social-signup-consent-header {
    align-items: flex-start;
}

.social-signup-consent-error {
    margin: 0;
    color: var(--ref-accent-orange);
    font-size: var(--fm-font-size-label);
}

.social-signup-consent-error[hidden] {
    display: none;
}

.social-signup-consent-footer {
    gap: 8px;
}

.social-signup-consent-footer .btn-freemode {
    flex: 1;
}

@media (max-width: 767px) {
    .social-signup-consent-overlay {
        align-items: flex-end;
    }

    .modal-container.social-signup-consent-modal {
        width: 100%;
        max-height: 92vh;
        border-radius: var(--fm-radius-medium) var(--fm-radius-medium) 0 0;
    }
}

/* 헤더 프로필 메뉴 버튼은 기존 드롭다운 링크와 동일한 모양으로 표시한다. */
.header-profile-menu-button {
    width: 100%;
    border: 0;
    background: var(--k-bg-white);
    font-family: var(--k-font-primary);
    text-align: left;
    cursor: pointer;
}

/* 헤더 프로필 모달은 시안처럼 화면 중앙의 작은 카드로 표시한다. */
.header-profile-modal-overlay {
    padding: 16px;
    backdrop-filter: none;
}

body.header-profile-modal-open {
    overflow: hidden;
}

.header-profile-modal {
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 20px 18px;
    border-radius: var(--fm-radius-medium);
    background: var(--k-bg-white);
    box-shadow: var(--k-shadow-modal);
    color: var(--ref-ink);
    font-family: var(--k-font-primary);
    animation: popIn 0.2s ease;
}

/* 구독 모달은 변경 시안의 카드 너비와 내부 여백을 사용한다. */
.header-subscription-modal {
    max-width: 400px;
    padding: 36px 24px 32px;
    border-radius: var(--fm-radius-medium);
}

.header-profile-modal-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
}

.header-profile-modal-title-row h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ref-ink);
}

.header-subscription-summary h3,
.header-subscription-notice h3 {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--ref-gray-700);
}

.header-subscription-action-button:disabled,
.header-subscription-small-button:disabled,
.header-subscription-cancel-actions button:disabled {
    cursor: default;
    opacity: 0.6;
}

/* 구독 모달은 현재 플랜, 결제 예정 정보, 이용안내와 주요 동작을 변경 시안 순서로 표시한다. */
.header-subscription-modal .header-profile-modal-title-row {
    margin-bottom: 34px;
}

.header-subscription-modal .header-profile-modal-title-row h2 {
    font-size: 20px;
    line-height: 1.4;
}

.header-subscription-summary {
    padding-bottom: 28px;
    border-bottom: 1px solid var(--fm-color-border);
}

.header-subscription-summary h3,
.header-subscription-notice h3 {
    margin-bottom: 14px;
    color: var(--fm-color-text-secondary);
    font-size: 14px;
    font-weight: 600;
}

.header-subscription-summary p {
    margin: 0;
    color: var(--fm-color-text-primary);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
}

.header-subscription-summary p strong {
    color: var(--fm-color-primary);
}

.header-subscription-payment {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 26px 0 28px;
    border-bottom: 1px solid var(--fm-color-border);
}

#headerSubscriptionInfoView.is-free .header-subscription-payment {
    padding-bottom: 0;
    border-bottom: 0;
}

#headerSubscriptionInfoView.is-free #headerSubscriptionMethodRow,
#headerSubscriptionInfoView.is-free #headerSubscriptionNotice,
#headerSubscriptionInfoView.is-free #headerSubscriptionCancelButton,
#headerSubscriptionInfoView:not(.is-free) #headerSubscriptionChangeButton {
    display: none;
}

.header-subscription-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 24px;
    font-size: 14px;
}

.header-subscription-row > span {
    color: var(--fm-color-text-secondary);
    font-weight: 600;
}

.header-subscription-row strong {
    font-size: 14px;
    font-weight: 500;
    color: var(--fm-color-text-primary);
}

.header-subscription-method-row > div {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    min-width: 0;
}

.header-subscription-method-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-subscription-small-button {
    flex: 0 0 auto;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--fm-color-border-strong);
    border-radius: var(--k-radius-md);
    background: var(--fm-color-surface);
    color: var(--fm-color-text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.header-subscription-notice {
    padding: 28px 0 0;
}

.header-subscription-notice ul {
    margin: 0;
    padding-left: 20px;
    color: var(--fm-color-text-secondary);
}

.header-subscription-notice li {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.65;
    word-break: keep-all;
}

.header-subscription-notice li:last-child {
    margin-bottom: 0;
}

.header-subscription-actions {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 8px;
    margin-top: 32px;
}

#headerSubscriptionInfoView.is-free .header-subscription-actions {
    grid-template-columns: minmax(0, 1fr) 80px;
}

.header-subscription-action-button {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--fm-color-border-strong);
    border-radius: var(--k-radius-md);
    background: var(--fm-color-surface);
    color: var(--fm-color-text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.header-subscription-action-button.is-primary {
    border-color: var(--fm-color-primary);
    background: var(--fm-color-primary);
    color: var(--fm-color-surface);
}

#headerSubscriptionChangeButton {
    display: none;
}

.header-subscription-cancel-heading {
    margin-bottom: 34px;
    text-align: center;
}

.header-subscription-cancel-heading h2 {
    margin: 0;
    color: var(--fm-color-text-primary);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.5;
    word-break: keep-all;
}

.header-subscription-cancel-view > p {
    margin: 0;
    text-align: center;
    color: var(--fm-color-text-secondary);
    font-size: 14px;
    line-height: 1.65;
    word-break: keep-all;
}

.header-subscription-cancel-view > p strong {
    font-weight: 700;
}

.header-subscription-cancel-actions {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 8px;
    margin-top: 42px;
}

.header-subscription-cancel-actions button {
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--fm-color-border-strong);
    border-radius: var(--k-radius-md);
    background: var(--fm-color-surface);
    color: var(--fm-color-text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.header-subscription-cancel-actions button.is-primary {
    border-color: var(--fm-color-primary);
    background: var(--fm-color-primary);
    color: var(--fm-color-surface);
}

/* 모바일에서는 프로필 모달을 안전 영역 안에서 세로 스크롤할 수 있도록 확장한다. */
@media (max-width: 480px) {
    .header-profile-modal-overlay {
        align-items: flex-start;
        overflow-y: auto;
        padding: 12px;
    }

    .header-profile-modal {
        max-width: none;
        max-height: none;
        margin: auto 0;
        padding: 22px 18px;
    }

    .header-subscription-modal {
        max-width: 400px;
        padding: 30px 20px 24px;
    }

    .header-subscription-method-row {
        align-items: flex-start;
    }

    .header-subscription-method-row > div {
        flex-wrap: wrap;
    }

    .header-subscription-actions,
    .header-subscription-cancel-actions {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    #headerSubscriptionInfoView.is-free .header-subscription-actions {
        grid-template-columns: minmax(0, 1fr) 72px;
    }
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header.no-border {
    border-bottom: none;
}

/* 모달 제목의 공통 글자 위계를 정의한다. */
.modal-title {
    font-size: var(--fm-font-size-heading-small);
    font-weight: 600;
    font-family: var(--k-font-primary);
    color: var(--ref-ink);
    margin: 0;
}

/* Modal Close Button */
.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--ref-gray-700);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.modal-close-btn:hover {
    color: var(--ref-ink);
    background-color: var(--k-bg-gray-light);
}

/* Modal Body */
.modal-body {
    overflow-y: auto;
    scrollbar-gutter: auto;
    flex: 1;
    min-height: 0;
    margin-right: 0;
    padding: 0 24px;
}

/* 모달 본문 스크롤바를 컨테이너 우측 끝에 정렬한다. */
.modal-container > .modal-body,
.modal-container-tab > .modal-body {
    margin-right: 0;
    padding-right: var(--modal-inline-padding);
}

.modal-body.no-padding {
    padding: 0;
}

/* no-padding 본문은 컨테이너 가로 여백을 적용하지 않는다. */
.modal-container > .modal-body.no-padding,
.modal-container-tab > .modal-body.no-padding {
    padding-left: 0;
    padding-right: 0;
}

/* Modal Footer */
.modal-footer {
    padding: var(--fm-modal-body-footer-gap) 0 0;
    margin-top: 0;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.modal-footer.space-between {
    justify-content: space-between;
    padding: var(--fm-modal-body-footer-gap) 24px 0;
}

.modal-footer.center {
    justify-content: center;
    gap: 8px;
}

.modal-footer.no-border {
    border-top: none;
    margin-top: 0;
}

/* 모달 폼 입력 그룹의 공통 간격을 정의한다. */
.form-group {
    margin-bottom: 19px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--ref-ink);
}

/* 모달 내부 폼 라벨의 글자 위계를 통일한다. */
.modal-overlay .form-label {
    font-size: var(--fm-font-size-label);
    font-weight: 600;
}

/* Modal 내부의 모든 input과 textarea 폰트 사이즈 */
.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="password"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body input[type="time"],
.modal-body input[type="tel"],
.modal-body input[type="url"],
.modal-body input[type="search"],
.modal-body textarea,
.modal-overlay input[type="text"],
.modal-overlay input[type="email"],
.modal-overlay input[type="password"],
.modal-overlay input[type="number"],
.modal-overlay input[type="date"],
.modal-overlay input[type="time"],
.modal-overlay input[type="tel"],
.modal-overlay input[type="url"],
.modal-overlay input[type="search"],
.modal-overlay textarea {
    font-size: 14px !important;
}

/* Modal Footer Sections */
.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 모바일에서는 기본 모달 컨테이너의 상하 패딩을 축소해 화면 활용도를 높인다. */
@media (max-width: 1023px) {
    .modal-container,
    .modal-container-tab {
        padding: 12px 0;
    }
}

/* ==========================================================
   Figma 소셜 회원가입 약관 팝업
   ========================================================== */

/* 소셜 가입 팝업을 Figma 기준 레이아웃으로 표시한다. */
.modal-container.social-signup-consent-modal {
    display: flex;
    flex-direction: column;
    gap: 42px;
    width: 520px;
    max-width: calc(100% - 32px);
    max-height: none;
    padding: var(--fm-space-8) var(--fm-space-6);
    box-sizing: border-box;
    background: var(--fm-color-surface);
    border: 0;
    border-radius: var(--fm-radius-medium);
    box-shadow: var(--fm-shadow-modal);
}

.social-signup-consent-content {
    display: flex;
    flex-direction: column;
    gap: 52px;
    width: 100%;
}

.social-signup-consent-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--fm-space-6);
    text-align: center;
}

.social-signup-consent-header img {
    width: 50px;
    height: 14px;
}

.social-signup-consent-header h2 {
    margin: 0;
    color: var(--fm-color-text-primary);
    font-size: 26px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

.social-signup-consent-header h2 strong {
    color: var(--fm-color-primary);
    font-weight: 600;
}

.social-signup-consent-list {
    display: flex;
    flex-direction: column;
    gap: var(--fm-space-4);
    width: 100%;
    color: var(--fm-color-text-primary);
    font-size: var(--fm-font-size-body);
}

/* 전체 동의 아래의 개별 동의 항목을 Figma 기준 8픽셀 간격으로 묶습니다. */
.social-signup-consent-items {
    display: flex;
    flex-direction: column;
    gap: var(--fm-space-2);
    width: 100%;
}

.social-signup-consent-row,
.social-signup-consent-row label {
    display: flex;
    align-items: center;
    gap: var(--fm-space-2);
    min-width: 0;
}

.social-signup-consent-row {
    justify-content: space-between;
}

.social-signup-consent-row[hidden] {
    display: none;
}

.social-signup-consent-all {
    justify-content: flex-start;
    overflow: hidden;
}

/* 만 15세 이상 동의 문구를 다른 개별 약관과 동일하게 왼쪽에 배치한다. */
.social-signup-consent-age {
    justify-content: flex-start;
}

.social-signup-consent-row input {
    width: 18px;
    height: 18px;
    margin: 0;
    appearance: none;
    background: var(--fm-color-surface);
    border: 1px solid var(--fm-color-border-strong);
    border-radius: 2px;
    flex: 0 0 18px;
}

.social-signup-consent-row input:checked {
    background: var(--fm-color-primary) url('/images/auth/auth-checkbox-checked.svg') center / 18px 18px no-repeat;
    border-color: var(--fm-color-primary);
}

.social-signup-consent-row span {
    line-height: 1.4;
}

.social-signup-consent-row strong {
    color: var(--fm-color-primary);
}

.social-signup-consent-row em {
    color: var(--fm-color-danger);
    font-style: normal;
}

.social-signup-consent-row i {
    color: var(--fm-color-text-secondary);
    font-style: normal;
}

.social-signup-consent-divider {
    width: 100%;
    height: 1px;
    margin-bottom: 0;
    background: var(--fm-color-border);
}

.social-signup-policy-view {
    flex: 0 0 auto;
    padding: 0;
    color: var(--fm-color-text-secondary);
    font-family: var(--fm-font-family);
    font-size: var(--fm-font-size-body);
    background: transparent;
    border: 0;
    cursor: pointer;
}

.social-signup-consent-error {
    margin: 0;
    color: var(--fm-color-danger);
    font-size: var(--fm-font-size-small);
}

.social-signup-consent-footer {
    display: flex;
    align-items: center;
    gap: var(--fm-space-2);
    width: 100%;
}

.social-signup-consent-footer button {
    height: 42px;
    padding: 0 var(--fm-space-4);
    font-family: var(--fm-font-family);
    font-size: var(--fm-font-size-body);
    font-weight: 500;
    border-radius: var(--fm-radius-medium);
    cursor: pointer;
}

#socialSignupConsentComplete {
    flex: 1;
    color: var(--fm-color-surface);
    background: var(--fm-color-primary);
    border: 1px solid var(--fm-color-primary);
}

#socialSignupConsentCancel {
    flex: 0 0 72px;
    min-width: 72px;
    color: var(--fm-color-text-primary);
    background: var(--fm-color-canvas);
    border: 1px solid var(--fm-color-border);
    white-space: nowrap;
}

/* 회원가입 완료 팝업을 Figma 기준 420픽셀 규격으로 표시합니다. */
.modal-container.signup-complete-modal {
    display: flex;
    flex-direction: column;
    gap: 42px;
    width: 420px;
    max-width: calc(100% - 32px);
    max-height: none;
    padding: var(--fm-space-8) var(--fm-space-6);
    box-sizing: border-box;
    background: var(--fm-color-surface);
    border: 0;
    border-radius: var(--fm-radius-medium);
    box-shadow: var(--fm-shadow-modal);
}

/* 완료 안내 내용과 제목 영역을 세로 중앙 정렬합니다. */
.signup-complete-content,
.signup-complete-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.signup-complete-content {
    gap: var(--fm-space-6);
}

.signup-complete-header {
    gap: 18px;
}

.signup-complete-header img {
    width: 40px;
    height: 40px;
}

.signup-complete-header h2 {
    margin: 0;
    color: var(--fm-color-text-primary);
    font-size: var(--fm-font-size-detail-title);
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

/* 완료 안내 문구를 Figma 기준 보조 본문 스타일로 표시합니다. */
.signup-complete-description {
    margin: 0;
    color: var(--fm-color-text-secondary);
    font-size: var(--fm-font-size-body);
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: -0.02em;
    text-align: center;
}

.signup-complete-description span {
    display: block;
}

.signup-complete-description strong {
    color: var(--fm-color-primary);
    font-weight: 500;
}

#signupCompleteStart {
    width: 100%;
    height: 42px;
    padding: 0 var(--fm-space-4);
    color: var(--fm-color-surface);
    font-family: var(--fm-font-family);
    font-size: var(--fm-font-size-body);
    font-weight: 500;
    background: var(--fm-color-primary);
    border: 1px solid var(--fm-color-primary);
    border-radius: var(--fm-radius-medium);
    cursor: pointer;
}

/* 완료 팝업이 열린 동안 배경 화면의 스크롤을 막습니다. */
body.signup-complete-open {
    overflow: hidden;
}
