/**
 * 파일명: profile.css
 * 위치: /wp-content/plugins/jmp-mypage/assets/css/
 * 설명: 프로필 페이지 전용 스타일 — v4.0 Modern Redesign
 * 버전: 4.0.0
 */

/* ════════════════════════════════════════
   추가 토큰 (profile 전용)
   ════════════════════════════════════════ */
.joyn-profile-wrapper {
    --avatar-size:       clamp(88px, 22vw, 121px);
    --avatar-font:       clamp(22px, 5vw, 30px);
    --profile-gap:       clamp(16px, 4vw, 28px);
}

/* ════════════════════════════════════════
   래퍼
   ════════════════════════════════════════ */
.joyn-profile-wrapper {
    padding-top: var(--joyn-space-5);
    display: flex;
    flex-direction: column;
    gap: var(--joyn-space-4);
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

/* ════════════════════════════════════════
   카드 공통 override — 더 넓은 radius + hover
   ════════════════════════════════════════ */
.joyn-profile-wrapper .joyn-card {
    border-radius: var(--radius-lg) !important;
    padding: var(--joyn-space-5);
    margin-bottom: 0;
    transition: box-shadow var(--transition);
}
.joyn-profile-wrapper .joyn-card:hover {
    box-shadow: var(--shadow-md);
}

/* ════════════════════════════════════════
   CARD 1 — 프로필 아이덴티티
   ════════════════════════════════════════ */
.joyn-profile-wrapper .profile-identity-card {
    background: linear-gradient(148deg, var(--bg-1) 0%, var(--bg-2) 100%) !important;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    /* 히어로와 간격 + 아바타 테두리·그림자가 잘리지 않도록 상단 여유 */
    padding-top: clamp(22px, 5.5vw, 32px) !important;
}
.joyn-profile-wrapper .profile-identity-card::before {
    content: '';
    position: absolute;
    top: -28px; right: -28px;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: var(--brand-glow);
    pointer-events: none;
    z-index: 0;
}
.joyn-profile-wrapper .profile-identity-card::after {
    content: '';
    position: absolute;
    bottom: -24px; left: -24px;
    width: 88px; height: 88px;
    border-radius: 50%;
    background: rgba(69,65,255,.05);
    pointer-events: none;
    z-index: 0;
}

/* ── 아이덴티티 레이아웃 ── */
.joyn-profile-wrapper .profile-top {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--profile-gap);
    text-align: left;
    position: relative; z-index: 1;
}

/* ── 아바타 섹션 ── */
.joyn-profile-wrapper .jmp-profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding-left: 0;
}
.joyn-profile-wrapper .jmp-profile-avatar-wrap {
    position: relative;
    width: var(--avatar-size);
    height: var(--avatar-size);
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 50%;
}
.joyn-profile-wrapper .jmp-profile-avatar-wrap .avatar,
.joyn-profile-wrapper .jmp-profile-avatar-wrap .jmp-profile-avatar-initial {
    width: 100%; height: 100%;
    border-radius: 50%;
    font-size: var(--avatar-font);
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-pale) 100%);
    color: var(--brand-contrast);
    display: flex; align-items: center; justify-content: center;
    border: 3px solid rgba(69,65,255,.18);
    box-shadow: 0 6px 20px rgba(69,65,255,.2);
}
.joyn-profile-wrapper .jmp-profile-avatar-wrap .jmp-profile-avatar-img {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(69,65,255,.18);
    box-shadow: 0 6px 20px rgba(69,65,255,.2);
}

/* 사진선택 버튼 (label) — 일반 버튼과 동일 */
.joyn-profile-wrapper .jmp-avatar-file-label {
    position: static;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    overflow: visible;
    border-radius: var(--radius-sm);
}
.joyn-profile-wrapper .jmp-avatar-file-input {
    display: none;
}

