/* 모달 기본 스타일 */
.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal, 9999);
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    background-color: transparent;
    pointer-events: none;
}

.modal.show {
    display: block !important;
}

.modal .modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ece9d8;
    padding: 0;
    border: 2px solid #0054e3;
    border-radius: 6px;
    width: 500px;
    max-width: calc(100% - 40px);
    max-height: calc(100vh - 40px); /* 화면 높이에서 여백 제외 */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    display: flex;
    flex-direction: column; /* 헤더, 바디, 푸터를 세로로 배치 */
}

.modal .modal-header {
    background: linear-gradient(180deg, #0054e3 0%, #0046c7 100%);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 4px 4px 0 0;
    flex-shrink: 0; /* 헤더가 줄어들지 않도록 */
}

.modal .modal-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: bold;
    color: white;
}

.modal .modal-close {
    background: linear-gradient(180deg, #ff6b6b 0%, #dc3545 100%);
    border: 1px solid #c82333;
    color: white;
    font-size: 16px;
    font-weight: bold;
    width: 21px;
    height: 21px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal .modal-body {
    padding: 20px;
    overflow-y: auto; /* 내용이 많을 경우 스크롤 */
    flex: 1; /* 남은 공간 차지 */
    min-height: 0; /* flex 자식의 스크롤을 위해 필요 */
}

.modal .modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #c5c5c5;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0; /* 푸터가 줄어들지 않도록 */
}

/* 업로드 영역 스타일 */
.upload-area {
    border: 2px dashed #ccc;
    border-radius: 4px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: #0054e3;
    background-color: rgba(0, 84, 227, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.upload-queue {
    margin-top: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.upload-item {
    padding: 10px;
    border: 1px solid #ddd;
    margin-bottom: 5px;
    border-radius: 3px;
    background: white;
}

.upload-progress-bar {
    height: 4px;
    background: #0054e3;
    transition: width 0.3s;
    margin-top: 5px;
}

/* 반응형: 작은 화면에서 모달 높이 조정 */
@media (max-height: 700px) {
    .modal .modal-content {
        max-height: calc(100vh - 20px); /* 더 작은 여백으로 최대 공간 활용 */
    }
    
    .modal .modal-body {
        max-height: 400px; /* body의 최대 높이 제한 */
    }
}

@media (max-height: 500px) {
    .modal .modal-content {
        max-height: calc(100vh - 10px);
    }
    
    .modal .modal-body {
        max-height: 250px; /* 아주 작은 화면에서는 더 제한 */
    }
}

/* 모바일 화면 대응 */
@media (max-width: 600px) {
    .modal .modal-content {
        width: calc(100% - 20px);
        max-height: calc(100vh - 20px);
    }
}

/* adminApp.js에서 직접 생성하는 모달 스타일 */
#userModalContent {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ece9d8;
    padding: 0;
    border: 2px solid #0054e3;
    border-radius: 6px;
    width: 500px;
    max-width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    /* display는 인라인 스타일로만 제어 (CSS에서 설정하지 않음) */
    flex-direction: column;
}

/* 인라인 스타일로 display가 설정되면 해당 값을 따름 */

#userModalContent .modal-header {
    flex-shrink: 0;
}

#userModalContent .modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

#userModalContent .modal-footer {
    flex-shrink: 0;
}

/* 낮은 해상도 대응 */
@media (max-height: 700px) {
    #userModalContent {
        max-height: calc(100vh - 20px);
    }
    
    #userModalContent .modal-body {
        max-height: 400px;
    }
}

@media (max-height: 600px) {
    #userModalContent .modal-body {
        max-height: 300px;
    }
}

@media (max-height: 500px) {
    #userModalContent {
        max-height: calc(100vh - 10px);
    }
    
    #userModalContent .modal-body {
        max-height: 220px;
    }
}
