/* ===== Modal Base ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .5);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 크기 변수 기본값 (모디파이어로 덮어씀) */
.modal {
    --modal-w: min(900px, 90vw);
    --modal-h: min(70vh, 90vh);
    --modal-radius: 12px;
    --modal-pad: 20px;

    --media-h: 360px;
}

/* 컨테이너 */
.modal__content {
    width: var(--modal-w);
    max-height: var(--modal-h);
    background: var(--color-bg, #fff);
    color: var(--color-text, #222);
    border-radius: var(--modal-radius);
    box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, .15));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 헤더/바디/푸터 */
.modal__header,
.modal__footer {
    padding: var(--modal-pad);
    background: var(--color-bg, #fff);
    display: flex;
    gap: 10px;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border, #e6e6ea);
}

.modal__title {
    font-size: 18px;
    font-weight: 600;
}

.modal__close {
    background: none;
    border: 0;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-muted, #666);
    padding: 4px;
    border-radius: 6px;
}

.modal__close:hover {
    background: var(--color-hover-bg, #f5f5f7);
}

.modal__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 0;
}

/* ===== 레이아웃 모디파이어 ===== */
/* 가로형: 좌(미디어/갤러리) - 우(디테일) */
.modal--h .modal__main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: var(--modal-pad);
}

/* 세로형: 상(미디어) - 하(디테일) */
.modal--v .modal__main {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 16px;
    padding: var(--modal-pad);
}

/* 미디어/디테일 공통 */
.modal__media {
    position: relative;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal__media > img,
.modal__media > iframe,
.modal__media > video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 0;
}

.modal__details {
    min-width: 0;
    height: 450px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* ===== 갤러리: 메인(상단) + 썸네일(하단) ===== */
.modal--has-subimage .modal__gallery {
    display: flex;
    flex-direction: column; /* 상단 메인, 하단 썸네일 */
    gap: 10px;
}

/* 메인 이미지 contain 모드(선택) */
.modal__media.modal__media--contain > img,
.modal__media.modal__media--contain > video,
.modal__media.modal__media--contain > iframe {
    object-fit: contain;
    background: #fff;
}

/* 썸네일 바 */
.modal--has-subimage .modal__subimages {
    position: relative;
}

/* 트랙(가로 슬라이드) */
.modal--has-subimage .modal__slider {
    display: flex;
    gap: 8px;
    overflow: hidden; /* JS translateX로 이동 */
    scroll-behavior: smooth;
}

/* 썸네일 아이템(버튼) */
.modal--has-subimage .modal__thumb {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: #eee;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.modal--has-subimage .modal__thumb.is-active {
    border-color: var(--color-primary, #2563eb);
}

.modal--has-subimage .modal__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #fff;
    border: 0;
}

/* 좌/우 네비게이션 버튼 */
.modal--has-subimage .modal__slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: var(--color-bg, #fff);
    border: 1px solid var(--color-border, #e6e6ea);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, .08));
    z-index: 1;
}

.modal--has-subimage .modal__slider-btn:hover {
    background: var(--color-hover-bg, #f5f5f7);
}

.modal--has-subimage .modal__slider-btn--prev {
    left: -16px;
}

.modal--has-subimage .modal__slider-btn--next {
    right: -16px;
}

/* ===== 크기 모디파이어 ===== */
.modal--sm {
    --modal-w: min(560px, 90vw);
    --modal-h: min(70vh, 90vh);
}

.modal--md {
    --modal-w: min(720px, 90vw);
    --modal-h: min(72vh, 90vh);
}

.modal--lg {
    --modal-w: min(900px, 92vw);
    --modal-h: min(80vh, 92vh);
}

.modal--xl {
    --modal-w: min(1120px, 95vw);
    --modal-h: min(85vh, 95vh);
}

/* 높이 보정 */
.modal--short {
    --modal-h: min(60vh, 90vh);
}

.modal--tall {
    --modal-h: min(90vh, 95vh);
}

/* ===== 콘텐츠 유틸 ===== */
.detail__section {
    margin-bottom: 15px;
}

.detail__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted, #666);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}

.detail__value {
    font-size: var(--fs-medium, 16px);
    color: var(--color-text, #222);
    margin-bottom: 6px;
}

.detail__value--lg {
    font-size: var(--fs-xlarge, 20px);
    font-weight: 600;
}

.detail__desc {
    line-height: 1.6;
    color: var(--color-text, #222);
    /*white-space: pre-line;*/
}

.detail__desc .member-list {display: flex; gap: 10px;}

.detail__actions {
    display: flex;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--color-border, #e6e6ea);
}

/* 배지 베이스: 기존 'status-badge'도 그대로 지원 */
.status-badge,
.modal__badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    color: #fff;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
    user-select: none;
    z-index: 2; /* 미디어 위로 */
    pointer-events: none; /* 배지가 클릭을 가로채지 않도록 */
    background: var(--badge-bg, #6b7280); /* 기본 */
}

/* 상태별 색상 (기존 클래스 네이밍도 지원) */
.status-badge.pending,
.modal__badge--pending {
    --badge-bg: #f59e0b;
}

/* 대기(amber) */
.status-badge.approved,
.modal__badge--approved {
    --badge-bg: #10b981;
}

/* 승인(green) */
.status-badge.rejected,
.modal__badge--rejected {
    --badge-bg: #ef4444;
}

/* 미승인(red)  */

/* 위치 유틸(선택) */
.modal__badge--tr {
    top: 8px;
    right: 8px;
    left: auto;
}

.modal__badge--bl {
    bottom: 8px;
    left: 8px;
    top: auto;
}

.modal__badge--br {
    bottom: 8px;
    right: 8px;
    top: auto;
    left: auto;
}

/* 반응형: 좁은 화면에선 세로 스택 */
@media (max-width: 920px) {
    .modal {
        --media-h: 240px;
    }

    .modal--h .modal__main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .modal__media {
        min-height: 200px;
    }
}

/* ====== Board (게시글) 모달 ====== */
/* ===== Board Create(Form) 보강 ===== */
.modal--board .board-modal__section + .board-modal__section {
    margin-top: 8px;
}

.board-form__field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.board-form__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted, #667085);
}

.board-form__input,
.board-form__textarea {
    width: 100%;
    border: 1px solid var(--color-border, #e6e6ea);
    border-radius: 10px;
    padding: 12px;
    font: inherit;
    line-height: 1.5;
}

.board-form__textarea {
    min-height: 180px;
    resize: vertical;
}

.modal--board .detail__actions {
    justify-content: flex-end;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border, #e6e6ea);
}

/* 좁은 화면 대응 */
@media (max-width: 560px) {
    .board-form__textarea {
        min-height: 140px;
    }
}

.modal--board {
    /* 읽기 가독성 중심 크기 */
    --modal-w: min(760px, 92vw);
    --modal-h: min(80vh, 92vh);
}

.modal--board .modal__body {
    /* 헤더 분리감 유지 + 본문 스크롤만 */
    padding: var(--modal-pad);
    overflow-y: auto;
}

/* 본문 래퍼 */
.board-modal {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 제목 */
.board-modal__title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text, #222);
    margin: 4px 0 0;
}

/* 섹션 공통 */
.board-modal__section {
    display: block;
}

/* 메타(작성자/등록일) 2열 */
.board-modal__meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
}

.board-modal__meta-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted, #667085);
    margin-bottom: 6px;
    letter-spacing: .2px;
    text-transform: none;
}

.board-modal__meta-value {
    font-size: 15px;
    color: var(--color-text, #222);
}

/* 본문 콘텐츠 */
.board-modal__content {
    white-space: pre-wrap;
    line-height: 1.7;
    color: var(--color-text, #222);
    word-break: break-word;
}

/* 댓글 블록 */
.board-comments {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 각 댓글 카드 */
.board-comment {
    position: relative;
    border: 1px solid var(--color-border, #e6e6ea);
    border-radius: 12px;
    padding: 10px; /* 우측 아이콘 영역 확보 */
    background: #fff;
    transition: box-shadow .2s ease, border-color .2s ease, transform .02s ease;
}

.board-comment:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
    border-color: #dfe3e8;
}

/* 상단 정보 줄 */
.board-comment__head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 20px;
    margin-bottom: 4px;
}

.board-comment__author {
    font-weight: 700;
    font-size: 14px;
    color: #222;
}

.board-comment__date {
    margin-left: auto;
    font-size: 12px;
    color: var(--color-text-muted, #667085);
}

/* 본문 */
.board-comment__body {
    font-size: var(--fs-small);
    white-space: pre-wrap;
    line-height: 1.6;
    color: #333;
    margin-top:5px;
}

/* 편집 영역 */
.board-comment__edit textarea {
    width: 100%;
    min-height: 84px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    outline: none;
    font: inherit;
    line-height: 1.5;
}

.board-comment__edit textarea:focus {
    border-color: #c7d2fe;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

/* ===== 우측 상단 아이콘 액션 ===== */
.board-comment [data-role="actions"] {
    position: absolute;
    top: 35px;
    right: 10px;
    display: inline-flex;
    gap: 5px;
    margin: 0;
    padding: 0;
    border-top: 0; /* 기존 detail__actions 테두리 제거 */
}

.board-comment [data-role="actions"] .button {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px; /* 버튼 텍스트 숨김 */
    line-height: 0;
    transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

.board-comment [data-role="actions"] .button:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.board-comment [data-role="actions"] .button:active {
    transform: translateY(1px);
}

/* 편집 모드일 땐 아이콘 숨김 (JS가 display:none 주는 로직과 호환) */
.board-comment [data-role="actions"][style*="display: none"] {
    display: none !important;
}

/* 댓글 입력 */
.board-comment-form textarea {
    width: 100%;
    min-height: 96px;
    padding: 12px;
    border: 1px solid var(--color-border, #e6e6ea);
    border-radius: 10px;
    font: inherit;
    resize: vertical;
}

.board-comment-form .detail__actions {
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 0;
}

/* 반응형: 모바일에서 터치 타깃 확보 */
@media (max-width: 560px) {
    .board-modal__meta {
        grid-template-columns: 1fr;
    }

    .board-comment {
        padding-right: 44px;
    }

    .board-comment [data-role="actions"] .button {
        width: 32px;
        height: 32px;
    }
}