/* 업로드 중 오버레이 */
.joyn-profile-wrapper .jmp-profile-avatar-section.jmp-avatar-uploading .jmp-profile-avatar-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0,0,0,.4);
    z-index: 3;
}

/* 하단 버튼 (사진 / 삭제) — 같은 가로 한 줄에 배치 */
.joyn-profile-wrapper .jmp-profile-avatar-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 0;
}
.joyn-profile-wrapper .jmp-profile-avatar-actions .jmp-btn,
.joyn-profile-wrapper .jmp-profile-avatar-actions .jmp-avatar-file-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* ── 프로필 메인 (이름/이메일/배지) ── */
.joyn-profile-wrapper .profile-main {
    flex: 1;
    min-width: 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--joyn-space-2);
    margin-top: clamp(4px, 1.5vw, 10px);
    padding-left: 0;
}
.joyn-profile-wrapper .profile-main .name {
    font-size: var(--joyn-text-xl);
    font-weight: 800;
    color: var(--text-1);
    letter-spacing: -0.3px;
    line-height: 1.2;
    margin-bottom: 0;
}
.joyn-profile-wrapper .profile-main .email {
    font-size: var(--joyn-text-sm);
    color: var(--text-2);
    font-weight: 500;
}

/* ── 프로필 배지 ── */
.joyn-profile-wrapper .profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--joyn-space-1);
}
.joyn-profile-wrapper .profile-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--joyn-text-xs);
    font-weight: 700;
    transition: all var(--transition);
    line-height: 1.3;
}
.joyn-profile-wrapper .profile-badge i { font-size: 11px; }

.joyn-profile-wrapper .profile-badge.role-member {
    background: var(--brand-glow);
    color: var(--brand);
    border: 1px solid rgba(69,65,255,.18);
}
.joyn-profile-wrapper .profile-badge.role-admin {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: var(--brand-contrast);
    box-shadow: 0 2px 8px var(--brand-glow);
}
.joyn-profile-wrapper .profile-badge.role-acts {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: var(--brand-contrast);
    box-shadow: 0 2px 8px var(--warning-bg);
}
.joyn-profile-wrapper .profile-badge.phone-ok {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16,185,129,.2);
}

/* ── 통계: JSeeds / 등급 각 50% (빈 3열 그리드 잔상 방지) ── */
.joyn-profile-wrapper .profile-stats {
    display: flex;
    flex-direction: row;
    width: 100%;
    margin-top: var(--joyn-space-5);
    background: var(--border-1);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    z-index: 1;
    gap: 1px;
}
.joyn-profile-wrapper .profile-stat-item {
    flex: 1 1 50%;
    max-width: 50%;
    min-width: 0;
    box-sizing: border-box;
    background: var(--bg-2);
    padding: var(--joyn-space-4);
    text-align: center;
    transition: background var(--transition);
}
.joyn-profile-wrapper .profile-stat-item:hover { background: var(--bg-3); }
.joyn-profile-wrapper .profile-stat-value {
    font-size: var(--joyn-text-lg);
    font-weight: 800;
    color: var(--brand);
    display: block;
    line-height: 1.2;
}
.joyn-profile-wrapper .profile-stat-label {
    font-size: var(--joyn-text-xs);
    color: var(--text-3);
    margin-top: 3px;
    font-weight: 600;
    display: block;
}

/* ── ACTS 배너 (기존 호환) ── */
.joyn-profile-wrapper .joyn-profile-acts-banner {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%) !important;
    color: var(--brand-contrast);
}
.joyn-profile-wrapper .joyn-profile-acts-banner p { color: rgba(255,255,255,.85); }

/* ════════════════════════════════════════
   CARD 2 — 액션 버튼 카드
   ════════════════════════════════════════ */
.joyn-profile-wrapper .profile-actions {
    display: flex;
    flex-direction: row;
    gap: var(--joyn-space-3);
    padding: var(--joyn-space-4) !important;
}
.joyn-profile-wrapper .profile-actions .jmp-btn {
    flex: 1;
    min-height: 46px;
    font-size: var(--joyn-text-base);
    font-weight: 700;
    border-radius: var(--radius);
}

