/* v2/css/modal.css — Bootstrap 5 모달 공통 테마 */

.modal-backdrop {
    --bs-backdrop-bg: #000;
    --bs-backdrop-opacity: 0.65;
    z-index: 1050;
}

[data-theme='light'] .modal-backdrop {
    --bs-backdrop-bg: #0f172a;
    --bs-backdrop-opacity: 0.45;
}

.modal {
    z-index: 1055;
    font-family: var(--theme-font, 'Pretendard Variable', sans-serif);
}

/* 토스트는 모달·백드롭보다 항상 위 */
.toast-container {
    z-index: 20000 !important;
}

.modal h6,
.modal .modal-title {
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    color: inherit;
}

.modal .modal-content,
.modal .modal-body,
.modal .modal-footer,
.modal .form-control,
.modal .form-select,
.modal select.form-control,
.modal label,
.modal .btn {
    font-family: inherit;
}

.modal .modal-content {
    background: var(--theme-modal-bg, var(--theme-table-row-bg)) !important;
    color: var(--theme-modal-text, var(--theme-table-row-text)) !important;
    border: 1px solid var(--theme-modal-border, var(--theme-table-border)) !important;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--theme-shadow, 0 8px 24px rgba(0, 0, 0, 0.35));
}

.modal .modal-content > :first-child {
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.modal .modal-content > :last-child {
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

.modal .modal-header {
    background: var(--theme-modal-header-bg, var(--theme-table-header-bg)) !important;
    color: var(--theme-modal-header-text, var(--theme-table-header-text)) !important;
    border-bottom: 1px solid var(--theme-modal-border, var(--theme-table-border)) !important;
    align-items: center;
}

.modal .modal-body {
    background: var(--theme-table-row-bg) !important;
    color: var(--theme-table-row-text) !important;
    padding: .75rem !important;
}

#ivMsg .modal-dialog {
    --iv-msg-max-width: 500px;
    --iv-msg-min-width: 300px;
    width: fit-content;
    min-width: min(var(--iv-msg-min-width), calc(100vw - 2rem));
    max-width: min(var(--iv-msg-max-width), calc(100vw - 2rem));
    margin-left: auto;
    margin-right: auto;
}

#ivMsg .modal-content {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
}

#ivMsg .iv-msg-text {
    font-size: 1rem;
    font-weight: 400;
    color: inherit;
    line-height: 1.5;
    font-family: inherit;
    text-align: center;
    width: 100%;
    max-width: 100%;
    word-break: break-word;
}

#ivMsg .iv-msg-text img {
    max-width: 100%;
    height: auto;
}

#ivMsg .modal-footer {
    flex-wrap: nowrap;
    justify-content: center;
    white-space: nowrap;
}

.modal .modal-footer,
.modal .modal-footer.bg-light {
    background: var(--theme-modal-footer-bg, var(--theme-table-row-bg)) !important;
    color: var(--theme-modal-text, var(--theme-table-row-text)) !important;
    /* border-top: 1px solid var(--theme-modal-border, var(--theme-table-border)) !important; */
    padding: .75rem !important;
    border-top: none !important;
}

/* bg-primary/manager도 테이블 헤더와 동일 (모달 기본 헤더 클래스) */
.modal .modal-header.bg-primary,
.modal .modal-header.bg-manager,
.modal .modal-header.bg-dark {
    background: var(--theme-table-header-bg) !important;
    color: var(--theme-table-header-text) !important;
    border-bottom-color: var(--theme-table-border, var(--theme-modal-border));
}

.modal .modal-header.bg-warning {
    background: var(--theme-btn-warning-bg, #f0ad4e) !important;
    color: var(--theme-btn-warning-text, #111) !important;
}

.modal .modal-header.bg-danger {
    background: var(--theme-btn-danger-bg, #d9534f) !important;
    color: #fff !important;
}

/* BS4 .close → BS5 헤더에서 보이게 */
.modal-header .close {
    box-sizing: content-box;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0.25rem;
    margin: -0.25rem -0.25rem -0.25rem auto;
    background: transparent;
    border: 0;
    border-radius: 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: inherit;
    opacity: 0.75;
    cursor: pointer;
}

.modal-header .close:hover,
.modal-header .close:focus {
    opacity: 1;
    outline: none;
    box-shadow: none;
}

.modal-header.bg-primary .close,
.modal-header.bg-manager .close,
.modal-header.bg-dark .close,
.modal-header .close {
    color: inherit;
    text-shadow: none;
    opacity: 0.85;
}

.modal-header.bg-danger .close {
    color: #fff;
    opacity: 0.9;
}

/* 탑바 아래 여백 (인라인 top:90px / margin-top:70px 대체) */
.modal .modal-dialog:not(.modal-dialog-centered) {
    margin-top: var(--theme-modal-offset-top, 4.5rem);
    top: auto !important;
}

.modal .modal-dialog.modal-dialog-centered_none {
    margin-top: var(--theme-modal-offset-top, 4.5rem);
    top: auto !important;
}

.modal .modal-content[style*='margin-top'] {
    margin-top: 0 !important;
}

/* 모달 폼 */
.modal textarea.form-control {
    height: auto;
    min-height: 120px;
    resize: vertical;
}