/* ════════════════════════════════════════
   공지 노티스
   ════════════════════════════════════════ */
.jmp-notice-points-after-verify {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: var(--joyn-space-4);
    background: var(--bg-2);
    border-left: 3px solid var(--brand);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: var(--joyn-text-sm);
    color: var(--text-2);
}
.jmp-notice-points-after-verify::before {
    content: '\EECE'; /* ri-information-line codepoint */
    font-family: 'remixicon';
    font-size: 16px;
    color: var(--brand);
    flex-shrink: 0;
    line-height: 1.4;
}

/* ════════════════════════════════════════
   섹션 타이틀
   ════════════════════════════════════════ */
.joyn-profile-wrapper .section-title {
    font-size: var(--joyn-text-xs);
    font-weight: 800;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .7px;
    margin: 0 0 var(--joyn-space-4) 0;
    padding: 0;
    background: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.joyn-profile-wrapper .section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-2);
}
.joyn-profile-wrapper .section-title i { display: none; }

/* ════════════════════════════════════════
   정보 행
   ════════════════════════════════════════ */
.joyn-profile-wrapper .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(11px,2.2vw,13px) 0;
    border-bottom: 1px solid var(--border-2);
    gap: 12px;
}
.joyn-profile-wrapper .info-row:last-child { border-bottom: none; }
/* 라벨(연락처·가입일·회원등급·교회명·직분): 보조 색으로 구분 */
.joyn-profile-wrapper .info-label {
    font-size: var(--joyn-text-sm);
    color: var(--text-3);
    font-weight: 500;
    flex-shrink: 0;
}
/* 값: 주 텍스트 색·굵기로 가독성 강화 */
.joyn-profile-wrapper .info-value {
    font-size: var(--joyn-text-sm);
    font-weight: 700;
    color: var(--text-1);
    text-align: right;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ── 배지 (info-row 안) ── */
.joyn-profile-wrapper .badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: var(--joyn-text-xs); font-weight: 700;
    background: var(--bg-2); color: var(--text-2);
    border: 1px solid var(--border-1);
}
.joyn-profile-wrapper .jmp-phone-verified-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 8px;
    font-size: 11px; font-weight: 700;
    color: var(--success);
    background: var(--success-bg);
    border-radius: var(--radius-full);
    border: 1px solid rgba(16,185,129,.2);
}

/* ── 역할 배지 (기존 호환) ── */
.jmp-role-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.church-admin-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: var(--brand-contrast) !important;
    border-radius: var(--radius-full);
    font-size: var(--joyn-text-xs); font-weight: 700;
    text-decoration: none;
    transition: transform var(--transition), box-shadow var(--transition);
}
.church-admin-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--brand-glow);
    color: var(--brand-contrast) !important;
}
.acts-minister-badge {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%) !important;
    box-shadow: 0 2px 8px var(--warning-bg);
}
.acts-minister-badge:hover { box-shadow: 0 4px 12px var(--warning-bg) !important; }

/* ════════════════════════════════════════
   하단 버튼 카드
   ════════════════════════════════════════ */
.joyn-profile-wrapper .jmp-cloud-withdraw-btns {
    display: flex;
    flex-wrap: wrap;
    gap: var(--joyn-space-3);
}
.joyn-profile-wrapper .jmp-withdraw-btn {
    background: var(--error-bg) !important;
    border-color: rgba(239,68,68,.25) !important;
    color: var(--error) !important;
}
.joyn-profile-wrapper .jmp-withdraw-btn:hover {
    background: var(--error) !important;
    border-color: var(--error) !important;
    color: var(--brand-contrast) !important;
}

/* ════════════════════════════════════════
   읽기 전용 필드
   ════════════════════════════════════════ */
input.form-control[readonly] {
    background: var(--bg-2);
    color: var(--text-2);
}

/* ════════════════════════════════════════
   휴대폰 인증 UI
   ════════════════════════════════════════ */
.jmp-phone-verify-group .jmp-phone-row {
    display: flex; gap: var(--joyn-space-2); align-items: center;
}
.jmp-phone-verify-group .jmp-phone-row input.form-control {
    flex: 1; min-width: 0;
}
.jmp-phone-otp-wrap {
    margin-top: var(--joyn-space-4);
    padding: var(--joyn-space-3);
    background: var(--bg-2);
    border-radius: var(--radius-sm);
}
.jmp-phone-otp-wrap .jmp-otp-label {
    display: block; font-size: var(--joyn-text-sm); font-weight: 600;
    margin-bottom: 6px; color: var(--text-1);
}
.jmp-phone-otp-delay-hint { margin-top: 6px; font-size: 12px; color: var(--text-2); }
.jmp-phone-otp-row { display: flex; gap: var(--joyn-space-2); align-items: center; }
.jmp-phone-otp-row .jmp-otp-input {
    width: 100px; text-align: center;
    letter-spacing: 4px; font-size: 1.1em;
}
.jmp-phone-otp-hint { margin: 8px 0 0; font-size: 12px; color: var(--text-2); }
.jmp-phone-verified-msg { margin-top: 8px; margin-bottom: 0; color: var(--text-1); }
.jmp-phone-duplicate-msg { margin: 6px 0 0; font-size: 13px; color: var(--error); }

/* ════════════════════════════════════════
   교회 검색 드롭다운
   ════════════════════════════════════════ */
.church-search-group { position: relative; overflow: visible; }
.church-search-wrapper { position: relative; overflow: visible; }
.church-search-results {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-1);
    border: 1px solid var(--border-1);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: min(60vh, 500px);
    overflow-y: scroll; overflow-x: hidden;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    color: var(--text-1);
}
.church-result-item {
    padding: 12px 16px; cursor: pointer;
    border-bottom: 1px solid var(--border-2);
    transition: background var(--transition); color: var(--text-1);
}
.church-result-item:last-child { border-bottom: none; }
.church-result-item:hover { background: var(--bg-2); }
.church-result-id { font-size: .75rem; color: var(--text-3); margin-bottom: 2px; font-family: monospace; }
.church-result-name { font-weight: 700; color: var(--text-1); margin-bottom: 4px; }
.church-result-info { font-size: .85rem; color: var(--text-2); display: flex; gap: 12px; flex-wrap: wrap; }
.church-result-info i { color: var(--text-3); }
.search-loading, .no-results, .search-error {
    padding: 16px; text-align: center; color: var(--text-2);
}
.search-error { color: var(--error); }
.selected-church-display {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px; padding: 10px 14px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: var(--brand-contrast); border-radius: var(--radius); font-size: .9rem;
}
.selected-church-display span { flex: 1; font-weight: 600; }
.selected-church-display .remove-church {
    background: rgba(255,255,255,.2); border: none;
    color: var(--brand-contrast); width: 24px; height: 24px;
    border-radius: 50%; cursor: pointer; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
}
.selected-church-display .remove-church:hover { background: rgba(255,255,255,.35); }
.form-hint { display: block; margin-top: 6px; font-size: .8rem; color: var(--text-3); }

/* ════════════════════════════════════════
   모달
   ════════════════════════════════════════ */
.joyn-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999; display: none;
}
.joyn-modal-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5); cursor: pointer;
}
.joyn-modal-content {
    position: relative; max-width: 600px;
    margin: 50px auto;
    background: var(--bg-1);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    color: var(--text-1);
}
.joyn-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-1);
    display: flex; justify-content: space-between; align-items: center;
}
.joyn-modal-header h3 { margin: 0; font-size: 18px; font-weight: 700; color: var(--text-1); }
.joyn-modal-close {
    background: none; border: none;
    font-size: 28px; line-height: 1; cursor: pointer;
    color: var(--text-2); padding: 0; width: 32px; height: 32px;
}
.joyn-modal-close:hover { color: var(--text-1); }
.joyn-modal-body { padding: 24px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--text-1); }
.form-control {
    width: 100%; padding: 12px 16px;
    border: 1.5px solid var(--border-1);
    border-radius: var(--radius); font-size: 15px;
    transition: border-color var(--transition);
    background: var(--bg-input); color: var(--text-1);
    font-family: inherit;
}
.form-control:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
    background: var(--bg-1);
}
.form-group small { display: block; margin-top: 4px; font-size: 13px; color: var(--text-2); }
.form-actions {
    display: flex; gap: 12px;
    justify-content: flex-end; margin-top: 24px;
}
.form-actions .jmp-btn { min-width: 100px; }
body.modal-open { overflow: hidden; }

/* ════════════════════════════════════════
   프로필 수정 전용 페이지
   ════════════════════════════════════════ */
.joyn-profile-edit-page.jmp-profile-edit-page {
    max-width: 560px; margin: 0 auto; padding: 24px;
}
.joyn-profile-edit-page .jmp-profile-edit-header {
    display: flex; align-items: center;
    gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.joyn-profile-edit-page .jmp-back-to-mypage { text-decoration: none; }
.joyn-profile-edit-page .jmp-profile-edit-title {
    margin: 0; font-size: 1.25rem; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.joyn-profile-edit-page .jmp-profile-edit-actions {
    margin-top: 28px; padding-top: 20px;
    border-top: 1px solid var(--border-1);
}

/* ════════════════════════════════════════
   로딩 애니메이션
   ════════════════════════════════════════ */
@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.rotating { animation: rotate 1s linear infinite; }

/* ════════════════════════════════════════
   반응형
   ════════════════════════════════════════ */
@media (max-width: 600px) {
    /* 퍼플 히어로와 첫 카드 사이 시각적 간격 */
    .joyn-profile-wrapper {
        --avatar-size: clamp(114px, 28.6vw, 157px);
        --avatar-font: clamp(29px, 6.5vw, 39px);
        padding-top: clamp(12px, 3vw, 20px);
    }
    .joyn-profile-wrapper .profile-top {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .joyn-profile-wrapper .profile-main {
        align-items: center;
        text-align: center;
    }
    .joyn-profile-wrapper .profile-badges { justify-content: center; }
    .joyn-profile-wrapper .info-row { align-items: flex-start; flex-direction: column; gap: 4px; }
    .joyn-profile-wrapper .info-value { text-align: left; justify-content: flex-start; }
    /* 모바일: 기본 정보·교회 정보 라벨·값 폰트 확대 */
    .joyn-profile-wrapper .section-title {
        font-size: 14px;
    }
    .joyn-profile-wrapper .info-label {
        font-size: 16px;
    }
    .joyn-profile-wrapper .info-value {
        font-size: 17px;
    }
    .joyn-profile-wrapper .info-row .badge {
        font-size: 15px;
    }
    .joyn-modal-content {
        position: fixed;
        top: 50%;
        left: 16px;
        right: 16px;
        width: auto;
        max-width: 360px;
        margin: 0 auto;
        transform: translateY(-50%);
        max-height: calc(100vh - 80px);
        max-height: calc(100dvh - 80px);
        overflow-y: auto;
        box-sizing: border-box;
    }
    #joyn-change-password-modal .joyn-modal-content {
        max-height: 72vh; display: flex;
        flex-direction: column; overflow: hidden;
    }
    #joyn-change-password-modal .joyn-modal-header { flex-shrink: 0; }
    #joyn-change-password-modal .joyn-modal-body {
        flex: 1; min-height: 0;
        overflow-y: auto; -webkit-overflow-scrolling: touch;
    }
    .form-actions { flex-direction: column; }
    .form-actions button { width: 100%; }
}
